exhibition.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="main">
  3. <div class="content">
  4. <sub-header />
  5. <div class="left">
  6. <n-tabs type="line" pane-class="tab-content" v-model:value="currentTab">
  7. <template #prefix>
  8. <span class="meta-title">
  9. <img src="@/assets/subtitle_2.png" />
  10. </span>
  11. </template>
  12. <n-tab-pane name="all" tab="全部展览" v-infinite-scroll="onLoadMore">
  13. <n-grid :x-gap="XGap" :y-gap="YGap" :cols="1" class="tab-grid">
  14. <template v-for="item in exhibitionList">
  15. <n-gi>
  16. <!-- {{ item }} -->
  17. <exhibition-box
  18. :id="item.id"
  19. :title="item.name"
  20. :cover="domain + item.thumb"
  21. :content="item.richText"
  22. :location="item.address"
  23. :type="item.type"
  24. isHasVR
  25. />
  26. </n-gi>
  27. </template>
  28. </n-grid>
  29. <empty :show="exhibitionList.length === 0" :height="500" />
  30. </n-tab-pane>
  31. <n-tab-pane name="long" tab="常设展览" v-infinite-scroll="onLoadMore">
  32. <n-grid :x-gap="XGap" :y-gap="YGap" :cols="1" class="tab-grid">
  33. <template v-for="item in exhibitionList">
  34. <n-gi>
  35. <exhibition-box
  36. :id="item.id"
  37. :title="item.name"
  38. :cover="domain + item.thumb"
  39. :content="item.richText"
  40. :location="item.address"
  41. :type="item.type"
  42. :isHasVR="item.link.length > 0"
  43. />
  44. </n-gi>
  45. </template>
  46. </n-grid>
  47. <empty :show="exhibitionList.length === 0" :height="500" />
  48. </n-tab-pane>
  49. <n-tab-pane
  50. name="topic"
  51. tab="专题展览"
  52. v-infinite-scroll="onLoadMore"
  53. >
  54. <n-grid :x-gap="XGap" :y-gap="YGap" :cols="1" class="tab-grid">
  55. <template v-for="item in exhibitionList">
  56. <n-gi>
  57. <exhibition-box
  58. :id="item.id"
  59. :title="item.name"
  60. :cover="domain + item.thumb"
  61. :content="item.richText"
  62. :location="item.address"
  63. :type="item.type"
  64. :isHasVR="item.link.length > 0"
  65. />
  66. </n-gi>
  67. </template>
  68. </n-grid>
  69. <empty :show="exhibitionList.length === 0" :height="500" />
  70. </n-tab-pane>
  71. <n-tab-pane name="temp" tab="临时展览" v-infinite-scroll="onLoadMore">
  72. <n-grid :y-gap="YGap" :cols="1" class="tab-grid">
  73. <template v-for="item in exhibitionList">
  74. <n-gi>
  75. <exhibition-box
  76. :id="item.id"
  77. :title="item.name"
  78. :cover="domain + item.thumb"
  79. :content="item.richText"
  80. :location="item.address"
  81. :type="item.type"
  82. :isHasVR="item.link.length > 0"
  83. />
  84. </n-gi>
  85. </template>
  86. </n-grid>
  87. <empty :show="exhibitionList.length === 0" :height="500" />
  88. </n-tab-pane>
  89. </n-tabs>
  90. </div>
  91. <side-menu />
  92. </div>
  93. </div>
  94. </template>
  95. <script setup>
  96. import { computed, watch } from "vue";
  97. import { vInfiniteScroll } from "@vueuse/components";
  98. import { useThrottleFn } from "@vueuse/core";
  99. import subHeader from "../components/subHeader";
  100. import sideMenu from "../components/sideMenu";
  101. import exhibitionBox from "../components/exhibitionBox";
  102. import { useExhibitionStore } from "../store/exhibition";
  103. import empty from "../components/empty.vue";
  104. const loadingBar = useLoadingBar();
  105. const exhibitionStore = useExhibitionStore();
  106. const domain = ref(import.meta.env.VITE_DOMAIN_URL);
  107. const exhibitionList = computed(() => exhibitionStore.lists);
  108. const XGap = ref(50);
  109. const YGap = ref(50);
  110. const currentTab = ref("all");
  111. watch(
  112. currentTab,
  113. async (val) => {
  114. console.log("val", val);
  115. loadingBar.start();
  116. await exhibitionStore.getExhibitionList(1, val);
  117. loadingBar.finish();
  118. },
  119. {
  120. immediate: true,
  121. }
  122. );
  123. const onLoadMore = useThrottleFn(async () => {
  124. if (exhibitionStore.isLoad) {
  125. console.log("canLoadMore", exhibitionStore.canLoadMore);
  126. exhibitionStore.canLoadMore && loadingBar.start();
  127. await exhibitionStore.loadMore(currentTab.value);
  128. loadingBar.finish();
  129. }
  130. }, 1000);
  131. </script>
  132. <style lang="scss" scoped>
  133. :deep(.n-tabs) {
  134. --n-tab-font-size: 1.25rem;
  135. --n-tab-gap: 60px;
  136. height: 100%;
  137. overflow: hidden;
  138. .n-tab-pane {
  139. overflow-y: scroll;
  140. }
  141. .n-tabs-bar {
  142. height: 0.25rem;
  143. border-radius: 1.875rem !important;
  144. }
  145. }
  146. </style>