diff --git a/src/api/monitor/online.js b/src/api/monitor/online.js index a6d20ec..d51b88d 100644 --- a/src/api/monitor/online.js +++ b/src/api/monitor/online.js @@ -10,9 +10,10 @@ export function listOnline(query) { } // 强退用户 -export function forceLogout(tokenId) { +export function forceLogout(data) { return request({ - url: '/monitor/online/' + tokenId, - method: 'delete' + url: '/monitor/online/lock', + method: 'delete', + data: data }) } diff --git a/src/router/index.js b/src/router/index.js index 874564a..76f9155 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -85,22 +85,6 @@ export const constantRoutes = [ meta: { title: '个人中心', icon: 'user', titleKey: 'menu.personalCenter' } } ] - }, - // 不用可删掉 - { - path: '', - component: Layout, - hidden: false, - meta: { title: '组件示例', icon: 'icon', noCache: 'fasle' }, - children: [ - { - path: 'icon', - component: () => import('@/views/components/icons/index'), - //component: () => import('@/views/business/GenDemo'), - name: 'icon', - meta: { title: '图标icon', icon: 'icon1', noCache: 'fasle', titleKey: 'menu.icon' } - } - ] } ] diff --git a/src/utils/signalR.js b/src/utils/signalR.js index e4cbe60..e34acc4 100644 --- a/src/utils/signalR.js +++ b/src/utils/signalR.js @@ -1,15 +1,15 @@ // 官方文档:https://docs.microsoft.com/zh-cn/aspnet/core/signalr/javascript-client?view=aspnetcore-6.0&viewFallbackFrom=aspnetcore-2.2&tabs=visual-studio import * as signalR from '@microsoft/signalr' import { getToken } from '@/utils/auth' -import { ElNotification, ElMessage } from 'element-plus' +import { ElNotification, ElMessage, ElMessageBox } from 'element-plus' import useSocketStore from '@/store/modules/socket' +import useUserStore from '@/store/modules/user' import { webNotify } from './index' export default { // signalR对象 SR: {}, // 失败连接重试次数 failNum: 4, - baseUrl: '', init(url) { var socketUrl = window.location.origin + url const connection = new signalR.HubConnectionBuilder() @@ -80,6 +80,9 @@ export default { connection.on('welcome', (data) => { ElNotification.info(data) }) + connection.on('getConnId', (data) => { + // useUserStore().saveConnId(data) + }) // 接收后台手动推送消息 connection.on('receiveNotice', (title, data) => { ElNotification({ @@ -103,6 +106,22 @@ export default { // useSocketStore().setOnlineUsers(data) // }) + // 接收封锁通知 + connection.on('lockUser', (data) => { + ElMessageBox.alert(`你的账号已被锁定,剩余,${data.time}分,原因:${data.reason || '-'}`, '提示', { + confirmButtonText: '确定', + callback: (action) => { + useUserStore() + .logOut() + .then(() => { + var redirectUrl = window.location.pathname + if (location.pathname.indexOf('/login') != 0) { + location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'index?redirect=' + redirectUrl + } + }) + } + }) + }) // 接收聊天数据 connection.on('receiveChat', (data) => { const title = `来自${data.userName}的消息通知` diff --git a/src/views/monitor/onlineuser/index.vue b/src/views/monitor/onlineuser/index.vue index efe96a6..bef028d 100644 --- a/src/views/monitor/onlineuser/index.vue +++ b/src/views/monitor/onlineuser/index.vue @@ -15,40 +15,32 @@ - - - - + + + + - + - + diff --git a/src/views/monitor/operlog/index.vue b/src/views/monitor/operlog/index.vue index 21d6df9..c8637e6 100644 --- a/src/views/monitor/operlog/index.vue +++ b/src/views/monitor/operlog/index.vue @@ -91,7 +91,7 @@ - +