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:
42
src/app.tsx
42
src/app.tsx
@@ -10,6 +10,7 @@ import {
|
||||
exchangeThirdPartyCredential,
|
||||
isThirdPartyTransitionPage,
|
||||
} from './utils/thirdPartyLogin';
|
||||
import { shouldSkipManagementBootstrap } from './utils/routeContext';
|
||||
import { saveGetInfoCache } from './utils/jobPortalAuth';
|
||||
import {
|
||||
getRemoteMenu,
|
||||
@@ -73,19 +74,8 @@ export async function getInitialState(): Promise<{
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
// 如果不是登录页面,执行
|
||||
const { location } = history;
|
||||
// 排除登录页面、过渡页面和求职者页面(考虑基础路径 /shihezi/)
|
||||
const isTransitionPage = location.pathname === '/' ||
|
||||
location.pathname === '/login-tow' ||
|
||||
location.pathname === '/shihezi/' ||
|
||||
location.pathname === '/shihezi/login-tow';
|
||||
|
||||
// 排除求职者相关页面
|
||||
const isJobPortalPage = location.pathname.startsWith('/job-portal') ||
|
||||
location.pathname.startsWith('/shihezi/job-portal');
|
||||
|
||||
if (location.pathname !== PageEnum.LOGIN && !isTransitionPage && !isJobPortalPage) {
|
||||
if (!shouldSkipManagementBootstrap(location.pathname)) {
|
||||
const currentUser = await fetchUserInfo();
|
||||
return {
|
||||
fetchUserInfo,
|
||||
@@ -135,16 +125,10 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
|
||||
onPageChange: () => {
|
||||
const { location } = history;
|
||||
// 如果没有登录,重定向到 login,但排除过渡页面和求职者页面(考虑基础路径 /shihezi/)
|
||||
const isTransitionPage = location.pathname === '/' ||
|
||||
location.pathname === '/login-tow' ||
|
||||
location.pathname === '/shihezi/' ||
|
||||
location.pathname === '/shihezi/login-tow';
|
||||
|
||||
// 排除求职者相关页面
|
||||
const isJobPortalPage = location.pathname.startsWith('/job-portal') ||
|
||||
location.pathname.startsWith('/shihezi/job-portal');
|
||||
|
||||
if (!initialState?.currentUser && location.pathname !== PageEnum.LOGIN && !isTransitionPage && !isJobPortalPage) {
|
||||
if (
|
||||
!initialState?.currentUser &&
|
||||
!shouldSkipManagementBootstrap(location.pathname)
|
||||
) {
|
||||
history.push(PageEnum.LOGIN);
|
||||
}
|
||||
},
|
||||
@@ -205,11 +189,12 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
|
||||
|
||||
export async function onRouteChange({ clientRoutes, location }: { clientRoutes: any; location: any }) {
|
||||
const menus = getRemoteMenu();
|
||||
// console.log('onRouteChange', clientRoutes, location, menus);
|
||||
|
||||
// 如果路由信息未加载,尝试重新获取路由信息
|
||||
const token = getAccessToken();
|
||||
if (menus === null && location.pathname !== PageEnum.LOGIN && token) {
|
||||
if (
|
||||
menus === null &&
|
||||
token &&
|
||||
!shouldSkipManagementBootstrap(location.pathname)
|
||||
) {
|
||||
console.log('检测到路由信息未加载,正在重新获取路由信息...');
|
||||
|
||||
// 重新获取路由信息,而不是刷新页面
|
||||
@@ -248,6 +233,11 @@ export async function render(oldRender: () => void) {
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSkipManagementBootstrap(pathname)) {
|
||||
oldRender();
|
||||
return;
|
||||
}
|
||||
|
||||
const token = getAccessToken();
|
||||
if (!token || token.length === 0) {
|
||||
oldRender();
|
||||
|
||||
Reference in New Issue
Block a user