birdpaper-ui
Version:
一个通用的 vue3 UI组件库。A common vue3 UI component library.
33 lines (32 loc) • 850 B
JavaScript
import _sfc_main from "./src/messageList.vue.js";
import { getComponentsPrefix } from "../utils/config.js";
import MessageManager from "./src/instance.js";
import { isString } from "../utils/util.js";
_sfc_main.name = getComponentsPrefix() + _sfc_main.name;
let msg = null;
const types = ["text", "success", "warning", "error", "loading"];
const message = types.reduce((pre, value) => {
pre[value] = (config, appContext) => {
if (isString(config)) {
config = { content: config };
}
const _config = { type: value, ...config };
if (!msg) {
msg = new MessageManager(appContext);
}
return msg.add(_config);
};
return pre;
}, {});
const Message = Object.assign({
...message,
removeAll: () => {
msg && msg.clear();
},
install: (app, option) => {
return {};
}
});
export {
Message as default
};