|
@@ -29,7 +29,7 @@
|
|
</n-input-group>
|
|
</n-input-group>
|
|
</span>
|
|
</span>
|
|
</template>
|
|
</template>
|
|
- <n-tab-pane name="all" tab="全部">
|
|
|
|
|
|
+ <n-tab-pane name="all" tab="全部" v-infinite-scroll="onLoadMore">
|
|
<n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
|
|
<n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
|
|
<template v-for="item in collectLists">
|
|
<template v-for="item in collectLists">
|
|
<n-gi>
|
|
<n-gi>
|
|
@@ -45,7 +45,7 @@
|
|
</n-grid>
|
|
</n-grid>
|
|
<empty :show="collectLists.length === 0" :height="500" />
|
|
<empty :show="collectLists.length === 0" :height="500" />
|
|
</n-tab-pane>
|
|
</n-tab-pane>
|
|
- <n-tab-pane name="1" tab="一级">
|
|
|
|
|
|
+ <n-tab-pane name="1" tab="一级" v-infinite-scroll="onLoadMore">
|
|
<n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
|
|
<n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
|
|
<template v-for="item in collectLists">
|
|
<template v-for="item in collectLists">
|
|
<n-gi>
|
|
<n-gi>
|
|
@@ -61,7 +61,7 @@
|
|
</n-grid>
|
|
</n-grid>
|
|
<empty :show="collectLists.length === 0" :height="500" />
|
|
<empty :show="collectLists.length === 0" :height="500" />
|
|
</n-tab-pane>
|
|
</n-tab-pane>
|
|
- <n-tab-pane name="2" tab="二级">
|
|
|
|
|
|
+ <n-tab-pane name="2" tab="二级" v-infinite-scroll="onLoadMore">
|
|
<n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
|
|
<n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
|
|
<template v-for="item in collectLists">
|
|
<template v-for="item in collectLists">
|
|
<n-gi>
|
|
<n-gi>
|
|
@@ -77,7 +77,7 @@
|
|
</n-grid>
|
|
</n-grid>
|
|
<empty :show="collectLists.length === 0" :height="500" />
|
|
<empty :show="collectLists.length === 0" :height="500" />
|
|
</n-tab-pane>
|
|
</n-tab-pane>
|
|
- <n-tab-pane name="3" tab="三级">
|
|
|
|
|
|
+ <n-tab-pane name="3" tab="三级" v-infinite-scroll="onLoadMore">
|
|
<n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
|
|
<n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
|
|
<template v-for="item in collectLists">
|
|
<template v-for="item in collectLists">
|
|
<n-gi>
|
|
<n-gi>
|
|
@@ -101,14 +101,18 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { computed, onMounted, ref, unref, watch, watchEffect } from "vue";
|
|
|
|
-import { useFullscreen } from "@vueuse/core";
|
|
|
|
|
|
+import { computed, ref, unref, watch } from "vue";
|
|
|
|
+import { vInfiniteScroll } from "@vueuse/components";
|
|
|
|
+import { useLoadingBar } from "naive-ui";
|
|
|
|
+// import { useFullscreen } from "@vueuse/core";
|
|
import collectBox from "../components/collectBox";
|
|
import collectBox from "../components/collectBox";
|
|
import subHeader from "../components/subHeader";
|
|
import subHeader from "../components/subHeader";
|
|
import sideMenu from "../components/sideMenu";
|
|
import sideMenu from "../components/sideMenu";
|
|
import empty from "../components/empty.vue";
|
|
import empty from "../components/empty.vue";
|
|
-// import noticeBox from "../components/noticeBox";
|
|
|
|
import { useCollectStore } from "../store/collect";
|
|
import { useCollectStore } from "../store/collect";
|
|
|
|
+import { useThrottleFn } from "@vueuse/core";
|
|
|
|
+
|
|
|
|
+const loadingBar = useLoadingBar();
|
|
const collectStore = useCollectStore();
|
|
const collectStore = useCollectStore();
|
|
const domain = ref(import.meta.env.VITE_DOMAIN_URL);
|
|
const domain = ref(import.meta.env.VITE_DOMAIN_URL);
|
|
const collectLists = computed(() => collectStore.lists);
|
|
const collectLists = computed(() => collectStore.lists);
|
|
@@ -119,9 +123,11 @@ const currentTab = ref("all");
|
|
|
|
|
|
watch(
|
|
watch(
|
|
currentTab,
|
|
currentTab,
|
|
- (val) => {
|
|
|
|
|
|
+ async (val) => {
|
|
|
|
+ loadingBar.start();
|
|
const level = isNaN(Number(val)) ? 0 : Number(val);
|
|
const level = isNaN(Number(val)) ? 0 : Number(val);
|
|
- collectStore.getCollectList(1, level);
|
|
|
|
|
|
+ await collectStore.getCollectList(1, level);
|
|
|
|
+ loadingBar.finish();
|
|
},
|
|
},
|
|
{
|
|
{
|
|
immediate: true,
|
|
immediate: true,
|
|
@@ -138,6 +144,19 @@ const handleSearch = () => {
|
|
collectStore.fetch();
|
|
collectStore.fetch();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+const onLoadMore = useThrottleFn(async () => {
|
|
|
|
+ if (collectStore.isLoad) {
|
|
|
|
+ console.log("canLoadMore", collectStore.canLoadMore);
|
|
|
|
+ collectStore.canLoadMore && loadingBar.start();
|
|
|
|
+ const level = isNaN(Number(currentTab.value))
|
|
|
|
+ ? 0
|
|
|
|
+ : Number(currentTab.value);
|
|
|
|
+ const code = await collectStore.loadMore(level);
|
|
|
|
+ console.log("code", code);
|
|
|
|
+ loadingBar.finish();
|
|
|
|
+ }
|
|
|
|
+}, 1000);
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|