页眉文字+自动打开

This commit is contained in:
熊猫 2024-02-18 09:09:09 +08:00
parent bb7cc85792
commit 6aa352cc47
4 changed files with 58 additions and 2 deletions

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<title>瑞鞍星医疗科技</title>
</head>
<body>
<div id="app"></div>

View File

@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
"serve": "vite",
"serve": "vite --open",
"build": "run-p type-check build-only",
"preview": "vite preview",
"build-only": "vite build",

46
src/axios/ws.ts Normal file
View File

@ -0,0 +1,46 @@
let ws: WebSocket;
function init(url: string | URL, protocols?: string | string[]) {
return new Promise(resolve => {
try {
ws = new WebSocket(url);
resolve(true)
} catch (e) {
console.log(e)
}
})
}
function close(code?: number, reason?: string) {
ws.close(code, reason)
}
function send(data: string | ArrayBufferLike | Blob | ArrayBufferView) {
ws.send(data)
}
function closeListener(cb: any) {
ws.onclose = cb
}
function openListener(cb: any) {
ws.onopen = cb
}
function errorListener(cb: any) {
ws.onerror = cb
}
function messageListener(cb: any) {
ws.onmessage = cb
}
export const wsApi= {
init,
close,
send,
closeListener,
openListener,
errorListener,
messageListener
}

View File

@ -65,6 +65,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import { useLoginStore } from '@/stores/user-info-store'
import { getHospitalsData } from '@/static-data/core'
import userInfoForm from '@/components/user-info.vue'
import {wsApi} from "@/axios/ws";
const router = useRouter()
const route = useRoute()
@ -161,6 +162,15 @@ const userCommand = (e: string) => {
break;
}
}
/*wsApi.init("").then(() => {
wsApi.openListener(fn1);
})
function fn1(res:any) {
console.log(res);
}*/
</script>
<style lang='scss' scoped>