浏览代码

修改重复提示问题

bill 2 年之前
父节点
当前提交
ceae24f460
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      src/graphic/Service/UIService.js

+ 13 - 1
src/graphic/Service/UIService.js

@@ -287,8 +287,20 @@ export default class UIService {
     return newPosition;
   }
 
+  currentShowMsgs = [];
   prompt(msg) {
-    Message.success(typeof msg === "string" ? { msg } : msg);
+    const config = typeof msg === "string" ? { msg, time: 1000 } : msg;
+    if (this.currentShowMsgs.includes(config.msg)) {
+      return;
+    }
+
+    this.currentShowMsgs.push(config.msg);
+    setTimeout(() => {
+      this.currentShowMsgs = this.currentShowMsgs.filter(
+        (msg) => msg !== config.msg
+      );
+    }, config.time);
+    Message.success(config);
   }
 }