type DialogType = 'success' | 'error' | 'info' interface DialogBoxProps { show?: boolean type?: DialogType confirmText?: string confirmPlain?: boolean cancelText?: string iconSize?: string message?: string tip?: string showConfirm?: boolean showCancel?: boolean showTip?: boolean closeOnClickOverlay?: boolean } const DIALOG_PRESETS: Record> = { info: { type: 'info', iconSize: '120rpx', confirmText: '知道了', }, success: { type: 'success', iconSize: '120rpx', confirmText: '好的', }, error: { type: 'error', iconSize: '120rpx', confirmText: '重试', }, } /** * 创建预设对话框配置 * @param type 对话框类型 * @param message 消息内容 * @param options 额外配置选项 * @returns 对话框配置 */ export function createDialogConfig( type: DialogType, message: string, options: Partial = {}, ): DialogBoxProps { const preset = DIALOG_PRESETS[type] return { show: true, message, ...preset, ...options, } } /** * 创建信息对话框配置 */ export function createInfoDialog(message: string, options?: Partial) { return createDialogConfig('info', message, options) } /** * 创建成功对话框配置 */ export function createSuccessDialog(message: string, options?: Partial) { return createDialogConfig('success', message, options) } /** * 创建错误对话框配置 */ export function createErrorDialog(message: string, options?: Partial) { return createDialogConfig('error', message, options) } /** * 对话框工具类 */ export class DialogUtils { /** * 显示信息对话框 */ static info(message: string, options?: Partial) { return createInfoDialog(message, options) } /** * 显示成功对话框 */ static success(message: string, options?: Partial) { return createSuccessDialog(message, options) } /** * 显示错误对话框 */ static error(message: string, options?: Partial) { return createErrorDialog(message, options) } }