完整的教务系统前端项目 - 包含所有修复和9月份数据
This commit is contained in:
16
src/pages/CompanyJobsListPage/index.css
Normal file
16
src/pages/CompanyJobsListPage/index.css
Normal file
@@ -0,0 +1,16 @@
|
||||
.company-jobs-list-page-wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 20px;
|
||||
|
||||
.jobs-list-margin {
|
||||
> li {
|
||||
width: 556px;
|
||||
margin-right: 20px;
|
||||
.company-jobs-info {
|
||||
width: 430px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
src/pages/CompanyJobsListPage/index.jsx
Normal file
47
src/pages/CompanyJobsListPage/index.jsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { useState, useCallback } from "react";
|
||||
import JobList from "@/pages/CompanyJobsPage/components/JobList";
|
||||
import InfiniteScroll from "@/components/InfiniteScroll";
|
||||
import { getJobsList } from "@/services";
|
||||
|
||||
import "./index.css";
|
||||
|
||||
const PAGE_SIZE = 20;
|
||||
|
||||
const CompanyJobsListPage = () => {
|
||||
const [jobs, setJobs] = useState([]);
|
||||
const [listPage, setListPage] = useState(1);
|
||||
const [listHasMore, setListHasMore] = useState(true);
|
||||
|
||||
const fetchJobs = useCallback(async () => {
|
||||
const res = await getJobsList({
|
||||
page: listPage,
|
||||
pageSize: PAGE_SIZE,
|
||||
isActive: true,
|
||||
});
|
||||
if (res.success) {
|
||||
// Mock数据已经是前端格式,不需要映射
|
||||
setJobs((prevList) => {
|
||||
const newList = [...prevList, ...res.data];
|
||||
if (res.total === newList?.length) {
|
||||
setListHasMore(false);
|
||||
} else {
|
||||
setListPage((prevPage) => prevPage + 1);
|
||||
}
|
||||
return newList;
|
||||
});
|
||||
}
|
||||
}, [listPage]);
|
||||
|
||||
return (
|
||||
<InfiniteScroll
|
||||
loadMore={fetchJobs}
|
||||
hasMore={listHasMore}
|
||||
empty={jobs.length === 0}
|
||||
className="company-jobs-list-page-wrapper"
|
||||
>
|
||||
<JobList data={jobs} className="jobs-list-margin" />
|
||||
</InfiniteScroll>
|
||||
);
|
||||
};
|
||||
|
||||
export default CompanyJobsListPage;
|
||||
Reference in New Issue
Block a user