diff --git a/package.json b/package.json index 17b02ff..de20c7c 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "type-check": "vue-tsc --noEmit" }, "dependencies": { + "@stomp/stompjs": "^7.0.0", "axios": "^1.3.3", + "crypto-js": "4.2.0", "echarts": "^5.4.1", "element-plus": "2.3.1", "js-cookie": "^3.0.5", @@ -20,8 +22,7 @@ "vant": "^4.8.3", "vue": "^3.2.45", "vue-router": "^4.1.6", - "xlsx": "^0.18.5", - "crypto-js": "4.2.0" + "xlsx": "^0.18.5" }, "devDependencies": { "@types/js-cookie": "^3.0.6", diff --git a/src/views/login/login.vue b/src/views/login/login.vue index baeca9f..ff60821 100644 --- a/src/views/login/login.vue +++ b/src/views/login/login.vue @@ -377,7 +377,6 @@ function sliderSuccess() { // 存储token 信息 Session.set('token', data.access_token); Session.set('refresh_token', data.refresh_token); - console.log(data); toHome() }) } diff --git a/src/views/remote-manage/remote-control.vue b/src/views/remote-manage/remote-control.vue index 1c8e258..ad473b1 100644 --- a/src/views/remote-manage/remote-control.vue +++ b/src/views/remote-manage/remote-control.vue @@ -1,142 +1,156 @@ - - - - {{ useRemoteStore().getCurrentRemote().title }} - - - - + + + + {{ useRemoteStore().getCurrentRemote().title }} + + + + - - - - - - - - + + + + + + + + - - - {{ isStart ? '终止' : '开始' - }} - - AI给药 - 人工给药 - - - - - - - - - - 患者信息 - 已连接 - 机器人运行正常 - - - - 返回 - - - - 异常信息 - - {{ item }} - - - - - - - - - - - - - - - - - - - - - {{ item.msg }} - - - - - 发送消息 - - - - - - - - - - - — - - - - - - - - - - - - 确定 - 取消 - - - - - - - + + + {{ + isStart ? '终止' : '开始' + }} + + + AI给药 + 人工给药 + + + + + + + + + + + 患者信息 + 已连接 + 机器人运行正常 + + + + + + 返回 + + + + + 异常信息 + + {{ item }} + + + + + + + + + + + + + + + + + + + + + {{ item.msg }} + + + + + 发送消息 + + + + + + + + + + + — + + + + + + + + + + + + + + + + 确定 + + 取消 + + + + + + + + - - - - - + + + + + 取消 确定 - - - - + + + + + + diff --git a/src/views/remote-manage/remote-manage.vue b/src/views/remote-manage/remote-manage.vue index 6c5ec35..ceaccad 100644 --- a/src/views/remote-manage/remote-manage.vue +++ b/src/views/remote-manage/remote-manage.vue @@ -33,6 +33,8 @@ import type { RemoteItem } from '@/utils/public-interface' import RemoteDialog from './part/remote-dialog.vue' import RemotePart from './part/remote-part.vue' import MessagePart from './part/message-part.vue' +import {Client} from "@stomp/stompjs"; +import {Session} from "@/utils/storage"; const router = useRouter() const remoteStore = useRemoteStore() @@ -118,6 +120,8 @@ const confirmRemote = (e: RemoteItem) => { }, e.index) remoteTask.value[e.index] = e // 状态设置为可连接 remotePartRef.value.initData(e) + console.log(e); + getSurgeryData(e.patientCode, e.patientName); } // 连接失败 const errorRemote = (e: RemoteItem) => { @@ -140,6 +144,43 @@ const breakRemote = (e: RemoteItem) => { const addLogAfter = () => { messagePartRef.value.scrollToBottom() } + +const surgeryClient = new Client({ + brokerURL: 'ws://localhost:5173/socket.io/admin/rax/SurgeryData', + connectHeaders: { + access_token: Session.get('token') + } +}) +surgeryClient.activate() + +surgeryClient.onWebSocketError = (error) => { + console.log('Error with websocket', error) +}; + +surgeryClient.onStompError = (frame) => { + console.log('Broker reported error: ' + frame.headers['message']) + console.log('Additional details: ' + frame.body) +}; + +function getSurgeryData(username: string, db: string) { + console.log(username, db); + surgeryClient.publish({ + destination: "/front/getSurgeryData", + body: JSON.stringify({'status': "start", db}) + }); + const account = "admin"; + surgeryClient.subscribe('/topic/user/' + account + ":" + db + '/surgeryData', (data: any) => { + console.log(data); + }) +} + +function disconnectSurgeryData(username: string, db: string) { + surgeryClient.publish({ + destination: "/front/getSurgeryData", + body: JSON.stringify({'status': "stop", db, username}) + }); + surgeryClient.unsubscribe("/topic/user/" + username + "/surgeryData"); +}