fix: JWT密钥YAML格式和401错误处理

- 修复JWT密钥在YAML配置文件中未加引号导致解析错误的问题
- 添加dashboard页面401错误处理,自动清除token并跳转登录页
This commit is contained in:
2026-05-04 09:12:50 +08:00
parent 9262d066bb
commit 7ab899b44f
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -145,6 +145,7 @@ async function fetchDashboard() {
const token = localStorage.getItem('token')
if (!token) {
console.error('No token found')
router.push('/login')
return
}
@@ -154,6 +155,13 @@ async function fetchDashboard() {
},
})
if (response.status === 401) {
localStorage.removeItem('token')
localStorage.removeItem('user')
router.push('/login')
return
}
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}