diff --git a/src/App.vue b/src/App.vue
index 9b70e17..ab9dbf7 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -7,5 +7,34 @@
diff --git a/src/api/user/index.ts b/src/api/user/index.ts
index fd33efd..e315cf2 100644
--- a/src/api/user/index.ts
+++ b/src/api/user/index.ts
@@ -27,9 +27,7 @@ export function getWeather(): AxiosPromise<[]> {
*
* @param queryParams
*/
-export function getUserPage(
- queryParams: UserQuery
-): AxiosPromise> {
+export function getUserPage(queryParams: UserQuery): AxiosPromise> {
return request({
url: '/api/v1/users/page',
method: 'get',
@@ -168,7 +166,8 @@ export function importUser(deptId: number, file: File) {
*/
export function userVersionRelation(data: any) {
return request({
- url: 'model/userVersionRelation',
+ // url: 'model/userVersionRelation',
+ url: 'system/userNoticeRelation',
method: 'post',
data: data
});
diff --git a/src/permission.ts b/src/permission.ts
index 0488bb7..11876cf 100644
--- a/src/permission.ts
+++ b/src/permission.ts
@@ -9,6 +9,7 @@
import router from '@/router';
import { useUserStoreHook } from '@/store/modules/user';
import { usePermissionStoreHook } from '@/store/modules/permission';
+import socket from '@/utils/socket';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
NProgress.configure({ showSpinner: false }); // 进度条
@@ -34,6 +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信息');
+ const exitStatu = {
+ code: 'exitDataMonitor'
+ };
+ socket.onSend(exitStatu);
next();
}
} else {
@@ -43,6 +49,14 @@ router.beforeEach(async (to, from, next) => {
accessRoutes.forEach(route => {
router.addRoute(route);
});
+
+ 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);
next({ ...to, replace: true });
} catch (error) {
// 移除 token 并跳转登录页
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 6839636..3fbccca 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -57,10 +57,10 @@ export const useUserStore = defineStore('user', () => {
roles.value = data.roles;
perms.value = data.permissions;
userInfo.value = user;
- if (data.webVersion === null) {
+ if (data.notice === null) {
webVersion.value = '';
} else {
- webVersion.value = JSON.stringify(data.webVersion);
+ webVersion.value = JSON.stringify(data.notice);
}
// useStorage('userInfo', user);
resolve(data);
diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts
index 5742656..acba637 100644
--- a/src/types/auto-imports.d.ts
+++ b/src/types/auto-imports.d.ts
@@ -2,11 +2,9 @@
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
- const ElForm: typeof import('element-plus/es')['ElForm']
const ElMessage: typeof import('element-plus/es')['ElMessage']
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
const ElNotification: typeof import('element-plus/es')['ElNotification']
- const NEllipsis: typeof import('naive-ui')['NEllipsis']
const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
const computed: typeof import('vue')['computed']
@@ -273,11 +271,9 @@ import { UnwrapRef } from 'vue'
declare module 'vue' {
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef
- readonly ElForm: UnwrapRef
readonly ElMessage: UnwrapRef
readonly ElMessageBox: UnwrapRef
readonly ElNotification: UnwrapRef
- readonly NEllipsis: UnwrapRef
readonly asyncComputed: UnwrapRef
readonly autoResetRef: UnwrapRef
readonly computed: UnwrapRef
diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue
index 808a366..c8eef2c 100644
--- a/src/views/dashboard/index.vue
+++ b/src/views/dashboard/index.vue
@@ -86,13 +86,19 @@ import LineChart from './components/LineChart.vue';
import BarChart from './components/BarChart.vue';
import PieChart from './components/PieChart.vue';
import avatar from '@/assets/images/avatar.png';
+import mitt from '@/plugins/bus';
+
+// import socket from '@/utils/socket';
+// const userStorageInfo = sessionStorage.getItem('userInfo');
+// const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo);
+// const wsUrl = `ws://10.10.10.56:9010/websocket/${userInfo.userName}`; //websocket地址
const timer = ref();
const isCurrentRoute = ref(true);
const userStore = useUserStore();
const duration = 5000;
const userNumber = ref(2800);
-const notice = ref({});
+// const notice = ref({});
// const vsitsNumber = transitionNum(720, 5000);
const currentTime = useDateFormat(useNow(), 'YYYY-MM-DD HH:mm:ss');
const hoursNow = useNow().value.getHours();
@@ -170,32 +176,33 @@ const timePeriod = computed(() => {
onMounted(() => {
getWeatherData();
- const webVersion = sessionStorage.getItem('webVersion');
- if (webVersion != '' && webVersion != null) {
- const version = JSON.parse(webVersion);
- notice.value = ElNotification({
- title: '更新日志',
- dangerouslyUseHTMLString: true,
- customClass: 'notice',
- duration: 0,
- message: version.versionDesc.replace(/\n/g, '
'),
- onClose: () => {
- noticeCloce(version.id);
- }
- });
- }
+ // socket.initialize(wsUrl);
+ // const webVersion = sessionStorage.getItem('webVersion');
+ // if (webVersion != '' && webVersion != null) {
+ // const version = JSON.parse(webVersion);
+ // notice.value = ElNotification({
+ // title: version.noticeTitle,
+ // dangerouslyUseHTMLString: true,
+ // customClass: 'notice',
+ // duration: 0,
+ // message: version.noticeContent.replace(/\n/g, '
'),
+ // onClose: () => {
+ // noticeCloce(version.noticeId);
+ // }
+ // });
+ // }
});
-function noticeCloce(id: any) {
- //更新日志关闭事件
- const params = {
- versionId: id
- };
- userVersionRelation(params).then((res: any) => {
- if (res.code === 200) {
- console.log('更新日志关闭!');
- }
- });
-}
+// function noticeCloce(id: any) {
+// //更新日志关闭事件
+// const params = {
+// versionId: id
+// };
+// userVersionRelation(params).then((res: any) => {
+// if (res.code === 200) {
+// console.log('更新日志关闭!');
+// }
+// });
+// }
function getWeatherData() {
//获取天气
getWeather().then((res: any) => {
@@ -212,6 +219,10 @@ function getWeatherData() {
}
});
}
+// mitt.on('tableMessage', (res: any) => {
+// //监听表格数据变化
+// console.log('noticeMessage--', res.data);
+// });