// composables/useMessageBox.ts import { ElMessageBox } from 'element-plus'; export const useMessageBox = () => { const confirm = (options: any) => { return ElMessageBox.confirm( options.message, options.title, Object.assign({ confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', draggable: true, showClose: false, customClass: 'custom-message-box', beforeClose: (action:string, instance:any, done:any) => { if (action === 'confirm') { instance.confirmButtonLoading = true; setTimeout(() => { done(); instance.confirmButtonLoading = false; }, 1000); } else { done(); } } }, options) ); }; const prompt = (options: any) => { return ElMessageBox.prompt( options.message, options.title, Object.assign({ confirmButtonText: '提交', cancelButtonText: '取消', inputType: 'text', inputPlaceholder: '请输入内容', draggable: true }, options) ); }; const alert = (options: any) => { return ElMessageBox.alert( options.message, options.title, Object.assign({ confirmButtonText: '我知道了', type: 'info' }, options) ); }; return { confirm, prompt, alert }; };