mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
perf: 防止message重复弹出 (#1996)
This commit is contained in:
parent
5dac95c3de
commit
c1db5886ff
@ -1,7 +1,21 @@
|
|||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
let messageDom: any = null;
|
||||||
|
const messageTypes: Array<string> = ['success', 'error', 'warning', 'info'];
|
||||||
|
const Message: any = (options) => {
|
||||||
|
if (messageDom) messageDom.close();
|
||||||
|
messageDom = ElMessage(options);
|
||||||
|
};
|
||||||
|
messageTypes.forEach((type) => {
|
||||||
|
Message[type] = (options) => {
|
||||||
|
if (typeof options === 'string') options = { message: options };
|
||||||
|
options.type = type;
|
||||||
|
return Message(options);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
export const MsgSuccess = (message) => {
|
export const MsgSuccess = (message) => {
|
||||||
ElMessage.success({
|
Message.success({
|
||||||
message: message,
|
message: message,
|
||||||
type: 'success',
|
type: 'success',
|
||||||
showClose: true,
|
showClose: true,
|
||||||
@ -10,7 +24,7 @@ export const MsgSuccess = (message) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const MsgInfo = (message) => {
|
export const MsgInfo = (message) => {
|
||||||
ElMessage.info({
|
Message.info({
|
||||||
message: message,
|
message: message,
|
||||||
type: 'info',
|
type: 'info',
|
||||||
showClose: true,
|
showClose: true,
|
||||||
@ -19,7 +33,7 @@ export const MsgInfo = (message) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const MsgWarning = (message) => {
|
export const MsgWarning = (message) => {
|
||||||
ElMessage.warning({
|
Message.warning({
|
||||||
message: message,
|
message: message,
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
showClose: true,
|
showClose: true,
|
||||||
@ -28,7 +42,7 @@ export const MsgWarning = (message) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const MsgError = (message) => {
|
export const MsgError = (message) => {
|
||||||
ElMessage.error({
|
Message.error({
|
||||||
message: message,
|
message: message,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
showClose: true,
|
showClose: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user