远程管理接口调试

This commit is contained in:
zhaoyz 2024-03-16 12:00:13 +08:00
parent c962e9f5fe
commit 9186e1a01b
5 changed files with 881 additions and 785 deletions

View File

@ -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",

View File

@ -377,7 +377,6 @@ function sliderSuccess() {
// token
Session.set('token', data.access_token);
Session.set('refresh_token', data.refresh_token);
console.log(data);
toHome()
})
}

File diff suppressed because it is too large Load Diff

View File

@ -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");
}
</script>
<style lang='scss' scoped>

View File

@ -27,7 +27,13 @@ export default defineConfig({
ws: true, // 是否启用 WebSocket
changeOrigin: true, // 是否修改请求头中的 Origin 字段
rewrite: (path) => path.replace(/^\/api/, ''),
}
},
'/socket.io': {
target: 'ws://localhost:9999',
ws: true,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/socket.io/, ''),
},
}
}
})