소스 검색

修改机器人页面定时更新余额

DESKTOP-NE65RNK\Citrus_limon 1 년 전
부모
커밋
45a32ac8c6
2개의 변경된 파일36개의 추가작업 그리고 34개의 파일을 삭제
  1. 18 17
      src/views/bot/as/index.vue
  2. 18 17
      src/views/bot/manage/index.vue

+ 18 - 17
src/views/bot/as/index.vue

@@ -128,7 +128,6 @@
                 @click="handleStatus([row.id], 'RESTART')"
               />
               <TableButton v-if="apiList?.includes('/robot/delete') && ['STOPPED', 'STOP_PENDING', 'ERROR'].includes(row.status)" text="删除" @click="handleDelete(row)" />
-
             </lay-space>
           </template>
         </lay-table>
@@ -170,7 +169,7 @@
 </template>
 
 <script lang="ts" setup name="BotManage">
-import { ref, reactive, getCurrentInstance, onBeforeUnmount } from "vue";
+import { ref, reactive, getCurrentInstance, onActivated, onDeactivated } from "vue";
 import BatchUpdate from "./components/BatchUpdate.vue";
 import Update from "./components/Update.vue";
 import Transfers from "./components/Transfers.vue";
@@ -253,16 +252,17 @@ let selectedKeys = ref([]);
 let collectInfo = ref(`[0/0] 利润:<span class="primary-color">0(0%)</span> 初始:<span class="primary-color">0</span> 现有:<span class="primary-color">0</span>`);
 let userList = ref();
 let exchangeList = ref();
+let refreshAsBotInterval = ref();
 
 // 请求机器人列表
-const getPageInfo = (isSearch?: boolean) => {
+const getPageInfo = (isSearch?: boolean, isRefresh?: boolean) => {
   if (isSearch) {
     pageParams.pageNum = 1;
     selectedKeys.value = [];
   }
-  pageConfig.loading = true;
+  pageConfig.loading = true && !isRefresh;
   get_as_robot_list(pageParams, (data: any) => {
-    pageConfig.loading = false;
+    pageConfig.loading = false && !isRefresh;
     if (data.code == 200) {
       dataSource.value = data.data.list;
       tablePage.total = data.data.total;
@@ -290,16 +290,6 @@ const get_exchange_list = () => {
 };
 get_exchange_list();
 
-let refreshInterval = setInterval(() => {
-  get_as_robot_list(pageParams, (data: any) => {
-    if (data.code == 200) {
-      dataSource.value = data.data.list;
-      tablePage.total = data.data.total;
-      handleShowInfo(data.data);
-    }
-  });
-}, 2000);
-
 const jumpDetail = (info: any) => {
   window.open(`/bot/as/detail/${info.id}`);
 };
@@ -459,9 +449,20 @@ const handleCurrentChange = (val: any) => {
   getPageInfo();
 };
 
-onBeforeUnmount(() => {
+let startInterval = () => {
+  refreshAsBotInterval.value = setInterval(() => {
+    getPageInfo(false, true);
+  }, 2000);
+};
+let closeInterval = () => {
+  clearInterval(refreshAsBotInterval.value);
+};
+onActivated(() => {
+  startInterval();
+});
+onDeactivated(() => {
   document.title = "4L CAPITAL";
-  clearInterval(refreshInterval);
+  closeInterval();
 });
 </script>
 

+ 18 - 17
src/views/bot/manage/index.vue

@@ -171,7 +171,7 @@
 </template>
 
 <script lang="ts" setup name="BotManage">
-import { ref, reactive, getCurrentInstance, onBeforeUnmount } from "vue";
+import { ref, reactive, getCurrentInstance, onActivated, onDeactivated } from "vue";
 import BatchUpdate from "./components/BatchUpdate.vue";
 import Update from "./components/Update.vue";
 import Transfers from "./components/Transfers.vue";
@@ -254,16 +254,16 @@ let selectedKeys = ref([]);
 let collectInfo = ref(`[0/0] 利润:<span class="primary-color">0(0%)</span> 初始:<span class="primary-color">0</span> 现有:<span class="primary-color">0</span>`);
 let userList = ref();
 let exchangeList = ref();
-
+let refreshBotInterval = ref();
 // 请求机器人列表
-const getPageInfo = (isSearch?: boolean) => {
+const getPageInfo = (isSearch?: boolean, isRefresh?: boolean) => {
   if (isSearch) {
     pageParams.pageNum = 1;
     selectedKeys.value = [];
   }
-  pageConfig.loading = true;
+  pageConfig.loading = true && !isRefresh;
   get_robot_list(pageParams, (data: any) => {
-    pageConfig.loading = false;
+    pageConfig.loading = false && !isRefresh;
     if (data.code == 200) {
       dataSource.value = data.data.list;
       tablePage.total = data.data.total;
@@ -291,16 +291,6 @@ const get_exchange_list = () => {
 };
 get_exchange_list();
 
-let refreshInterval = setInterval(() => {
-  get_robot_list(pageParams, (data: any) => {
-    if (data.code == 200) {
-      dataSource.value = data.data.list;
-      tablePage.total = data.data.total;
-      handleShowInfo(data.data);
-    }
-  });
-}, 2000);
-
 const jumpDetail = (info: any) => {
   window.open(`/bot/manage/detail/${info.id}`);
 };
@@ -466,9 +456,20 @@ const handleCurrentChange = (val: any) => {
   getPageInfo();
 };
 
-onBeforeUnmount(() => {
+let startInterval = () => {
+  refreshBotInterval.value = setInterval(() => {
+    getPageInfo(false, true);
+  }, 2000);
+};
+let closeInterval = () => {
+  clearInterval(refreshBotInterval.value);
+};
+onActivated(() => {
+  startInterval();
+});
+onDeactivated(() => {
   document.title = "4L CAPITAL";
-  clearInterval(refreshInterval);
+  closeInterval();
 });
 </script>