Просмотр исходного кода

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

visuddhinanda 2 лет назад
Родитель
Сommit
d375a05ce7
1 измененных файлов с 7 добавлено и 4 удалено
  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]);