fix: 修改权限提示

This commit is contained in:
ZhuRui
2026-08-07 14:48:25 +08:00
parent ba71b504e7
commit 0f611ad926
+6 -5
View File
@@ -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<AuthData> {
const promise = get('/op/permission')
.then((res) => normalizeAuthData(res))
.catch((err) => {
handleAuthFetchFailure();
.catch((err: Error) => {
handleAuthFetchFailure(err.message);
throw err;
});