强制退出功能
This commit is contained in:
@@ -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);
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user