forked from share121/inter-knot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
40 lines (38 loc) · 1.02 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<template>
<NuxtPwaManifest />
<header-bar />
<main-container />
<write-btn />
<refresh-btn @refresh="refresh" />
</template>
<script setup lang="ts">
const store = useConfigStore();
async function refresh() {
console.log("refresh");
store.data.length = 0;
document.documentElement.scrollTop = 0;
const res = await getDiscussions(null);
store.hasNextPage = res.hasNextPage;
store.endCursor = res.endCursor;
store.data.push(...res.discussions);
removeDuplicateArticle(store.data);
while (
document.documentElement.scrollHeight !==
document.documentElement.clientHeight
) {
await delay(100);
}
while (
document.documentElement.scrollHeight <=
document.documentElement.clientHeight
) {
console.log("load");
if (store.hasNextPage === false) break;
const res = await getDiscussions(store.endCursor);
store.hasNextPage = res.hasNextPage;
store.endCursor = res.endCursor;
store.data.push(...res.discussions);
removeDuplicateArticle(store.data);
}
}
</script>