feat: 优化确认对话框的属性设置,简化代码结构
Some checks failed
/ build-and-deploy-to-vercel (push) Failing after 31s
/ depcheck (push) Successful in 1m19s
/ playwright (push) Successful in 3m25s

This commit is contained in:
严浩
2024-12-14 20:49:49 +08:00
parent b1c0efb853
commit b9ad180d4c
2 changed files with 9 additions and 11 deletions

View File

@ -68,14 +68,8 @@ const openConfirm = async () => {
message: '确定要继续吗?',
header: '确认',
icon: 'pi pi-exclamation-triangle',
rejectProps: {
label: '取消',
severity: 'secondary',
outlined: true,
},
acceptProps: {
label: '确定',
},
rejectProps: { label: '取消', severity: 'secondary', outlined: true },
acceptProps: { label: '确定' },
accept: () => {
ToastService.add({ severity: 'info', summary: '已确认', detail: '您已同意操作', life: 3000 });
},

View File

@ -8,9 +8,13 @@ import '../assets/reset-primevue.css';
// ========================================================================
// @ts-expect-error - Ignore missing types
import ConfirmationEventBus from 'primevue/confirmationeventbus';
import type { ConfirmationServiceMethods } from 'primevue/confirmationservice';
export const ConfirmationService: ConfirmationServiceMethods = {
require: (options) => {
import type { ConfirmationOptions } from 'primevue/confirmationoptions';
interface HConfirmationOptions extends ConfirmationOptions {
rejectProps?: import('primevue/button').ButtonProps;
acceptProps?: import('primevue/button').ButtonProps;
}
export const ConfirmationService = {
require: (options: HConfirmationOptions) => {
ConfirmationEventBus.emit('confirm', options);
},
close: () => {