From 801a973801defdf16ab86a667671bc03af6975e2 Mon Sep 17 00:00:00 2001
From: Luyus <2593026969@qq.com>
Date: Wed, 14 Jan 2026 14:48:14 +0800
Subject: [PATCH] fix
---
src/components/trade/trade.vue | 34 ++++++++++++++++---
web/index.html | 2 +-
web/static/js/13.0673978e6ad4850d8a84.js | 2 ++
web/static/js/13.0673978e6ad4850d8a84.js.map | 1 +
web/static/js/13.15924c36aa1a8aecef22.js | 2 --
web/static/js/13.15924c36aa1a8aecef22.js.map | 1 -
...63.js => manifest.481aaeae1b883e5a1167.js} | 4 +--
...p => manifest.481aaeae1b883e5a1167.js.map} | 2 +-
8 files changed, 36 insertions(+), 12 deletions(-)
create mode 100644 web/static/js/13.0673978e6ad4850d8a84.js
create mode 100644 web/static/js/13.0673978e6ad4850d8a84.js.map
delete mode 100644 web/static/js/13.15924c36aa1a8aecef22.js
delete mode 100644 web/static/js/13.15924c36aa1a8aecef22.js.map
rename web/static/js/{manifest.91d8b21da8c741af5c63.js => manifest.481aaeae1b883e5a1167.js} (95%)
rename web/static/js/{manifest.91d8b21da8c741af5c63.js.map => manifest.481aaeae1b883e5a1167.js.map} (96%)
diff --git a/src/components/trade/trade.vue b/src/components/trade/trade.vue
index feeecff..76a79e7 100644
--- a/src/components/trade/trade.vue
+++ b/src/components/trade/trade.vue
@@ -403,7 +403,12 @@
turnoverTbData: [], //成交记录
entrustTbData: [], //委托定单
//深度数据
- depthsData: {},
+ depthsData: {
+ asks: [],
+ bids: [],
+ price: 0,
+ cnyPrice: 0
+ },
domWidth: 0,
asksDepth: 0,
@@ -1027,14 +1032,33 @@
this.$socket.subscribe(`market.${symbol}.depth.${mergeDepth}`, 'market-depth');
this.$socket.on('market-depth', (data) => {
- this.depthsData = data.tick;
- if(kline && kline.contentWindow) {
- kline.contentWindow.set_current_depth(this.depthsData);
+ // 处理双层 JSON 字符串
+ try {
+ if(data.result) {
+ let result = JSON.parse(data.result);
+ if(result.tick) {
+ this.depthsData = JSON.parse(result.tick);
+ }
+ } else if(data.tick) {
+ this.depthsData = typeof data.tick === 'string' ? JSON.parse(data.tick) : data.tick;
+ }
+
+ if(this.depthsData && kline && kline.contentWindow) {
+ kline.contentWindow.set_current_depth(this.depthsData);
+ }
+ if(this.depthsData) {
+ this.processDepthData()
+ }
+ } catch(e) {
+ console.error('解析深度数据失败:', e, data);
}
- this.processDepthData()
})
},
processDepthData(){
+ if(!this.depthsData || !this.depthsData.asks || !this.depthsData.bids) {
+ console.warn('深度数据为空或格式错误', this.depthsData);
+ return;
+ }
let {asks, bids} = this.depthsData;
let {priceScale, buyFeeRate, sellFeeRate,numScale} = this.currentMarket;
if(this.currentBuyItem.price === '' && bids.length > 0 && this.currentBuyItem.canBuyAmount === '') {
diff --git a/web/index.html b/web/index.html
index f3771c5..7b88928 100644
--- a/web/index.html
+++ b/web/index.html
@@ -11,4 +11,4 @@
// hm.src = "https://hm.baidu.com/hm.js?b4837d50cf55e64e8da2130f1ae8e997";
// var s = document.getElementsByTagName("script")[0];
// s.parentNode.insertBefore(hm, s);
-// })();