合并代码

This commit is contained in:
X1627315083
2024-08-19 10:36:46 +08:00
parent a8ab30f30c
commit e4b3ebe88b
30 changed files with 857 additions and 472 deletions

View File

@@ -1,11 +1,27 @@
import MyEvent from "@/tool/myEvents";
class MyWs {
constructor() {
this.ws = null;
// this.ws = new WebSocket();
let http = process.env.VUE_APP_BASE_URL.replace(/^https?:\/\//, '')
this.messageUrl = http+'/notification'
}
linkWs(url) {
console.log(this.ws && this.ws.readyState == 1);
if (this.ws && this.ws.readyState == 1) return
this.ws = new WebSocket(url)
this.ws.onmessage = (e)=>{
try {
MyWs.receiveText(JSON.parse(e.data))
} catch (error) {
console.error('websocket',error)
}
}
console.log(this.ws);
}
static receiveText(data,call){
console.log('receive',data);
MyEvent.emit('getMessage',data)
}
sendMessage(data) {
console.log(this);
@@ -43,4 +59,5 @@ class MyWs {
}
}
}
export default new MyWs();
export default new MyWs()