feat: 🎸 重新封装了滚动加载/解决了一个引用bug

This commit is contained in:
2025-08-21 13:37:27 +08:00
parent 52572dfdeb
commit 916d210290
3 changed files with 63 additions and 36 deletions

View File

@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { jobAPI } from "@/services/api";
import { getJobsList } from "@/services";
import { mapJobList } from "@/utils/dataMapper";
import JobList from "@/pages/CompanyJobsPage/components/JobList";
@@ -20,12 +20,12 @@ const CompanyJobsListPage = () => {
const fetchJobs = async () => {
try {
setLoading(true);
const response = await jobAPI.getList({
const response = await getJobsList({
page,
pageSize: 20,
isActive: true
isActive: true,
});
const mappedJobs = mapJobList(response.data || response);
setJobs(mappedJobs);
setTotal(response.total || mappedJobs.length);
@@ -39,12 +39,15 @@ const CompanyJobsListPage = () => {
if (loading && jobs.length === 0) {
return (
<div className="company-jobs-list-page-wrapper" style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
minHeight: '400px'
}}>
<div
className="company-jobs-list-page-wrapper"
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
minHeight: "400px",
}}
>
<p>加载中...</p>
</div>
);
@@ -54,11 +57,13 @@ const CompanyJobsListPage = () => {
<ul className="company-jobs-list-page-wrapper">
<JobList data={jobs} />
{jobs.length === 0 && !loading && (
<div style={{
textAlign: 'center',
padding: '40px',
color: '#999'
}}>
<div
style={{
textAlign: "center",
padding: "40px",
color: "#999",
}}
>
暂无岗位信息
</div>
)}

View File

@@ -72,7 +72,6 @@ const ProjectLibrary = () => {
<InfiniteScroll
loadMore={fetchProjects}
hasMore={hasMore}
threshold={100}
empty={projectList.length === 0}
className="user-portfolio-list"
>