From 0d7c0aa6baba05bfeefd7dd7f37e63a9752caf90 Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Mon, 30 Jun 2025 19:32:24 +0800
Subject: [PATCH] 当前持仓添加轮询
---
src/page/perpetualContract/perpetualHistory.vue | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/page/perpetualContract/perpetualHistory.vue b/src/page/perpetualContract/perpetualHistory.vue
index f5491fb..d98927d 100644
--- a/src/page/perpetualContract/perpetualHistory.vue
+++ b/src/page/perpetualContract/perpetualHistory.vue
@@ -134,11 +134,24 @@
loading: false,
finished: false,
page: 1,
+ pollTimer: null,
};
},
mounted() {
this.getCoins();
// this.symbol = this.$route.query.symbol;
+ },
+ watch: {
+ type(newVal) {
+ if (newVal === "position") {
+ this.startPolling();
+ } else {
+ this.stopPolling();
+ }
+ },
+ },
+ beforeDestroy() {
+ this.stopPolling();
},
methods: {
getCoins() {
@@ -160,6 +173,18 @@
onClickLeft() {
this.$router.go(-1);
},
+ startPolling() {
+ if (this.pollTimer) return;
+ this.pollTimer = setInterval(() => {
+ this.fetchList(); // 你的轮询方法
+ }, 1500); // 3秒轮询一次,可根据需要调整
+ },
+ stopPolling() {
+ if (this.pollTimer) {
+ clearInterval(this.pollTimer);
+ this.pollTimer = null;
+ }
+ },
async fetchList(symbol) {
if (this.type === "position") {
_orderListHold().then((data) => {
--
Gitblit v1.9.3