feat: 优化确认对话框的属性设置,简化代码结构
This commit is contained in:
@ -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 });
|
||||
},
|
||||
|
@ -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: () => {
|
||||
|
Reference in New Issue
Block a user