feat:增加 loginlog 登录日志
parent
99797f6618
commit
1259699632
|
|
@ -0,0 +1,32 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace SystemLoginLogApi {
|
||||||
|
/** 登录日志信息 */
|
||||||
|
export interface SystemLoginLog {
|
||||||
|
id: number;
|
||||||
|
logType: number;
|
||||||
|
traceId: number;
|
||||||
|
userId: number;
|
||||||
|
userType: number;
|
||||||
|
username: string;
|
||||||
|
result: number;
|
||||||
|
status: number;
|
||||||
|
userIp: string;
|
||||||
|
userAgent: string;
|
||||||
|
createTime: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询登录日志列表 */
|
||||||
|
export function getLoginLogPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<SystemLoginLogApi.SystemLoginLog>>('/system/login-log/page',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出登录日志 */
|
||||||
|
export function exportLoginLog(params: any) {
|
||||||
|
return requestClient.download('/system/login-log/export-excel', { params });
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { SystemLoginLogApi } from '#/api/system/login-log';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '#/utils/dict';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
import { useAccess } from '@vben/access';
|
||||||
|
|
||||||
|
const { hasAccessByCodes } = useAccess();
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'username',
|
||||||
|
label: '用户名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入用户名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'userIp',
|
||||||
|
label: '登录地址',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入登录地址',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'createTime',
|
||||||
|
label: '登录时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns<T = SystemLoginLogApi.SystemLoginLog>(
|
||||||
|
onActionClick: OnActionClickFn<T>,
|
||||||
|
): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: '日志编号',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'logType',
|
||||||
|
title: '操作类型',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.SYSTEM_LOGIN_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'username',
|
||||||
|
title: '用户名称',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'userIp',
|
||||||
|
title: '登录地址',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'userAgent',
|
||||||
|
title: '浏览器',
|
||||||
|
minWidth: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'result',
|
||||||
|
title: '登录结果',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.SYSTEM_LOGIN_RESULT },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '登录日期',
|
||||||
|
minWidth: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'operation',
|
||||||
|
title: '操作',
|
||||||
|
minWidth: 120,
|
||||||
|
align: 'center',
|
||||||
|
fixed: 'right',
|
||||||
|
cellRender: {
|
||||||
|
attrs: {
|
||||||
|
nameField: 'username',
|
||||||
|
nameTitle: '登录日志',
|
||||||
|
onClick: onActionClick,
|
||||||
|
},
|
||||||
|
name: 'CellOperation',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
code: 'view',
|
||||||
|
text: '详情',
|
||||||
|
show: hasAccessByCodes(['system:login-log:query']),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { SystemLoginLogApi } from '#/api/system/login-log';
|
||||||
|
|
||||||
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { Download } from '@vben/icons';
|
||||||
|
import { Button } from 'ant-design-vue';
|
||||||
|
import { DocAlert } from '#/components/doc-alert';
|
||||||
|
import Detail from './modules/detail.vue';
|
||||||
|
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { exportLoginLog, getLoginLogPage } from '#/api/system/login-log';
|
||||||
|
import { downloadByData } from '#/utils/download';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
|
||||||
|
const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Detail,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function onRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function onExport() {
|
||||||
|
const data = await exportLoginLog(await gridApi.formApi.getValues());
|
||||||
|
downloadByData(data, '登录日志.xls');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看登录日志详情 */
|
||||||
|
function onView(row: SystemLoginLogApi.SystemLoginLog) {
|
||||||
|
detailModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表格操作按钮的回调函数 */
|
||||||
|
function onActionClick({
|
||||||
|
code,
|
||||||
|
row,
|
||||||
|
}: OnActionClickParams<SystemLoginLogApi.SystemLoginLog>) {
|
||||||
|
switch (code) {
|
||||||
|
case 'view': {
|
||||||
|
onView(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(onActionClick),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getLoginLogPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<SystemLoginLogApi.SystemLoginLog>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<DocAlert title="系统日志" url="https://doc.iocoder.cn/system-log/" />
|
||||||
|
|
||||||
|
<DetailModal @success="onRefresh" />
|
||||||
|
<Grid table-title="登录日志列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<Button type="primary" class="ml-2" @click="onExport" v-access:code="['system:login-log:export']">
|
||||||
|
<Download class="size-5" />
|
||||||
|
{{ $t('ui.actionTitle.export') }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { SystemLoginLogApi } from '#/api/system/login-log';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { Descriptions } from 'ant-design-vue';
|
||||||
|
import { DictTag } from '#/components/dict-tag';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { formatDateTime } from '@vben/utils';
|
||||||
|
import { DICT_TYPE } from '#/utils/dict';
|
||||||
|
|
||||||
|
const formData = ref<SystemLoginLogApi.SystemLoginLog>();
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<SystemLoginLogApi.SystemLoginLog>();
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = data;
|
||||||
|
} finally {
|
||||||
|
modalApi.lock(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal title="登录日志详情" class="w-1/2" :show-cancel-button="false" :show-confirm-button="false">
|
||||||
|
<Descriptions bordered :column="1" size="middle" class="mx-4" :label-style="{ width: '110px' }">
|
||||||
|
<Descriptions.Item label="日志编号">
|
||||||
|
{{ formData?.id }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="操作类型">
|
||||||
|
<DictTag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="formData?.logType" />
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="用户名称">
|
||||||
|
{{ formData?.username }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="登录地址">
|
||||||
|
{{ formData?.userIp }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="浏览器">
|
||||||
|
{{ formData?.userAgent }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="登录结果">
|
||||||
|
<DictTag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="formData?.result" />
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="登录日期">
|
||||||
|
{{ formatDateTime(formData?.createTime || '') }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -69,9 +69,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
|
||||||
|
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
|
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
||||||
|
|
||||||
<DetailModal @success="onRefresh" />
|
<DetailModal @success="onRefresh" />
|
||||||
<Grid table-title="邮件日志列表">
|
<Grid table-title="邮件日志列表">
|
||||||
<template #toolbar-tools> </template>
|
<template #toolbar-tools> </template>
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal title="邮件日志详情" class="w-1/2">
|
<Modal title="邮件日志详情" class="w-1/2" :show-cancel-button="false" :show-confirm-button="false">
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<Descriptions :column="2" bordered>
|
<Descriptions :column="2" bordered :label-style="{ width: '140px' }">
|
||||||
<Descriptions.Item label="编号">{{ formData?.id }}</Descriptions.Item>
|
<Descriptions.Item label="编号">{{ formData?.id }}</Descriptions.Item>
|
||||||
<Descriptions.Item label="创建时间">
|
<Descriptions.Item label="创建时间">
|
||||||
{{ formatDateTime(formData?.createTime || '') }}
|
{{ formatDateTime(formData?.createTime || '') }}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal title="站内信详情" class="w-1/2">
|
<Modal title="站内信详情" class="w-1/2" :show-cancel-button="false" :show-confirm-button="false">
|
||||||
<Descriptions bordered :column="1" size="middle" class="mx-4">
|
<Descriptions bordered :column="1" size="middle" class="mx-4">
|
||||||
<Descriptions.Item label="编号">{{ formData?.id }}</Descriptions.Item>
|
<Descriptions.Item label="编号">{{ formData?.id }}</Descriptions.Item>
|
||||||
<Descriptions.Item label="用户类型">
|
<Descriptions.Item label="用户类型">
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
import type { SystemSmsLogApi } from '#/api/system/sms/log';
|
import type { SystemSmsLogApi } from '#/api/system/sms/log';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { Descriptions, Tag } from 'ant-design-vue';
|
import { Descriptions } from 'ant-design-vue';
|
||||||
|
import { DictTag } from '#/components/dict-tag';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { formatDateTime } from '@vben/utils';
|
import { formatDateTime } from '@vben/utils';
|
||||||
import { DICT_TYPE } from '#/utils/dict';
|
import { DICT_TYPE } from '#/utils/dict';
|
||||||
import { DictTag } from '#/components/dict-tag';
|
|
||||||
|
|
||||||
const formData = ref<SystemSmsLogApi.SystemSmsLog>();
|
const formData = ref<SystemSmsLogApi.SystemSmsLog>();
|
||||||
|
|
||||||
|
|
@ -32,8 +32,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal title="短信日志详情" class="w-1/2">
|
<Modal title="短信日志详情" class="w-1/2" :show-cancel-button="false" :show-confirm-button="false">
|
||||||
<Descriptions bordered :column="2" size="middle" class="mx-4">
|
<Descriptions bordered :column="2" size="middle" class="mx-4" :label-style="{ width: '140px' }">
|
||||||
<Descriptions.Item label="创建时间">
|
<Descriptions.Item label="创建时间">
|
||||||
{{ formatDateTime(formData?.createTime || '') }}
|
{{ formatDateTime(formData?.createTime || '') }}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue