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
+1 -1
View File
@@ -299,7 +299,7 @@ func generateConfigFile(dbType string, req SetupRequest, jwtSecret string) strin
content.WriteString(" name: verification-platform\n")
content.WriteString(" env: production\n")
content.WriteString(" port: \"8080\"\n")
content.WriteString(fmt.Sprintf(" jwt_secret: %s\n", jwtSecret))
content.WriteString(fmt.Sprintf(" jwt_secret: \"%s\"\n", jwtSecret))
content.WriteString(" jwt_expire: 24h\n\n")
content.WriteString("# 数据库配置\n")
+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}`)
}