From 1b8ed300551b88bd86b80b8dfa52d2d6c2b7fdb2 Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Sun, 24 Aug 2025 14:45:52 +0800
Subject: [PATCH] 1
---
src/components/stock-list.vue | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/components/stock-list.vue b/src/components/stock-list.vue
index 54685f0..2a42cf9 100644
--- a/src/components/stock-list.vue
+++ b/src/components/stock-list.vue
@@ -77,7 +77,7 @@
pageNum: 1,
pageSize: 10,
total: 1,
- stockList: [],
+ stockList: []
};
},
props: {
@@ -101,9 +101,16 @@
watch: {
propOption: {
handler(val) {
+ // 根据当前股票类型连接对应的ws
+ if (val.stockType == "US")
+ this.initWebSocket("wss://usws.yanshiz.com/websocket-server");
+ else this.initWebSocket("wss://ws.acapl.net/websocket-server");
+
this.pageNum = 1;
this.getStockList();
- }
+ },
+ deep: true,
+ immediate: true
},
pageNum: {
handler(val) {
@@ -114,7 +121,7 @@
},
mounted() {
this.getStockList();
- this.initWebSocket();
+ // this.initWebSocket();
},
methods: {
// 获取数据
@@ -165,10 +172,13 @@
}
},
// 连接ws实时监控变动
- initWebSocket() {
+ initWebSocket(url) {
console.log("initWebSocket");
+ if (this.Trade) {
+ this.Trade.close();
+ }
this.Trade = new WhrWebSocket({
- path: `wss://ws.acapl.net/websocket-server `,
+ path: url,
onmessage: this.getTradeMessage
});
--
Gitblit v1.9.3