perf: 使用封装的 confirm 替换 Modal.confirm

This commit is contained in:
xingyu4j
2025-05-06 21:38:46 +08:00
parent b724ca2917
commit d92972ba3e
6 changed files with 56 additions and 78 deletions

View File

@@ -5,11 +5,11 @@ import type {
} from '#/adapter/vxe-table';
import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log';
import { Page, useVbenModal } from '@vben/common-ui';
import { confirm, Page, useVbenModal } from '@vben/common-ui';
import { Download } from '@vben/icons';
import { downloadFileFromBlobPart } from '@vben/utils';
import { Button, message, Modal } from 'ant-design-vue';
import { Button, message } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
@@ -47,18 +47,13 @@ function onDetail(row: InfraApiErrorLogApi.ApiErrorLog) {
/** 处理已处理 / 已忽略的操作 */
async function onProcess(id: number, processStatus: number) {
Modal.confirm({
title: '确认操作',
confirm({
content: `确认标记为${InfraApiErrorLogProcessStatusEnum.DONE ? '已处理' : '已忽略'}?`,
onOk: async () => {
await updateApiErrorLogStatus(id, processStatus);
// 关闭并提示
message.success({
content: $t('ui.actionMessage.operationSuccess'),
key: 'action_process_msg',
});
onRefresh();
},
}).then(async () => {
await updateApiErrorLogStatus(id, processStatus);
// 关闭并提示
message.success($t('ui.actionMessage.operationSuccess'));
onRefresh();
});
}

View File

@@ -7,6 +7,7 @@ import type { InfraFileApi } from '#/api/infra/file';
import { Page, useVbenModal } from '@vben/common-ui';
import { Upload } from '@vben/icons';
import { openWindow } from '@vben/utils';
import { useClipboard } from '@vueuse/core';
import { Button, Image, message } from 'ant-design-vue';
@@ -52,7 +53,7 @@ async function onCopyUrl(row: InfraFileApi.File) {
/** 打开 URL */
function openUrl(url?: string) {
if (url) {
window.open(url, '_blank');
openWindow(url);
}
}

View File

@@ -5,10 +5,11 @@ import type {
} from '#/adapter/vxe-table';
import type { InfraFileConfigApi } from '#/api/infra/file-config';
import { Page, useVbenModal } from '@vben/common-ui';
import { confirm, Page, useVbenModal } from '@vben/common-ui';
import { Plus } from '@vben/icons';
import { openWindow } from '@vben/utils';
import { Button, message, Modal } from 'ant-design-vue';
import { Button, message } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
@@ -72,14 +73,13 @@ async function onTest(row: InfraFileConfigApi.FileConfig) {
const response = await testFileConfig(row.id as number);
hideLoading();
// 确认是否访问该文件
Modal.confirm({
confirm({
title: '测试上传成功',
content: '是否要访问该文件?',
okText: '访问',
confirmText: '访问',
cancelText: '取消',
onOk: () => {
window.open(response, '_blank');
},
}).then(() => {
openWindow(response);
});
} catch {
hideLoading();

View File

@@ -7,11 +7,11 @@ import type { InfraJobApi } from '#/api/infra/job';
import { useRouter } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui';
import { confirm, Page, useVbenModal } from '@vben/common-ui';
import { Download, History, Plus } from '@vben/icons';
import { downloadFileFromBlobPart } from '@vben/utils';
import { Button, message, Modal } from 'ant-design-vue';
import { Button, message } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
@@ -74,32 +74,24 @@ async function onUpdateStatus(row: InfraJobApi.Job) {
? InfraJobStatusEnum.NORMAL
: InfraJobStatusEnum.STOP;
const statusText = status === InfraJobStatusEnum.NORMAL ? '启用' : '停用';
Modal.confirm({
title: '确认操作',
confirm({
content: `确定${statusText} ${row.name} 吗?`,
onOk: async () => {
await updateJobStatus(row.id as number, status);
message.success({
content: $t('ui.actionMessage.operationSuccess'),
key: 'action_process_msg',
});
onRefresh();
},
}).then(async () => {
await updateJobStatus(row.id as number, status);
// 提示成功
message.success($t('ui.actionMessage.operationSuccess'));
onRefresh();
});
}
/** 执行一次任务 */
async function onTrigger(row: InfraJobApi.Job) {
Modal.confirm({
title: '确认操作',
confirm({
content: `确定执行一次 ${row.name} 吗?`,
onOk: async () => {
await runJob(row.id as number);
message.success({
content: $t('ui.actionMessage.operationSuccess'),
key: 'action_process_msg',
});
},
}).then(async () => {
await runJob(row.id as number);
message.success($t('ui.actionMessage.operationSuccess'));
});
}