Procházet zdrojové kódy

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

visuddhinanda před 2 roky
rodič
revize
d375a05ce7
1 změnil soubory, kde provedl 7 přidání a 4 odebrání
  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(() => {
   useEffect(() => {
     console.log("get command", searchWord);
     console.log("get command", searchWord);
-    if (myDictDirty) {
-      notification.warning({ message: "用户词典有未保存内容,请保存后再查词" });
-      return;
-    }
+
     if (typeof searchWord === "string" && searchWord !== wordSearch) {
     if (typeof searchWord === "string" && searchWord !== wordSearch) {
+      if (myDictDirty) {
+        notification.warning({
+          message: "用户词典有未保存内容,请保存后再查词",
+        });
+        return;
+      }
       setWordSearch(searchWord);
       setWordSearch(searchWord);
     }
     }
   }, [searchWord, myDictDirty, wordSearch]);
   }, [searchWord, myDictDirty, wordSearch]);