From 42e6c7b6003501580586423c35e89c446ac5a73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Thu, 23 Nov 2023 18:55:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20websocket=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/application/websocketConfig.py | 2 +- web/src/App.vue | 14 +++-- web/src/i18n/lang/zh-cn.ts | 4 +- web/src/i18n/lang/zh-tw.ts | 2 +- web/src/layout/navBars/breadcrumb/user.vue | 69 +++++++++++++++++++++- web/src/layout/upgrade/index.vue | 2 +- web/src/stores/interface/index.ts | 1 + web/src/stores/userInfo.ts | 4 ++ web/src/utils/websocket.ts | 20 +++++-- 9 files changed, 100 insertions(+), 18 deletions(-) diff --git a/backend/application/websocketConfig.py b/backend/application/websocketConfig.py index c36d97a..ab2cd64 100644 --- a/backend/application/websocketConfig.py +++ b/backend/application/websocketConfig.py @@ -73,7 +73,7 @@ class DvadminWebSocket(AsyncJsonWebsocketConsumer): unread_count = await _get_message_unread(self.user_id) if unread_count == 0: # 发送连接成功 - await self.send_json(set_message('system', 'SYSTEM', '连接成功')) + await self.send_json(set_message('system', 'SYSTEM', '您已上线')) else: await self.send_json( set_message('system', 'SYSTEM', "请查看您的未读消息~", diff --git a/web/src/App.vue b/web/src/App.vue index ec824fa..caa36ca 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -59,12 +59,6 @@ onBeforeMount(() => { setIntroduction.cssCdn(); // 设置批量第三方 js setIntroduction.jsCdn(); - //websockt 模块 - try { - //websocket.init(wsReceive) - } catch (e) { - console.log('websocket错误'); - } }); // 页面加载时 onMounted(() => { @@ -93,6 +87,14 @@ watch( () => route.path, () => { other.useTitle(); + if (!websocket.websocket) { + //websockt 模块 + try { + websocket.init(wsReceive) + } catch (e) { + console.log('websocket错误'); + } + } }, { deep: true, diff --git a/web/src/i18n/lang/zh-cn.ts b/web/src/i18n/lang/zh-cn.ts index 6fc6ef3..6289a39 100644 --- a/web/src/i18n/lang/zh-cn.ts +++ b/web/src/i18n/lang/zh-cn.ts @@ -40,6 +40,8 @@ export default { title4: '消息', title5: '开全屏', title6: '关全屏', + retry: '重试上线', + onlinePrompt: '当前离线状态,是否重试上线?', dropdownLarge: '大型', dropdownDefault: '默认', dropdownSmall: '小型', @@ -75,7 +77,7 @@ export default { }, noAccess: { accessTitle: '您未被授权,没有操作权限~', - accessMsg: '联系方式:加QQ群探讨 665452019', + accessMsg: '请联系管理员', accessBtn: '重新授权', }, layout: { diff --git a/web/src/i18n/lang/zh-tw.ts b/web/src/i18n/lang/zh-tw.ts index 35e406f..ea00164 100644 --- a/web/src/i18n/lang/zh-tw.ts +++ b/web/src/i18n/lang/zh-tw.ts @@ -123,7 +123,7 @@ export default { }, noAccess: { accessTitle: '您未被授權,沒有操作許可權~', - accessMsg: '聯繫方式:加QQ群探討665452019', + accessMsg: '請聯系管理員', accessBtn: '重新授權', }, layout: { diff --git a/web/src/layout/navBars/breadcrumb/user.vue b/web/src/layout/navBars/breadcrumb/user.vue index f4cf706..620a076 100644 --- a/web/src/layout/navBars/breadcrumb/user.vue +++ b/web/src/layout/navBars/breadcrumb/user.vue @@ -57,9 +57,33 @@ :class="!state.isScreenfull ? 'icon-fullscreen' : 'icon-tuichuquanping'" > +