admin-vben5/apps/web-antd/src/views/monitor/online/index.vue

75 lines
1.8 KiB
Vue
Raw Normal View History

2024-08-07 08:57:56 +08:00
<script setup lang="ts">
2024-10-05 13:44:02 +08:00
import type { Recordable } from '@vben/types';
2024-09-24 11:23:02 +08:00
2024-10-05 13:44:02 +08:00
import { Page, type VbenFormProps } from '@vben/common-ui';
2024-10-07 16:56:32 +08:00
import { getPopupContainer } from '@vben/utils';
2024-09-24 11:23:02 +08:00
2024-10-05 13:44:02 +08:00
import { Popconfirm } from 'ant-design-vue';
2024-09-24 11:23:02 +08:00
2024-10-17 15:16:22 +08:00
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
2024-10-05 13:44:02 +08:00
import { forceLogout, onlineList } from '#/api/monitor/online';
2024-09-24 11:23:02 +08:00
2024-10-05 13:44:02 +08:00
import { columns, querySchema } from './data';
const formOptions: VbenFormProps = {
2024-10-05 23:34:29 +08:00
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
2024-10-05 23:34:29 +08:00
},
2024-10-05 13:44:02 +08:00
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
};
const gridOptions: VxeGridProps = {
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await onlineList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
2024-09-24 11:23:02 +08:00
},
},
2024-10-05 13:44:02 +08:00
rowConfig: {
isHover: true,
keyField: 'tokenId',
2024-09-24 11:23:02 +08:00
},
id: 'monitor-online-index',
2024-10-05 13:44:02 +08:00
};
const [BasicTable, tableApi] = useVbenVxeGrid({ formOptions, gridOptions });
async function handleForceOffline(row: Recordable<any>) {
await forceLogout(row.tokenId);
2024-10-05 23:34:29 +08:00
await tableApi.query();
2024-10-05 13:44:02 +08:00
}
2024-08-07 08:57:56 +08:00
</script>
<template>
2024-10-05 13:44:02 +08:00
<Page :auto-content-height="true">
<BasicTable>
<template #toolbar-actions>
2024-10-05 23:42:25 +08:00
<span class="pl-[7px] text-[16px]">在线用户列表</span>
2024-10-05 13:44:02 +08:00
</template>
<template #action="{ row }">
<Popconfirm
2024-10-07 16:56:32 +08:00
:get-popup-container="getPopupContainer"
2024-10-05 13:44:02 +08:00
:title="`确认强制下线[${row.userName}]?`"
placement="left"
@confirm="handleForceOffline(row)"
>
2024-10-07 16:56:32 +08:00
<ghost-button danger>强制下线</ghost-button>
2024-10-05 13:44:02 +08:00
</Popconfirm>
</template>
</BasicTable>
2024-09-24 11:23:02 +08:00
</Page>
2024-08-07 08:57:56 +08:00
</template>