强制退出功能

This commit is contained in:
橙子
2022-10-03 18:27:37 +08:00
parent 3943536485
commit 1a2d9ba2b2
12 changed files with 208 additions and 248 deletions

View File

@@ -2,7 +2,8 @@
import * as signalR from '@microsoft/signalr'
import useSocketStore from '@/store/modules/socket'
import { getToken } from '@/utils/auth'
import useUserStore from '@/store/modules/user'
import { ElMessage } from 'element-plus'
export default {
// signalR对象
@@ -36,6 +37,12 @@ export default {
* 调用 this.signalR.start().then(async () => { await this.SR.invoke("method")})
* @returns
*/
async close(){
var that = this;
await this.SR.stop();
},
async start() {
var that = this;
@@ -62,6 +69,12 @@ export default {
const socketStore = useSocketStore();
socketStore.setOnlineNum(data)
});
connection.on("forceOut", (msg) => {
useUserStore().logOut().then(() => {
ElMessage.error(msg);
location.href = '/index';
})
});
// connection.on("onlineNum", (data) => {
// store.dispatch("socket/changeOnlineNum", data);
// });