feat: 优化确认对话框的属性设置,简化代码结构
This commit is contained in:
@ -68,14 +68,8 @@ const openConfirm = async () => {
|
|||||||
message: '确定要继续吗?',
|
message: '确定要继续吗?',
|
||||||
header: '确认',
|
header: '确认',
|
||||||
icon: 'pi pi-exclamation-triangle',
|
icon: 'pi pi-exclamation-triangle',
|
||||||
rejectProps: {
|
rejectProps: { label: '取消', severity: 'secondary', outlined: true },
|
||||||
label: '取消',
|
acceptProps: { label: '确定' },
|
||||||
severity: 'secondary',
|
|
||||||
outlined: true,
|
|
||||||
},
|
|
||||||
acceptProps: {
|
|
||||||
label: '确定',
|
|
||||||
},
|
|
||||||
accept: () => {
|
accept: () => {
|
||||||
ToastService.add({ severity: 'info', summary: '已确认', detail: '您已同意操作', life: 3000 });
|
ToastService.add({ severity: 'info', summary: '已确认', detail: '您已同意操作', life: 3000 });
|
||||||
},
|
},
|
||||||
|
@ -8,9 +8,13 @@ import '../assets/reset-primevue.css';
|
|||||||
// ========================================================================
|
// ========================================================================
|
||||||
// @ts-expect-error - Ignore missing types
|
// @ts-expect-error - Ignore missing types
|
||||||
import ConfirmationEventBus from 'primevue/confirmationeventbus';
|
import ConfirmationEventBus from 'primevue/confirmationeventbus';
|
||||||
import type { ConfirmationServiceMethods } from 'primevue/confirmationservice';
|
import type { ConfirmationOptions } from 'primevue/confirmationoptions';
|
||||||
export const ConfirmationService: ConfirmationServiceMethods = {
|
interface HConfirmationOptions extends ConfirmationOptions {
|
||||||
require: (options) => {
|
rejectProps?: import('primevue/button').ButtonProps;
|
||||||
|
acceptProps?: import('primevue/button').ButtonProps;
|
||||||
|
}
|
||||||
|
export const ConfirmationService = {
|
||||||
|
require: (options: HConfirmationOptions) => {
|
||||||
ConfirmationEventBus.emit('confirm', options);
|
ConfirmationEventBus.emit('confirm', options);
|
||||||
},
|
},
|
||||||
close: () => {
|
close: () => {
|
||||||
|
Reference in New Issue
Block a user