Bläddra i källkod

fix: 搜索重复数据

chenlei 11 månader sedan
förälder
incheckning
08e53849d2
4 ändrade filer med 24 tillägg och 27 borttagningar
  1. 0 13
      src/assets/css/base.css
  2. 3 1
      src/views/Collections/index.vue
  3. 0 1
      src/views/Events/detail.scss
  4. 21 12
      src/views/Search/index.vue

+ 0 - 13
src/assets/css/base.css

@@ -112,19 +112,6 @@ ul {
   list-style: none;
 }
 
-blockquote,
-q {
-  quotes: none;
-}
-
-blockquote:before,
-blockquote:after,
-q:before,
-q:after {
-  content: "";
-  content: none;
-}
-
 table {
   border-collapse: collapse;
   border-spacing: 0;

+ 3 - 1
src/views/Collections/index.vue

@@ -179,7 +179,9 @@ watch(sourceList, async (v) => {
       });
     }
   } finally {
-    rendering.value = false;
+    setTimeout(() => {
+      rendering.value = false;
+    }, 500);
   }
 });
 

+ 0 - 1
src/views/Events/detail.scss

@@ -67,7 +67,6 @@
     padding: 40px 30px;
     font-family: arial, helvetica, sans-serif;
     font-size: 16px;
-    line-height: 2em;
     text-align: justify;
     background: var(--white-bg);
     box-shadow: 0 5px 5px rgba(0, 0, 0, 0.5);

+ 21 - 12
src/views/Search/index.vue

@@ -27,7 +27,7 @@
         aria-label="Link"
         aria-description="All Results"
         :class="{ active: activeTabbar === -1 }"
-        @click="activeTabbar = -1"
+        @click="handleActiveTab(-1)"
       >
         <p>All Results</p>
         <p>({{ resultTotal }})</p>
@@ -39,7 +39,7 @@
         aria-label="Link"
         :aria-description="item.name"
         :class="{ active: idx === activeTabbar }"
-        @click="activeTabbar = idx"
+        @click="handleActiveTab(idx)"
       >
         <p>{{ item.name }}</p>
         <p>({{ item.total }})</p>
@@ -65,7 +65,7 @@
     <ul class="search-page-list">
       <li
         v-for="item in list"
-        :key="item.name"
+        :key="item.id ? item.module + item.id : item.name"
         class="search-page-item"
         :class="{
           'no-rtf': !item.rtf,
@@ -91,11 +91,8 @@
       </li>
     </ul>
 
-    <div v-if="list.length >= PAGE_SIZE" class="search-page__pagination">
-      <Pagination
-        :total="activeTabbar === -1 ? resultTotal : tabbar[activeTabbar].total"
-        @change="handlePage"
-      />
+    <div v-if="total >= PAGE_SIZE" class="search-page__pagination">
+      <Pagination :total="total" :page-size="PAGE_SIZE" @change="handlePage" />
     </div>
   </div>
 
@@ -213,10 +210,12 @@ const getList = async () => {
         return false;
 
       return true;
-    }).map((i) => ({
-      ...i,
-      rtf: getAbstract(i.rtf),
-    }));
+    })
+      .splice(pageNum.value === 1 ? 0 : pageNum.value * PAGE_SIZE, PAGE_SIZE)
+      .map((i) => ({
+        ...i,
+        rtf: getAbstract(i.rtf),
+      }));
 
     const BACKEND_MODULE_INDEX = [-1, 1, 2, 3, 4, 7];
     const data = await searchApi({
@@ -261,6 +260,11 @@ const getList = async () => {
     loading.value = false;
   }
 };
+const total = computed(() =>
+  activeTabbar.value === -1
+    ? resultTotal.value
+    : tabbar.value[activeTabbar.value].total
+);
 
 watch(
   route,
@@ -354,6 +358,11 @@ const handleClick = (item: SearchItem) => {
       break;
   }
 };
+
+const handleActiveTab = (idx: number) => {
+  pageNum.value = 1;
+  activeTabbar.value = idx;
+};
 </script>
 
 <style lang="scss" scoped>