bug修复
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:
@@ -15,6 +15,8 @@ import {
|
||||
} from '@ant-design/icons';
|
||||
import { history } from '@umijs/max';
|
||||
import { getJobTitleTreeSelect, getJobRecommend } from '@/services/common/jobTitle';
|
||||
import { getGetInfoCache, saveGetInfoCache } from '@/utils/jobPortalAuth';
|
||||
import { getUserInfo } from '@/services/session';
|
||||
import JobPortalHeader from '@/components/JobPortalHeader';
|
||||
import './index.less';
|
||||
|
||||
@@ -128,6 +130,33 @@ const JobPortalPage: React.FC = () => {
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [itemsPerPage] = useState<number>(6);
|
||||
const [totalPages, setTotalPages] = useState<number>(1);
|
||||
const [activeJobTitle, setActiveJobTitle] = useState<string>('');
|
||||
const [jobTitles, setJobTitles] = useState<string[]>(() => {
|
||||
// 初始化时先尝试从缓存读取
|
||||
return (getGetInfoCache()?.user as any)?.jobTitles || [];
|
||||
});
|
||||
|
||||
// 缓存可能因 SSO 登录时序问题尚未写入,主动拉取一次
|
||||
useEffect(() => {
|
||||
if (jobTitles.length > 0) return;
|
||||
const cached = (getGetInfoCache()?.user as any)?.jobTitles;
|
||||
if (cached?.length) {
|
||||
setJobTitles(cached);
|
||||
return;
|
||||
}
|
||||
// 缓存不存在则请求 /api/getInfo 写入后再读取
|
||||
getUserInfo({ skipErrorHandler: true })
|
||||
.then((res: any) => {
|
||||
saveGetInfoCache(res as Record<string, unknown>);
|
||||
const titles = (res?.user as any)?.jobTitles;
|
||||
if (titles?.length) {
|
||||
setJobTitles(titles);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// 静默处理
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchJobTitleData = async () => {
|
||||
@@ -147,9 +176,9 @@ const JobPortalPage: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const fetchJobRecommendData = async () => {
|
||||
const fetchJobRecommendData = async (jobTitle?: string) => {
|
||||
try {
|
||||
const response = await getJobRecommend();
|
||||
const response = await getJobRecommend(jobTitle ? { jobTitle } : undefined);
|
||||
setJobRecommendData(response);
|
||||
} catch {
|
||||
// 静默处理
|
||||
@@ -217,6 +246,20 @@ const JobPortalPage: React.FC = () => {
|
||||
history.push(`/job-portal/list`, { queryParams: { name } });
|
||||
};
|
||||
|
||||
const handleExpectationTagClick = (jobTitle: string) => {
|
||||
const newActive = activeJobTitle === jobTitle ? '' : jobTitle;
|
||||
setActiveJobTitle(newActive);
|
||||
const fetchJobRecommendData = async () => {
|
||||
try {
|
||||
const response = await getJobRecommend(newActive ? { jobTitle: newActive } : undefined);
|
||||
setJobRecommendData(response);
|
||||
} catch {
|
||||
// 静默处理
|
||||
}
|
||||
};
|
||||
fetchJobRecommendData();
|
||||
};
|
||||
|
||||
const renderJobCards = () => {
|
||||
const jobs = jobRecommendData?.data;
|
||||
if (jobs?.length) {
|
||||
@@ -358,7 +401,23 @@ const JobPortalPage: React.FC = () => {
|
||||
|
||||
<div className="jobs-section">
|
||||
<div className="jobs-section-header">
|
||||
<Title level={3} className="jobs-title">热门职位推荐</Title>
|
||||
<div className="jobs-section-header-left">
|
||||
<Title level={3} className="jobs-title">热门职位推荐</Title>
|
||||
{jobTitles.length > 0 && (
|
||||
<div className="expectation-tags">
|
||||
<span className="expectation-label">求职期望</span>
|
||||
{jobTitles.map((title) => (
|
||||
<Tag
|
||||
key={title}
|
||||
className={`expectation-tag ${activeJobTitle === title ? 'active' : ''}`}
|
||||
onClick={() => handleExpectationTagClick(title)}
|
||||
>
|
||||
{title}
|
||||
</Tag>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<span className="view-more" onClick={() => history.push('/job-portal/list')}>
|
||||
查看更多 >
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user