Browse Source

perf: update等于0的时候不刷新页面

曾坤森 3 months ago
parent
commit
a2188a0224
2 changed files with 11 additions and 4 deletions
  1. BIN
      dist.zip
  2. 11 4
      src/views/dashboard/record-list/index.vue

BIN
dist.zip


+ 11 - 4
src/views/dashboard/record-list/index.vue

@@ -54,7 +54,7 @@
 </template>
 
 <script lang="ts" name="RecordListPage" setup>
-import { computed, ref, reactive, watch, nextTick } from 'vue';
+import { computed, ref, reactive, watch, nextTick, shallowRef } from 'vue';
 import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
 import { useI18n } from 'vue-i18n';
 import useLoading from '@/hooks/loading';
@@ -71,7 +71,7 @@ interface FaceParams {
 }
 type SizeProps = 'mini' | 'small' | 'medium' | 'large';
 type Column = TableColumnData & { checked?: true };
-
+const isFirst = shallowRef<boolean>(true);
 const { loading, setLoading } = useLoading(true);
 const { t } = useI18n();
 const renderData = ref<DataList[]>([]);
@@ -151,9 +151,11 @@ const fetchData = async () => {
   setLoading(true);
   try {
     queryRecordList(formModel.value).then(res => {
-      renderData.value = res.data;
+      if (res.update === 1 || isFirst.value) {
+        renderData.value = res.data;
+      }
+      isFirst.value = false;
       pagination.current = formModel.value.pageIndex;
-      pagination.pageSize = pagination.pageSize;
       pagination.total = res.total;
     });
   } catch (err) {
@@ -170,6 +172,11 @@ const { pause, resume, isActive } = useIntervalFn(() => {
 }, 1000);
 const onPageChange = (current: number) => {
   formModel.value.pageIndex = current;
+  if (current === 1) {
+    resume();
+  } else {
+    pause();
+  }
   fetchData();
 };
 const downloadExcel = () => {