优化报销管理增加挂靠

This commit is contained in:
hero920103 committed 2026-11-06 01:13:28 +08:00
1 parent 7b1c94b5ff
commit ee49ef15b5
24 files changed
+1267 -70

No files matched your search

+7 -1
View File
@@ -1,5 +1,5 @@
import axios from 'axios';
import { refreshAccessToken, clearTokens, redirectToAuthorize } from '@/utils/authClient';
import { refreshAccessToken, clearTokens, redirectToAuthorize, isAuthHandoff } from '@/utils/authClient';
// 统一认证模式下 401 后正在跳转登录的标志,避免并发请求同时触发跳转造成死循环
let ssoRedirecting = false;
@@ -25,6 +25,9 @@ function authError(message) {
// 清空登录态并回认证中心重新登录(只跳一次,避免并发请求反复跳转)
function redirectToLoginOnce() {
// 交接页里的 401 来自旧 token,不代表刚换到的新登录态失效。
// 在这里清 token / 跳认证中心会造成「登录成功后又回登录页」。
if (isAuthHandoff()) return;
clearTokens();
localStorage.removeItem('userInfo');
if (ssoRedirecting) return;
@@ -42,6 +45,9 @@ function redirectToLoginOnce() {
// 「重放」与「续期」是两个独立阶段:前者不消耗 refresh_token,只挡一次;
// 否则令牌真的过期时就永远等不到续期,只会一路报「无效的token」。
async function recoverAuth(config, bizMsg) {
// 交接页的 401 来自旧 token,不能用旧 refresh_token 续期(会触发重放吊销),
// 也不能重放或自动跳转;换码完成后整页重载即可恢复正常请求。
if (isAuthHandoff()) return Promise.reject(authError('正在完成登录,请稍候'));
const latestToken = localStorage.getItem('token') || '';
const sentToken = String(config?.headers?.Authorization || '').replace(/^Bearer\s+/i, '');
if (!config?._replayedWithLatest && latestToken && latestToken !== sentToken) {