feat: update 404 handler

This commit is contained in:
tim
2025-07-14 19:33:20 +08:00
parent e686fcfb23
commit fbe63b3943
3 changed files with 5 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ export default {
},
computed: {
hideMenu() {
return ['/login', '/signup'].includes(this.$route.path)
return ['/login', '/signup', '/404'].includes(this.$route.path)
}
}
}

View File

@@ -1,7 +1,7 @@
<template>
<div class="not-found-page">
<h1>404 - 页面不存在</h1>
<p>你访问的页面不存在或已被删除</p>
<p>你访问的页面不存在或已被删除</p>
<router-link to="/">返回首页</router-link>
</div>
</template>
@@ -17,9 +17,9 @@ export default {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: calc(100vh - var(--header-height));
text-align: center;
background-color: var(--background-color);
}
.not-found-page h1 {

View File

@@ -1,5 +1,6 @@
package com.openisle.controller;
import com.openisle.exception.NotFoundException;
import com.openisle.model.User;
import com.openisle.service.*;
import org.springframework.beans.factory.annotation.Value;
@@ -80,7 +81,7 @@ public class UserController {
@GetMapping("/{identifier}")
public ResponseEntity<UserDto> getUser(@PathVariable("identifier") String identifier,
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));
}