-
-
-
{{$t("backendSystem.publishedBroadcast")}}
-
{{$t("backendSystem.addBroadcast")}}
-
-
-
-
-
-
-
- {{ handelTime(scope.row.createTime) }}
-
-
-
-
-
-
- {{ handelTime(scope.row.updateTime) }}
-
-
-
-
-
-
-
- {{$t("backendSystem.edit")}}
-
-
-
- {{ $t(`personal.delete`) }}
-
-
-
-
-
-
-
-
-
-
- handleInput(val, 'add')" />
-
- {{$t("backendSystem.exceedingInput")}}
- {{$t("backendSystem.newlineInvalid")}}
-
-
-
-
-
-
-
-
-
-
- handleInput(val, 'edit')" />
-
- {{$t("backendSystem.exceedingInput")}}
- {{$t("backendSystem.newlineInvalid")}}
-
-
-
-
-
+
+
+
{{ $t("backendSystem.publishedBroadcast") }}
+
{{ $t("backendSystem.addBroadcast") }}
+
-
+
+
+
+
+
+ {{ handelTime(scope.row.createTime) }}
+
+
+
+
+
+
+ {{ handelTime(scope.row.updateTime) }}
+
+
+
+
+
+
+ {{
+ $t("backendSystem.edit")
+ }}
+
+
+ {{
+ $t(`personal.delete`)
+ }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ handleInput(val, 'add')"
+ />
+
+
+ {{ $t("backendSystem.exceedingInput") }}
+ {{ $t("backendSystem.newlineInvalid") }}
+
+
+
+
+
+
+
+
+
+ handleInput(val, 'edit')"
+ />
+
+
+ {{ $t("backendSystem.exceedingInput") }}
+ {{ $t("backendSystem.newlineInvalid") }}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mining-pool/src/views/customerService/index.vue b/mining-pool/src/views/customerService/index.vue
index 1627b82..a17e132 100644
--- a/mining-pool/src/views/customerService/index.vue
+++ b/mining-pool/src/views/customerService/index.vue
@@ -433,7 +433,7 @@ export default {
},
},
- async created() {
+ created() {
try {
let userEmail = localStorage.getItem("userEmail");
this.userEmail = JSON.parse(userEmail);
@@ -443,11 +443,11 @@ export default {
});
// 获取聊天室列表
- await this.fetchRoomList();
+ this.fetchRoomList();
// 在组件创建时加载手动创建的聊天室
this.loadManualCreatedRooms();
- console.log(this.userEmail, "初始化的时候");
+ console.log("mounted userEmail=", userEmail, "parsed=", this.userEmail);
// 初始化 WebSocket 连接
this.initWebSocket();
} catch (error) {
@@ -455,6 +455,8 @@ export default {
}
},
async mounted() {
+
+
// 获取聊天室列表
await this.fetchRoomList();
@@ -577,6 +579,9 @@ export default {
return;
}
+ console.log("走这里了嘛 家电节爱哦都觉得久啊是哦大点击");
+
+
// 防止重复初始化
if (this.stompClient && this.stompClient.state !== "DISCONNECTED") {
console.log("WebSocket正在连接中,跳过初始化");
@@ -588,15 +593,9 @@ export default {
if (this.stompClient) {
this.forceDisconnectAll();
}
- let apiUrl = process.env.VUE_APP_BASE_API;
- let baseUrl=""
- // 将 https 替换为 wss
- if (apiUrl.startsWith("https://")) {
- baseUrl= apiUrl.replace("https://", "wss://");
- }
- if (apiUrl.startsWith("http://")) {
- baseUrl=apiUrl.replace("http://", "ws://");
- }
+
+ console.log("开始初始化WebSocket连接...");
+ const baseUrl = process.env.VUE_APP_BASE_API.replace("https", "wss");
const wsUrl = `${baseUrl}chat/ws`;
this.stompClient = Stomp.client(wsUrl);
@@ -650,11 +649,12 @@ export default {
this.subscribeToMessages();
this.updateLastActivityTime();
- // === 启动心跳检测 ===
- this.startHeartbeat();
-
- // === 启动连接状态检查 ===
- this.startConnectionCheck();
+ // === 暂时禁用心跳和连接检查,避免误判 ===
+ // this.startHeartbeat();
+ // this.startConnectionCheck();
+
+ // 只依赖 STOMP 内置心跳和订阅成功状态
+ console.log("✅ 连接成功,只使用 STOMP 内置心跳机制");
// === 注意:不在这里启动验证,而是在订阅成功后 ===
console.log("⚡ 客服连接成功,等待订阅完成后验证");
@@ -715,11 +715,10 @@ export default {
console.log("📢 客服订阅成功,立即标记连接已验证");
this.markConnectionVerified();
- // 确保连接状态正确
- if (this.connectionStatus !== "connected") {
- console.log("📡 修正客服连接状态为connected");
- this.connectionStatus = "connected";
- }
+ // 强制确保连接状态正确
+ this.isWebSocketConnected = true;
+ this.connectionStatus = "connected";
+ console.log("✅ 强制设置连接状态为已连接");
} else {
console.error("❌ 客服订阅失败,返回空subscription");
// 如果订阅失败,启动验证机制等待超时重连
@@ -1734,6 +1733,10 @@ export default {
this.markConnectionVerified();
this.updateLastActivityTime(); // 收到消息也是一种活动
this.lastHeartbeatTime = Date.now(); // 更新心跳时间
+
+ // 强制确保连接状态正确(收到消息说明连接肯定是好的)
+ this.isWebSocketConnected = true;
+ this.connectionStatus = "connected";
const msg = JSON.parse(message.body);
console.log("客服收到的消息", msg);
@@ -3665,14 +3668,45 @@ export default {
localStorage.setItem(key, String(count));
},
/**
- * 监听storage事件,实现多窗口未读同步
+ * 监听storage事件,实现多窗口未读同步和登录状态同步
*/
handleStorageChange(e) {
+ // 监听未读消息同步
if (e.key && e.key.startsWith("cs_unread_")) {
const roomId = e.key.replace("cs_unread_", "");
const count = parseInt(e.newValue, 10) || 0;
const contact = this.contacts.find((c) => c.roomId == roomId);
if (contact) contact.unread = count;
+ return;
+ }
+
+ // 监听登录状态同步 - 当userEmail被清除时表示用户已退出登录
+ if (e.key === "userEmail" && e.oldValue && (!e.newValue || e.newValue === "null")) {
+ this.handleLogoutSync();
+ }
+ },
+
+ /**
+ * 处理多窗口登录状态同步
+ */
+ handleLogoutSync() {
+ try {
+ // 断开WebSocket连接
+ this.forceDisconnectAll();
+
+ // 清除本地数据
+ this.userEmail = "";
+ this.currentContactId = null;
+ this.contacts = [];
+ this.messages = {};
+ this.inputMessage = "";
+ this.isWebSocketConnected = false;
+ this.connectionStatus = "disconnected";
+
+ // 跳转到首页
+ this.$router.replace("/");
+ } catch (error) {
+ this.$router.replace("/");
}
},
diff --git a/mining-pool/src/views/home/index.js b/mining-pool/src/views/home/index.js
index 27c5830..84551d4 100644
--- a/mining-pool/src/views/home/index.js
+++ b/mining-pool/src/views/home/index.js
@@ -918,7 +918,7 @@ export default {
});
// this.getBroadcastList({pageNum:1,pageSize:100})
- this.getBroadcastList()
+ this.getBroadcastList({lang:this.$i18n.locale})
this.startScroll();
this.$nextTick(() => {
@@ -1732,6 +1732,10 @@ scrollRight() {
if (this.broadcastList.length <= 1) return;
this.scrollTimer = setInterval(this.nextScroll, 3000);
},
+ stopScroll() {
+ if (this.scrollTimer) clearInterval(this.scrollTimer);
+ this.scrollTimer = null;
+ },
nextScroll() {
if (this.broadcastList.length <= 1) return;
this.isTransition = true;
diff --git a/mining-pool/src/views/home/index.vue b/mining-pool/src/views/home/index.vue
index a910326..eefe8be 100644
--- a/mining-pool/src/views/home/index.vue
+++ b/mining-pool/src/views/home/index.vue
@@ -421,7 +421,8 @@