11
Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled
Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Spin, message } from 'antd';
|
||||
import { history, useLocation, useModel } from '@umijs/max';
|
||||
import { getAccessToken } from '@/access';
|
||||
import { clearAllClientStorage, getAccessToken } from '@/access';
|
||||
import { getRoutersInfo, setRemoteMenu } from '@/services/session';
|
||||
import { flushSync } from 'react-dom';
|
||||
|
||||
@@ -103,6 +103,9 @@ export default function ThirdPartyRedirect() {
|
||||
if (pageName === 'personal-center') {
|
||||
history.replace(`/job-portal/${pageName}`);
|
||||
}
|
||||
if (pageName === 'policy') {
|
||||
history.replace(`/job-portal/${pageName}`);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
const menus = await getRoutersInfo();
|
||||
@@ -124,6 +127,30 @@ export default function ThirdPartyRedirect() {
|
||||
}
|
||||
};
|
||||
|
||||
/** URL 未带 token 时清除本地登录态(与退出登录一致) */
|
||||
const performLogout = () => {
|
||||
clearAllClientStorage();
|
||||
setRemoteMenu(null);
|
||||
flushSync(() => {
|
||||
setInitialState((s) => ({
|
||||
...s,
|
||||
currentUser: undefined,
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
const redirectByPageName = (params: URLSearchParams, pageName: string | null) => {
|
||||
if (!pageName) {
|
||||
history.replace('/job-portal');
|
||||
return;
|
||||
}
|
||||
if (pageName === 'jobDetail') {
|
||||
history.replace(`/job-portal/detail/${params.get('jobId')}`);
|
||||
return;
|
||||
}
|
||||
history.replace(`/job-portal/${pageName}`);
|
||||
};
|
||||
|
||||
const handleLoginRedirect = async () => {
|
||||
try {
|
||||
setIsError(false);
|
||||
@@ -132,11 +159,8 @@ export default function ThirdPartyRedirect() {
|
||||
const token = params.get('token');
|
||||
const pageName = params.get('pageName');
|
||||
|
||||
if (!code && !token && !pageName) {
|
||||
setIsError(true);
|
||||
setStatus(STATUS_TEXT.noCredential);
|
||||
}
|
||||
if (code || token) {
|
||||
// token 与 code 互斥,仅其一用于 SSO 换票
|
||||
if (token || code) {
|
||||
const sessionToken = getAccessToken();
|
||||
if (!sessionToken) {
|
||||
setIsError(true);
|
||||
@@ -147,21 +171,10 @@ export default function ThirdPartyRedirect() {
|
||||
await fetchUserInfo();
|
||||
return;
|
||||
}
|
||||
if (!token) {
|
||||
if (!pageName) {
|
||||
history.replace(`/job-portal`);
|
||||
}
|
||||
if (pageName === 'message') {
|
||||
history.replace(`/job-portal/${pageName}`);
|
||||
}
|
||||
if (pageName === 'jobDetail') {
|
||||
history.replace(`/job-portal/detail/${params.get('jobId')}`);
|
||||
}
|
||||
if (pageName === 'personal-center') {
|
||||
history.replace(`/job-portal/${pageName}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// URL 无 token/code:退出登录后跳转(无 pageName 则去求职门户首页)
|
||||
performLogout();
|
||||
redirectByPageName(params, pageName);
|
||||
} catch (error) {
|
||||
console.error('单点进入失败:', error);
|
||||
setIsError(true);
|
||||
|
||||
Reference in New Issue
Block a user