From c72b11fd813d6122d400e370dd9cb8bb85eb6259 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 20 Dec 2023 13:57:39 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=80=9A=E4=BF=A1=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=96=AD=E5=BC=80=E4=BD=8D=E7=BD=AE=E8=B0=83=E6=95=B4=EF=BC=9B?= =?UTF-8?q?=E7=BA=BF=E8=B7=AF=E5=88=9D=E5=A7=8B=E5=8C=96=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=88=97=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/AlertMock.ts | 8 ++++++++ src/css/app.scss | 3 +++ src/drawApp/lineApp.ts | 3 ++- src/drawApp/lineNetApp.ts | 3 ++- src/layouts/MainLayout.vue | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/api/AlertMock.ts b/src/api/AlertMock.ts index 8dca82a..9e31f90 100644 --- a/src/api/AlertMock.ts +++ b/src/api/AlertMock.ts @@ -130,3 +130,11 @@ export async function recordAlarmReport( const response = await api.post(`/api/alertRecord/report/${lineId}`, data); return response.data; } + +/** + * 初始化 + * @param linId 线路的id + */ +export function resetApi(linId: number): Promise { + return api.get(`${alertUriBase}/reset/${linId}`); +} diff --git a/src/css/app.scss b/src/css/app.scss index ecac98f..2157cc3 100644 --- a/src/css/app.scss +++ b/src/css/app.scss @@ -1 +1,4 @@ // app global css in SCSS form +.my-notif-class { + margin-top: 50px; +} diff --git a/src/drawApp/lineApp.ts b/src/drawApp/lineApp.ts index 90aa484..4202d02 100644 --- a/src/drawApp/lineApp.ts +++ b/src/drawApp/lineApp.ts @@ -143,7 +143,8 @@ export function initLineApp(): IGraphicApp { type: 'negative', timeout: 0, position: 'top-right', - message: '通信链接已断开!', + message: '与WebSocket服务连接断开!', + classes: 'my-notif-class', }); } else if (msgNotify && connected) { msgNotify(); diff --git a/src/drawApp/lineNetApp.ts b/src/drawApp/lineNetApp.ts index fb6f1ae..1f00a57 100644 --- a/src/drawApp/lineNetApp.ts +++ b/src/drawApp/lineNetApp.ts @@ -91,7 +91,8 @@ export function initLineNetApp(): IGraphicApp { type: 'negative', timeout: 0, position: 'top-right', - message: '通信链接已断开!', + message: '与WebSocket服务连接断开!', + classes: 'my-notif-class', }); } else if (msgNotify && connected) { msgNotify(); diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 3ef22a0..2dd13f7 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -30,6 +30,13 @@ class="q-mr-sm" @click="openSetAlarmTextDialog" /> +
{ + console.log('初始化', lineStore.lineId); + lineStore.lineId && + resetApi(lineStore.lineId) + .then(() => { + const app = lineStore.getLineApp(); + const trainList = app.queryStore.queryByType(Train.Type); + trainList.forEach((g) => { + app.deleteGraphics(g); + }); + }) + .catch((err) => { + errorNotify('初始化删除!', err); + }); + }); +} From 232536ae34b6dc1fef311b67cb08f02520bc26e8 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 20 Dec 2023 15:51:08 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/MainLayout.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 2dd13f7..f3f72ba 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -189,7 +189,6 @@ function resetFn() { cancel: true, persistent: true, }).onOk(() => { - console.log('初始化', lineStore.lineId); lineStore.lineId && resetApi(lineStore.lineId) .then(() => { @@ -200,7 +199,7 @@ function resetFn() { }); }) .catch((err) => { - errorNotify('初始化删除!', err); + errorNotify('初始化失败!', err); }); }); } From 9edc6971caabb8f5c48d2285a5aa906848d2037f Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 20 Dec 2023 16:23:17 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=B8=8E=E5=8D=A1=E6=96=AF=E6=9F=AF?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E7=8A=B6=E6=80=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ConnectInfoDialog.vue | 80 ++++++++++++ src/components/webSocketConnect.ts | 34 +++++ src/layouts/MainLayout.vue | 44 ++++++- src/pages/AlarmInfoList.vue | 31 +---- src/protos/device_info.ts | 62 ++++----- src/protos/system_warn_message.ts | 188 +++++++++++++++++++++++++++ src/stores/line-net-store.ts | 22 ++++ 7 files changed, 402 insertions(+), 59 deletions(-) create mode 100644 src/components/ConnectInfoDialog.vue create mode 100644 src/components/webSocketConnect.ts create mode 100644 src/protos/system_warn_message.ts diff --git a/src/components/ConnectInfoDialog.vue b/src/components/ConnectInfoDialog.vue new file mode 100644 index 0000000..3733ff2 --- /dev/null +++ b/src/components/ConnectInfoDialog.vue @@ -0,0 +1,80 @@ + + + diff --git a/src/components/webSocketConnect.ts b/src/components/webSocketConnect.ts new file mode 100644 index 0000000..c4881f6 --- /dev/null +++ b/src/components/webSocketConnect.ts @@ -0,0 +1,34 @@ +import { HandleMessage, StompMessagingClient } from 'jl-graphic'; +import { getJwtToken } from 'src/configs/TokenManage'; +import { getWebsocketUrl } from 'src/configs/UrlManage'; + +export function webSocketConnect( + socket: StompMessagingClient | null, + destination: string, + handler: HandleMessage +) { + socket = new StompMessagingClient({ + wsUrl: `${getWebsocketUrl()}`, + token: getJwtToken() as string, + protocol: 'protobuf', + connectTimeout: 30 * 1000, + heartbeat: 60, + retryPeriod: 2 * 1000, + retryTimes: 100, + }); + socket.on('connected', () => { + socket?.subscribe(destination, handler); + }); + socket.on('disconnected', () => { + console.log(6666); + }); +} + +export function closeWebSocketConnect( + socket: StompMessagingClient | null, + destination: string +) { + socket?.unsubscribe0(destination); + socket?.close(); + socket = null; +} diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index f3f72ba..058dea0 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -55,6 +55,14 @@ v-if="$q.screen.gt.sm" > +