mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-04-10 12:53:15 +08:00
refactor: 个人中心 在线设备 样式重构
This commit is contained in:
@@ -7,4 +7,5 @@ export interface OnlineUser {
|
|||||||
browser: string;
|
browser: string;
|
||||||
os: string;
|
os: string;
|
||||||
loginTime: number;
|
loginTime: number;
|
||||||
|
deviceType: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +1,82 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Recordable } from '@vben/types';
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { OnlineUser } from '#/api/monitor/online/model';
|
||||||
|
|
||||||
import { Popconfirm } from 'ant-design-vue';
|
import { onMounted, shallowRef } from 'vue';
|
||||||
|
|
||||||
|
import { getPopupContainer } from '@vben/utils';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
Descriptions,
|
||||||
|
DescriptionsItem,
|
||||||
|
Popconfirm,
|
||||||
|
Spin,
|
||||||
|
Tag,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
||||||
import { forceLogout2, onlineDeviceList } from '#/api/monitor/online';
|
import { forceLogout2, onlineDeviceList } from '#/api/monitor/online';
|
||||||
import { columns } from '#/views/monitor/online/data';
|
import { renderBrowserIcon, renderOsIcon } from '#/utils/render';
|
||||||
|
|
||||||
const gridOptions: VxeGridProps = {
|
|
||||||
columns,
|
|
||||||
keepSource: true,
|
|
||||||
pagerConfig: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
proxyConfig: {
|
|
||||||
ajax: {
|
|
||||||
query: async () => {
|
|
||||||
return await onlineDeviceList();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rowConfig: {
|
|
||||||
keyField: 'tokenId',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const [BasicTable, tableApi] = useVbenVxeGrid({ gridOptions });
|
|
||||||
|
|
||||||
async function handleForceOffline(row: Recordable<any>) {
|
async function handleForceOffline(row: Recordable<any>) {
|
||||||
await forceLogout2(row.tokenId);
|
await forceLogout2(row.tokenId);
|
||||||
await tableApi.query();
|
await loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const list = shallowRef<OnlineUser[]>([]);
|
||||||
|
const loading = shallowRef(false);
|
||||||
|
async function loadData() {
|
||||||
|
loading.value = true;
|
||||||
|
const resp = await onlineDeviceList();
|
||||||
|
list.value = resp.rows;
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
onMounted(loadData);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="mb-6">
|
||||||
<BasicTable table-title="我的在线设备">
|
<Spin :spinning="loading">
|
||||||
<template #action="{ row }">
|
<div
|
||||||
<Popconfirm
|
class="grid max-h-[calc(100vh/2)] min-h-[100px] grid-cols-1 gap-4 overflow-auto lg:grid-cols-2 2xl:grid-cols-3"
|
||||||
:title="`确认强制下线[${row.userName}]?`"
|
>
|
||||||
placement="left"
|
<Card
|
||||||
@confirm="handleForceOffline(row)"
|
v-for="online in list"
|
||||||
|
:key="online.tokenId"
|
||||||
|
size="small"
|
||||||
|
:title="`登录时间: ${dayjs(online.loginTime).format('YYYY-MM-DD HH:mm:ss')}`"
|
||||||
>
|
>
|
||||||
<a-button danger size="small" type="link">强制下线</a-button>
|
<template #extra>
|
||||||
</Popconfirm>
|
<Popconfirm
|
||||||
</template>
|
title="确认强制下线?"
|
||||||
</BasicTable>
|
placement="left"
|
||||||
|
:get-popup-container="getPopupContainer"
|
||||||
|
@confirm="handleForceOffline(online)"
|
||||||
|
>
|
||||||
|
<a-button danger size="small">强制下线</a-button>
|
||||||
|
</Popconfirm>
|
||||||
|
</template>
|
||||||
|
<Descriptions size="middle" :column="2">
|
||||||
|
<DescriptionsItem label="登录平台">
|
||||||
|
<Tag>{{ online.deviceType }}</Tag>
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="登录地址">
|
||||||
|
{{ online.loginLocation }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="浏览器">
|
||||||
|
<component :is="renderBrowserIcon(online.browser)" />
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="系统">
|
||||||
|
<component :is="renderOsIcon(online.os)" />
|
||||||
|
</DescriptionsItem>
|
||||||
|
<DescriptionsItem label="IP地址">
|
||||||
|
{{ online.ipaddr }}
|
||||||
|
</DescriptionsItem>
|
||||||
|
</Descriptions>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user