fix(admin): 登录接口 401 不再误报为「登录已过期」
- client 原将所有 401 当会话过期处理,覆盖了登录接口的凭据错误消息 - 排除 /admin/login,登录失败改为显示后端真实提示(用户名或密码错误) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,9 @@ export async function request<T>(
|
|||||||
|
|
||||||
const res = await fetch(path, { ...init, headers })
|
const res = await fetch(path, { ...init, headers })
|
||||||
|
|
||||||
if (res.status === 401) {
|
// 登录接口的 401 是「凭据错误」,交给下方按后端 message 处理;
|
||||||
|
// 其它接口的 401 才视为会话过期:清 token 并跳登录页
|
||||||
|
if (res.status === 401 && !path.includes('/admin/login')) {
|
||||||
clearToken()
|
clearToken()
|
||||||
// basename=/admin,登录路由实际是 /admin/login
|
// basename=/admin,登录路由实际是 /admin/login
|
||||||
if (!window.location.pathname.endsWith('/login')) {
|
if (!window.location.pathname.endsWith('/login')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user