From 8c6cf5bc434f1f236b9a12c45c05636a3903f8c7 Mon Sep 17 00:00:00 2001
From: AprilWind <2100166581@qq.com>
Date: 星期五, 19 四月 2024 13:02:14 +0800
Subject: [PATCH] !104 add 新增在线登录设备管理 * update 在线登录设备管理删除权限 * add 新增在线登录设备管理
---
src/views/system/user/profile/index.vue | 14 ++++++
src/views/system/user/profile/onlineDevice.vue | 59 +++++++++++++++++++++++++++++
src/api/monitor/online/index.ts | 16 ++++++++
3 files changed, 88 insertions(+), 1 deletions(-)
diff --git a/src/api/monitor/online/index.ts b/src/api/monitor/online/index.ts
index 3d9034a..7484702 100644
--- a/src/api/monitor/online/index.ts
+++ b/src/api/monitor/online/index.ts
@@ -18,3 +18,19 @@
method: 'delete'
});
}
+
+// 鑾峰彇褰撳墠鐢ㄦ埛鐧诲綍鍦ㄧ嚎璁惧
+export function getOnline() {
+ return request({
+ url: '/monitor/online',
+ method: 'get'
+ });
+}
+
+// 鍒犻櫎褰撳墠鍦ㄧ嚎璁惧
+export function delOnline(tokenId: string) {
+ return request({
+ url: '/monitor/online/' + tokenId,
+ method: 'post'
+ });
+}
diff --git a/src/views/system/user/profile/index.vue b/src/views/system/user/profile/index.vue
index 0c8b527..426fca8 100644
--- a/src/views/system/user/profile/index.vue
+++ b/src/views/system/user/profile/index.vue
@@ -58,6 +58,9 @@
<el-tab-pane label="绗笁鏂瑰簲鐢�" name="thirdParty">
<thirdParty :auths="state.auths" />
</el-tab-pane>
+ <el-tab-pane label="鍦ㄧ嚎璁惧" name="onlinDevice">
+ <onlinDevice :devices="state.devices" />
+ </el-tab-pane>
</el-tabs>
</el-card>
</el-col>
@@ -70,8 +73,10 @@
import UserInfo from './userInfo.vue';
import ResetPwd from './resetPwd.vue';
import ThirdParty from './thirdParty.vue';
+import OnlinDevice from './onlineDevice.vue';
import { getAuthList } from '@/api/system/social/auth';
import { getUserProfile } from '@/api/system/user';
+import { getOnline } from '@/api/monitor/online';
import { UserVO } from '@/api/system/user/types';
const activeTab = ref('userinfo');
@@ -80,12 +85,14 @@
roleGroup: string;
postGroup: string;
auths: any;
+ devices: any;
}
const state = ref<State>({
user: {},
roleGroup: '',
postGroup: '',
- auths: []
+ auths: [],
+ devices: []
});
const userForm = ref({});
@@ -102,9 +109,14 @@
const res = await getAuthList();
state.value.auths = res.data;
};
+const getOnlines = async () => {
+ const res = await getOnline();
+ state.value.devices = res.rows;
+};
onMounted(() => {
getUser();
getAuths();
+ getOnlines();
});
</script>
diff --git a/src/views/system/user/profile/onlineDevice.vue b/src/views/system/user/profile/onlineDevice.vue
new file mode 100644
index 0000000..479e89a
--- /dev/null
+++ b/src/views/system/user/profile/onlineDevice.vue
@@ -0,0 +1,59 @@
+<template>
+ <div>
+ <el-table :data="devices" style="width: 100%; height: 100%; font-size: 10px">
+ <el-table-column label="璁惧绫诲瀷" align="center">
+ <template #default="scope">
+ <dict-tag :options="sys_device_type" :value="scope.row.deviceType" />
+ </template>
+ </el-table-column>
+ <el-table-column label="涓绘満" align="center" prop="ipaddr" :show-overflow-tooltip="true" />
+ <el-table-column label="鐧诲綍鍦扮偣" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
+ <el-table-column label="鎿嶄綔绯荤粺" align="center" prop="os" :show-overflow-tooltip="true" />
+ <el-table-column label="娴忚鍣�" align="center" prop="browser" :show-overflow-tooltip="true" />
+ <el-table-column label="鐧诲綍鏃堕棿" align="center" prop="loginTime" width="180">
+ <template #default="scope">
+ <span>{{ parseTime(scope.row.loginTime) }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
+ <template #default="scope">
+ <el-tooltip content="鍒犻櫎" placement="top">
+ <el-button link type="primary" icon="Delete" @click="handldDelOnline(scope.row)">
+ </el-button>
+ </el-tooltip>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+</template>
+
+<script name="Online" lang="ts" setup>
+import { delOnline } from '@/api/monitor/online';
+import { propTypes } from '@/utils/propTypes';
+
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+const { sys_device_type } = toRefs<any>(proxy?.useDict('sys_device_type'));
+
+const props = defineProps({
+ devices: propTypes.any.isRequired
+});
+const devices = computed(() => props.devices);
+
+/** 鍒犻櫎鎸夐挳鎿嶄綔 */
+const handldDelOnline = (row: any) => {
+ ElMessageBox.confirm('鍒犻櫎璁惧鍚庯紝鍦ㄨ璁惧鐧诲綍闇�瑕侀噸鏂拌繘琛岄獙璇�')
+ .then(() => {
+ return delOnline(row.tokenId);
+ })
+ .then((res: any) => {
+ if (res.code === 200) {
+ proxy?.$modal.msgSuccess('鍒犻櫎鎴愬姛');
+ proxy?.$tab.refreshPage();
+ } else {
+ proxy?.$modal.msgError(res.msg);
+ }
+ })
+ .catch(() => {});
+};
+
+</script>
--
Gitblit v1.9.3