commit提交记录分页问题‘

This commit is contained in:
caishi 2024-11-14 16:21:26 +08:00
parent b863d8bfe6
commit 6b9f413532
1 changed files with 4 additions and 5 deletions

View File

@ -58,7 +58,6 @@ export default (props) => {
const { sha , projectsId, owner } = match.params; const { sha , projectsId, owner } = match.params;
const [ dropLoading, setDropLoading] = useState(false); //loading const [ dropLoading, setDropLoading] = useState(false); //loading
const [hasMore, setHasMore] = useState(true); //
const limit = 200; const limit = 200;
const fRef = useRef(); const fRef = useRef();
@ -107,8 +106,9 @@ export default (props) => {
async function InitDiffData (){ async function InitDiffData (){
let f = fRef.current ? fRef.current.files : []; let f = fRef.current ? fRef.current.files : [];
let p = (fRef.current && fRef.current.page) || 1; let p = fRef.current ? fRef.current.page : 1;
if (!hasMore || dropLoading || !isSpin) { let hm = fRef.current ? fRef.current.hasMore : true;
if (!hm || dropLoading || !isSpin) {
return; return;
} }
setDropLoading(true); setDropLoading(true);
@ -119,8 +119,7 @@ export default (props) => {
if(res?.status === 200){ if(res?.status === 200){
let arr = p === 1 ? res.data.files : [...f,...res.data.files]; let arr = p === 1 ? res.data.files : [...f,...res.data.files];
setData(res.data); setData(res.data);
fRef.current = {files:arr,page:p+1}; fRef.current = {files:arr,page:p+1,hasMore:arr.length === limit};
setHasMore(arr.length === limit);
setDropLoading(false); setDropLoading(false);
} }
}) })