@aplus-frontend/ui
Version:
87 lines (86 loc) • 1.77 kB
JavaScript
import { createVNode as o } from "vue";
import { Modal as r, notification as i, message as s } from "@aplus-frontend/antdv";
import { InfoCircleFilled as c, CheckCircleFilled as f, CloseCircleFilled as d } from "@ant-design/icons-vue";
import "../config-provider/index.mjs";
import { isType as m } from "@fruits-chain/utils";
import { useLocale as g } from "../config-provider/hooks/use-locale.mjs";
function l(e) {
return e === "warning" ? o(c, {
class: "modal-icon-warning"
}, null) : e === "success" ? o(f, {
class: "modal-icon-success"
}, null) : e === "info" ? o(c, {
class: "modal-icon-info"
}, null) : o(d, {
class: "modal-icon-error"
}, null);
}
function a({
content: e
}) {
return m("String")(e) ? o("div", {
innerHTML: `<div>${e}</div>`
}, null) : e;
}
function p(e) {
const n = e.iconType || "warning";
Reflect.deleteProperty(e, "iconType");
const u = {
centered: !0,
icon: l(n),
...e,
content: a(e)
};
return r.confirm(u);
}
const M = () => {
const {
t: e
} = g();
return {
okText: e("ap.common.okText"),
centered: !0
};
};
function t(e, n) {
return {
...M(),
...e,
content: a(e),
icon: l(n)
};
}
function C(e) {
return r.success(t(e, "success"));
}
function w(e) {
return r.error(t(e, "error"));
}
function T(e) {
return r.info(t(e, "info"));
}
function k(e) {
return r.warning(t(e, "warning"));
}
function v(e, n) {
return r[n](t(e, n));
}
i.config({
placement: "topRight",
duration: 3
});
function O() {
return {
createMessage: s,
notification: i,
createConfirm: p,
createSuccessModal: C,
createErrorModal: w,
createInfoModal: T,
createWarningModal: k,
createModal: v
};
}
export {
O as useMessage
};