forked from Gitlink/forgeplus-react
commit提交记录分页问题‘
This commit is contained in:
parent
b863d8bfe6
commit
6b9f413532
|
@ -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);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue