Explorar o código

确定查词前判断是否有未保存数据

visuddhinanda %!s(int64=2) %!d(string=hai) anos
pai
achega
d375a05ce7
Modificáronse 1 ficheiros con 7 adicións e 4 borrados
  1. 7 4
      dashboard/src/components/dict/DictComponent.tsx

+ 7 - 4
dashboard/src/components/dict/DictComponent.tsx

@@ -17,11 +17,14 @@ const DictComponentWidget = ({ word }: IWidgetDict) => {
 
   useEffect(() => {
     console.log("get command", searchWord);
-    if (myDictDirty) {
-      notification.warning({ message: "用户词典有未保存内容,请保存后再查词" });
-      return;
-    }
+
     if (typeof searchWord === "string" && searchWord !== wordSearch) {
+      if (myDictDirty) {
+        notification.warning({
+          message: "用户词典有未保存内容,请保存后再查词",
+        });
+        return;
+      }
       setWordSearch(searchWord);
     }
   }, [searchWord, myDictDirty, wordSearch]);