refactor:优化 mail 邮箱的实现

This commit is contained in:
YunaiV
2025-04-04 17:45:56 +08:00
parent c03845ba99
commit a59c3bed8a
13 changed files with 267 additions and 418 deletions

View File

@@ -1,19 +1,14 @@
<script lang="ts" setup>
import type {
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemMailLogApi } from '#/api/system/mail/log';
import { Page, useVbenModal } from '@vben/common-ui';
import { message } from 'ant-design-vue';
import Form from './modules/form.vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getMailLogPage, resendMail } from '#/api/system/mail/log';
import { getMailLogPage } from '#/api/system/mail/log';
import { useGridColumns, useGridFormSchema } from './data';
import Form from './modules/form.vue';
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
@@ -25,40 +20,17 @@ function onRefresh() {
gridApi.query();
}
/** 查看邮件日志详情 */
function onView(row: SystemMailLogApi.MailLog) {
/** 查看邮件日志 */
function onView(row: SystemMailLogApi.SystemMailLog) {
formModalApi.setData(row).open();
}
/** 重新发送邮件 */
async function onResend(row: SystemMailLogApi.MailLog) {
const hideLoading = message.loading({
content: '重新发送邮件中...',
duration: 0,
key: 'action_process_msg',
});
try {
await resendMail(row.id as number);
message.success({
content: '重新发送邮件成功',
key: 'action_process_msg',
});
onRefresh();
} finally {
hideLoading();
}
}
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
}: OnActionClickParams<SystemMailLogApi.MailLog>) {
}: OnActionClickParams<SystemMailLogApi.SystemMailLog>) {
switch (code) {
case 'resend': {
onResend(row);
break;
}
case 'view': {
onView(row);
break;
@@ -92,7 +64,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
refresh: { code: 'query' },
search: true,
},
} as VxeTableGridOptions<SystemMailLogApi.MailLog>,
} as VxeTableGridOptions<SystemMailLogApi.SystemMailLog>,
});
</script>
<template>