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 = 列宽
};
const disabled = ref(false); // 上锁
const inadvance = ref(400); // 距离
const page = ref(3) // 页码
const disabled = ref(false) // 上锁
const inadvance = ref(400) // 距离
const page = ref(3); // 页码
const nextPage = () => {
fetch(`/api/gallery?page=${page.value}`).then((res) => {
page.value = page.value + 1;
disabled.value = false;
if (res.status === 200) {
res.json().then((rest) => {
data.value = data.value.concat(rest)
});
fetch(`/api/gallery?page=${page.value}`).then(res => res.json()).then(data => {
page.value = page.value + 1
disabled.value = !!data.length
data.value = data.value.concat(data)
})
}
});
};
const handleScroll = () => {
if (disabled.value) return;
const { scrollHeight, scrollTop, clientHeight } = document.documentElement;
if (scrollHeight - scrollTop - clientHeight <= inadvance.value) {
disabled.value = true // 加载期间上锁
console.log("scroll to bottom");
disabled.value = true; // 加载期间上锁
inadvance.value = 1280; // 加高判定值使卡顿感减弱
nextPage();
}