From 02a3d94d359b34e915f34abec024cbc1504a6a7c Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Fri, 18 Apr 2025 11:00:14 +0800
Subject: [PATCH] feat

---
 src/components/commonTrade/kline.vue |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/src/components/commonTrade/kline.vue b/src/components/commonTrade/kline.vue
index fb634fc..b0e7cb9 100644
--- a/src/components/commonTrade/kline.vue
+++ b/src/components/commonTrade/kline.vue
@@ -1,6 +1,7 @@
 <template>
   <div class="kline-page">
     <div
+      v-if="isVisible"
       id="kline-BoxMain"
       :style="{ width: width != 0 ? width + 'px' : '' }"
       :class="[
@@ -132,6 +133,7 @@
   },
   data() {
     return {
+      isVisible: true,
       klineData: null,
       paneId: undefined,
       mssg: "",
@@ -182,9 +184,20 @@
         });
       }
     },
+    "$route.query.timestamp"(newVal, oldVal) {
+      // 当 timestamp 参数变化时执行
+      if (newVal !== oldVal) {
+        this.klineInIt(newVal); // 调用数据更新方法
+      }
+    },
   },
   methods: {
-    klineInIt() {
+    klineInIt(newVal) {
+      if (this.klineData && newVal) {
+        this.klineData = null;
+        this.isVisible = false;
+        this.klineData.remove(); // 销毁旧的图表实例
+      }
       this.klineData = init("kline-BoxMain", {
         locale: langStore.language, //https://klinecharts.com/guide/i18n.html
         styles: {
@@ -263,6 +276,7 @@
           },
         },
       });
+      this.isVisible = true;
 
       this.klineData.createIndicator("MA", false, {
         id: "candle_pane",

--
Gitblit v1.9.3