111
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:
francis-fh
2026-06-04 18:47:59 +08:00
parent 971e2b8be5
commit 134c1ecece
13 changed files with 646 additions and 20186 deletions

View File

@@ -19,8 +19,10 @@ import {
import { history, useLocation, useModel } from '@umijs/max';
import {
ensureJobPortalLogin,
getGetInfoCache,
isJobPortalLoggedIn,
PORTAL_LOGIN_URL,
prefetchJobPortalUserInfo,
} from '@/utils/jobPortalAuth';
import { getJobRecommend } from '@/services/common/jobTitle';
import { getMessageTotal } from '@/services/jobportal/user';
@@ -56,12 +58,18 @@ const JobPortalHeader: React.FC<JobPortalHeaderProps> = ({
const { initialState } = useModel('@@initialState');
const currentUser = initialState?.currentUser;
// 获取用户名,优先使用 initialState其次使用 localStorage 中的 userInfo
// 获取用户名,优先 initialState其次 getInfo 缓存,最后 appUser 缓存
const getUserName = (): string => {
if (currentUser?.nickName) {
return currentUser.nickName;
}
// 尝试从 localStorage 获取用户信息
const getInfoUser = getGetInfoCache()?.user;
if (getInfoUser?.nickName) {
return String(getInfoUser.nickName);
}
if (getInfoUser?.userName) {
return String(getInfoUser.userName);
}
try {
const cachedUserInfo = localStorage.getItem('userInfo');
if (cachedUserInfo) {
@@ -79,6 +87,13 @@ const JobPortalHeader: React.FC<JobPortalHeaderProps> = ({
const userName = getUserName();
const loggedIn = isJobPortalLoggedIn();
// SSO 仅有 token、本地尚无 userInfo 时预拉求职者资料
useEffect(() => {
if (loggedIn) {
prefetchJobPortalUserInfo();
}
}, [loggedIn]);
// 判断激活导航(简化为 startsWith 匹配)
const isHome = /^\/job-portal(\/(list|detail))?$/.test(location.pathname);
const isResume = location.pathname.startsWith('/job-portal/resume');