This commit is contained in:
Last 2025-03-08 05:11:20 +08:00
parent 3dc759235a
commit 57a6e31b44

View File

@ -97,28 +97,24 @@ const 屏幕宽高重置 = () => {
WIDTH.value = 列宽 WIDTH.value = 列宽
}; };
const disabled = ref(false); // const page = ref(3) //
const inadvance = ref(400); // const disabled = ref(false) //
const inadvance = ref(400) //
const page = ref(3); //
const nextPage = () => { const nextPage = () => {
fetch(`/api/gallery?page=${page.value}`).then((res) => { fetch(`/api/gallery?page=${page.value}`).then(res => res.json()).then(data => {
page.value = page.value + 1; page.value = page.value + 1
disabled.value = false; disabled.value = !!data.length
if (res.status === 200) { data.value = data.value.concat(data)
res.json().then((rest) => { })
data.value = data.value.concat(rest) }
});
}
});
};
const handleScroll = () => { const handleScroll = () => {
if (disabled.value) return; if (disabled.value) return;
const { scrollHeight, scrollTop, clientHeight } = document.documentElement; const { scrollHeight, scrollTop, clientHeight } = document.documentElement;
if (scrollHeight - scrollTop - clientHeight <= inadvance.value) { if (scrollHeight - scrollTop - clientHeight <= inadvance.value) {
disabled.value = true //
console.log("scroll to bottom"); console.log("scroll to bottom");
disabled.value = true; //
inadvance.value = 1280; // 使 inadvance.value = 1280; // 使
nextPage(); nextPage();
} }