From 0f611ad9267b4a6a7ebf5541e043e92e665e3dea Mon Sep 17 00:00:00 2001 From: ZhuRui Date: Fri, 7 Aug 2026 14:48:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/menu.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/menu.ts b/src/api/menu.ts index f9be5b1..5fb2961 100644 --- a/src/api/menu.ts +++ b/src/api/menu.ts @@ -18,6 +18,7 @@ export interface AuthData { } const AUTH_FETCH_FAIL_MSG = '账户权限获取失败,请重新登录'; +const AUTH_EMPTY_MSG = '当前账户权限无任何权限,请联系管理员'; function normalizeAuthData(res: any): AuthData { if (res?.code != null && res.code != 200) { @@ -29,7 +30,7 @@ function normalizeAuthData(res: any): AuthData { const permsList = data.permsList || []; if (permsList.length === 0) { - throw new Error(AUTH_FETCH_FAIL_MSG); + throw new Error(AUTH_EMPTY_MSG); } const nickname = data.nickName || ''; @@ -46,9 +47,9 @@ function normalizeAuthData(res: any): AuthData { return { roleList, permsList, nickname, phone }; } -function handleAuthFetchFailure() { +function handleAuthFetchFailure(msg?: string) { clearAuthDataCache(); - forceReLogin(AUTH_FETCH_FAIL_MSG); + forceReLogin(msg); } /** @@ -62,8 +63,8 @@ export function fetchAuthData(): Promise { const promise = get('/op/permission') .then((res) => normalizeAuthData(res)) - .catch((err) => { - handleAuthFetchFailure(); + .catch((err: Error) => { + handleAuthFetchFailure(err.message); throw err; });