fix(admin): 登录失败显示错误提示 (#14)

fix(admin): 登录失败显示错误提示

Merges #14. Related to #13.
This commit was merged in pull request #14.
This commit is contained in:
cykj committed 2026-11-10 08:15:10 +00:00
commit e8060287e0
1 file changed
+6 -2
+6 -2
View File
@@ -161,7 +161,7 @@
})
if (!result?.token) {
throw new Error('Login failed - no token received')
throw new Error('登录失败,未返回令牌')
}
const permissions = result.permissions || []
@@ -181,8 +181,12 @@
const redirect = route.query.redirect as string
router.push(redirect || '/')
} catch (error) {
if (!(error instanceof HttpError)) {
// 匿名登录接口的 401 不会走全局 showError,需在此提示服务端 detail。
if (error instanceof HttpError) {
ElMessage.error(error.message)
} else {
console.error('[Login] Unexpected error:', error)
ElMessage.error(error instanceof Error ? error.message : '登录失败,请稍后重试')
}
await loadCaptcha()
} finally {