优化报销管理增加挂靠
This commit is contained in:
1 parent
7b1c94b5ff
commit
ee49ef15b5
24 files changed
+1267
-70
No files matched your search
@@ -344,13 +344,15 @@ function findFirstValidRoute(routes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 跳转统一认证中心;地址未配置时给出提示,避免白屏 */
|
||||
/** 跳转统一认证中心;地址未配置/检测到循环时给出提示,避免白屏或无限跳转 */
|
||||
async function gotoAuthorize() {
|
||||
try {
|
||||
await redirectToAuthorize();
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
window.alert(e?.message || "统一认证跳转失败,请检查认证中心配置");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,14 +377,16 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
next({ path: "/home" });
|
||||
} else {
|
||||
await gotoAuthorize();
|
||||
const ok = await gotoAuthorize();
|
||||
if (!ok) next(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 未登录:统一走认证中心(本地登录已停用)
|
||||
if (!token) {
|
||||
await gotoAuthorize();
|
||||
const ok = await gotoAuthorize();
|
||||
if (!ok) next(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -391,7 +395,14 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 令牌失效时 ensureUserInfo 会清空登录态并返回 null,此时重新登录。
|
||||
const info = await ensureUserInfo();
|
||||
if (!info) {
|
||||
await gotoAuthorize();
|
||||
// 只有登录态确实被清空(确认令牌失效)才重新授权;userinfo 接口临时故障
|
||||
// 时保留 token 放行,避免「登录成功 → 接口抖动 → 回认证中心」的循环。
|
||||
if (localStorage.getItem("token")) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
const ok = await gotoAuthorize();
|
||||
if (!ok) next(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user