mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-04-21 11:27:27 +08:00
feat: update 404 handler
This commit is contained in:
@@ -26,7 +26,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
hideMenu() {
|
hideMenu() {
|
||||||
return ['/login', '/signup'].includes(this.$route.path)
|
return ['/login', '/signup', '/404'].includes(this.$route.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="not-found-page">
|
<div class="not-found-page">
|
||||||
<h1>404 - 页面不存在</h1>
|
<h1>404 - 页面不存在</h1>
|
||||||
<p>你访问的页面不存在或已被删除。</p>
|
<p>你访问的页面不存在或已被删除</p>
|
||||||
<router-link to="/">返回首页</router-link>
|
<router-link to="/">返回首页</router-link>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -17,9 +17,9 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
|
||||||
height: calc(100vh - var(--header-height));
|
height: calc(100vh - var(--header-height));
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
background-color: var(--background-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.not-found-page h1 {
|
.not-found-page h1 {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.openisle.controller;
|
package com.openisle.controller;
|
||||||
|
|
||||||
|
import com.openisle.exception.NotFoundException;
|
||||||
import com.openisle.model.User;
|
import com.openisle.model.User;
|
||||||
import com.openisle.service.*;
|
import com.openisle.service.*;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -80,7 +81,7 @@ public class UserController {
|
|||||||
@GetMapping("/{identifier}")
|
@GetMapping("/{identifier}")
|
||||||
public ResponseEntity<UserDto> getUser(@PathVariable("identifier") String identifier,
|
public ResponseEntity<UserDto> getUser(@PathVariable("identifier") String identifier,
|
||||||
Authentication auth) {
|
Authentication auth) {
|
||||||
User user = userService.findByIdentifier(identifier).orElseThrow();
|
User user = userService.findByIdentifier(identifier).orElseThrow(() -> new NotFoundException("User not found"));
|
||||||
return ResponseEntity.ok(toDto(user, auth));
|
return ResponseEntity.ok(toDto(user, auth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user