diff --git a/src/pages/JobPortal/index.tsx b/src/pages/JobPortal/index.tsx index b168da6..b664e98 100644 --- a/src/pages/JobPortal/index.tsx +++ b/src/pages/JobPortal/index.tsx @@ -16,6 +16,7 @@ import { import { history } from '@umijs/max'; import { getJobTitleTreeSelect, getJobRecommend } from '@/services/common/jobTitle'; import { getGetInfoCache, saveGetInfoCache } from '@/utils/jobPortalAuth'; +import { getAccessToken } from '@/access'; import { getUserInfo } from '@/services/session'; import JobPortalHeader from '@/components/JobPortalHeader'; import './index.less'; @@ -144,7 +145,8 @@ const JobPortalPage: React.FC = () => { setJobTitles(cached); return; } - // 缓存不存在则请求 /api/getInfo 写入后再读取 + // 未登录用户不请求 /api/getInfo,避免 401 触发强制跳转登录页 + if (!getAccessToken()) return; getUserInfo({ skipErrorHandler: true }) .then((res: any) => { saveGetInfoCache(res as Record);