首次提交

This commit is contained in:
2023-06-04 20:01:58 +08:00
parent 00c64c53bb
commit 587f078d21
560 changed files with 106725 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import Wsocket from "@/utils/Wsocket"
import tool from "@/utils/tool"
class Message {
ws
timer = null
interval = 10 * 1000
constructor() {
this.ws = new Wsocket(
import.meta.env.VITE_APP_WS_URL + "?token=" + tool.local.get(import.meta.env.VITE_APP_TOKEN_PREFIX),
{
onOpen: (_) => {
console.log("已成功连接到消息服务器...")
},
onError: (_) => {
this.ws = undefined
console.log("未成功连接到消息服务器...")
},
onClose: (_) => {
this.ws = undefined
console.log("与消息服务器断开...")
}
}
)
this.ws.heartbeat.openHeartbeat = false
}
getMessage() {
this.timer = setInterval(() => {
this.ws && this.ws.send({ event: "get_unread_message" })
}, this.interval)
}
connection() {
this.ws.connection()
}
}
export default Message