From 9d7de030d38f8d71fdf54ddfe26e46e71f17e9c0 Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Sat, 20 Sep 2025 15:21:43 +0800
Subject: [PATCH] 1
---
src/views/home/components/HomeLtl.vue | 51 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/src/views/home/components/HomeLtl.vue b/src/views/home/components/HomeLtl.vue
index 77f09ed..4837761 100644
--- a/src/views/home/components/HomeLtl.vue
+++ b/src/views/home/components/HomeLtl.vue
@@ -3,7 +3,9 @@
<div class="tabs_box">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="United States" name="US"></el-tab-pane>
- <el-tab-pane label="Mexico" name="MEX"></el-tab-pane>
+ <el-tab-pane label="Hong Kong" name="HK"></el-tab-pane>
+ <el-tab-pane label="Taiwan" name="TW"></el-tab-pane>
+ <el-tab-pane label="India" name="IN"></el-tab-pane>
</el-tabs>
</div>
@@ -24,9 +26,9 @@
<div class="resoult_list">
<el-table
+ height="100%"
:data="tableData"
style="width: 100%"
- height="100%"
size="small"
empty-text="No Data"
@row-click="Choice"
@@ -34,19 +36,11 @@
<el-table-column prop="spell" :label="$t('hj313')">
<template slot-scope="scope">
<el-tag
- v-if="scope.row.stock_type == 'MEX'"
+ :type="scope.row.stock_type != $mc ? 'success' : ''"
size="small"
style="margin-right: 8px"
>
- MEX
- </el-tag>
- <el-tag
- type="success"
- size="small"
- style="margin-right: 8px"
- v-else-if="scope.row.stock_type == 'US'"
- >
- US
+ {{ scope.row.stock_type }}
</el-tag>
<span>{{ scope.row.spell }}</span>
</template>
@@ -108,7 +102,31 @@
this.opt.stockType = this.activeName; // 赋值类型
this.apiInterface = api.getStockByType; // 赋值接口
this.init(); // 获取记录列表
- this.initWebSocket(); // 连接ws实时监控变动
+ // this.initWebSocket(); // 连接ws实时监控变动
+ },
+ watch: {
+ activeName: {
+ handler(val) {
+ // 根据当前股票类型连接对应的ws
+ if (val == "US")
+ this.initWebSocket("wss://ws.isusstock.com/websocket-server");
+ else this.initWebSocket("wss://ws.acapl.net/websocket-server");
+ },
+ immediate: true,
+ deep: true,
+ },
+ },
+ computed: {
+ },
+ props: {
+ },
+ components: {},
+ mounted() {},
+ beforeDestroy() {
+ if (this.Trade) {
+ this.Trade.close();
+ console.log("WebSocket disconnected");
+ }
},
methods: {
handleClick() {
@@ -124,10 +142,13 @@
this.$emit("choice", val.code);
},
// 连接ws实时监控变动
- initWebSocket() {
+ initWebSocket(url) {
console.log("initWebSocket");
+ if (this.Trade) {
+ this.Trade.close();
+ }
this.Trade = new WhrWebSocket({
- path: `wss://ws.kuspitai.com/websocket-server `,
+ path: url,
onmessage: this.getTradeMessage,
});
--
Gitblit v1.9.3