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();
} }