|
|
@ -9,7 +9,7 @@ |
|
|
|
import router from '@/router'; |
|
|
|
import { useUserStoreHook } from '@/store/modules/user'; |
|
|
|
import { usePermissionStoreHook } from '@/store/modules/permission'; |
|
|
|
import socket from '@/utils/socket'; |
|
|
|
// import socket from '@/utils/socket';
|
|
|
|
import NProgress from 'nprogress'; |
|
|
|
import 'nprogress/nprogress.css'; |
|
|
|
NProgress.configure({ showSpinner: false }); // 进度条
|
|
|
@ -35,11 +35,11 @@ router.beforeEach(async (to, from, next) => { |
|
|
|
if (to.matched.length === 0) { |
|
|
|
from.name ? next({ name: from.name }) : next('/404'); |
|
|
|
} else { |
|
|
|
console.log('切换页面发送websocket信息'); |
|
|
|
// console.log('切换页面发送websocket信息');
|
|
|
|
const exitStatu = { |
|
|
|
code: 'exitDataMonitor' |
|
|
|
}; |
|
|
|
socket.onSend(exitStatu); |
|
|
|
// socket.onSend(exitStatu);
|
|
|
|
next(); |
|
|
|
} |
|
|
|
} else { |
|
|
@ -50,13 +50,13 @@ router.beforeEach(async (to, from, next) => { |
|
|
|
router.addRoute(route); |
|
|
|
}); |
|
|
|
|
|
|
|
console.log('登录后链接websocket'); |
|
|
|
// console.log('登录后链接websocket');
|
|
|
|
//登录后连接webSocket
|
|
|
|
const userStorageInfo = sessionStorage.getItem('userInfo'); |
|
|
|
const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo); |
|
|
|
// const wsUrl = `ws://${window.location.host}/ws/websocket/${userInfo.userName}`; //websocket地址
|
|
|
|
const wsUrl = `ws://10.10.10.56:9010/websocket/${userInfo.userName}`; //websocket地址
|
|
|
|
socket.initialize(wsUrl); |
|
|
|
// const wsUrl = `ws://10.10.10.56:9010/websocket/${userInfo.userName}`; //websocket地址
|
|
|
|
// socket.initialize(wsUrl);
|
|
|
|
next({ ...to, replace: true }); |
|
|
|
} catch (error) { |
|
|
|
// 移除 token 并跳转登录页
|
|
|
|