mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-07 17:38:55 +08:00
refactor: 统一组件导入与消息提示方式
- 将多个组件中的 require 替换为 import,提升代码一致性。 - 更新消息提示方式,使用统一的 Message 和 Modal 组件,增强用户体验。 - 调整部分组件的样式和逻辑,确保界面一致性与可读性。
This commit is contained in:
@@ -63,11 +63,42 @@ export const Notice = {
|
||||
export const Modal = {
|
||||
confirm(options = {}) {
|
||||
const content = options.content || options.title || "确认操作?";
|
||||
return ElMessageBox.confirm(content, options.title || "提示", {
|
||||
const title = options.title || "提示";
|
||||
const boxOptions = {
|
||||
confirmButtonText: options.okText || "确定",
|
||||
cancelButtonText: options.cancelText || "取消",
|
||||
type: options.type || "warning",
|
||||
})
|
||||
};
|
||||
|
||||
if (options.loading) {
|
||||
return ElMessageBox.confirm(content, title, {
|
||||
...boxOptions,
|
||||
beforeClose: (action, instance, done) => {
|
||||
if (action !== "confirm") {
|
||||
if (typeof options.onCancel === "function") {
|
||||
options.onCancel();
|
||||
}
|
||||
done();
|
||||
return;
|
||||
}
|
||||
if (typeof options.onOk !== "function") {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
instance.confirmButtonLoading = true;
|
||||
Promise.resolve(options.onOk())
|
||||
.then(() => {
|
||||
instance.confirmButtonLoading = false;
|
||||
done();
|
||||
})
|
||||
.catch(() => {
|
||||
instance.confirmButtonLoading = false;
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return ElMessageBox.confirm(content, title, boxOptions)
|
||||
.then(() => {
|
||||
if (typeof options.onOk === "function") {
|
||||
return options.onOk();
|
||||
|
||||
Reference in New Issue
Block a user