Browse Source

word === "undefined" 不查询

visuddhinanda 2 years ago
parent
commit
19db611500

+ 3 - 0
dashboard/src/components/dict/CaseList.tsx

@@ -16,6 +16,9 @@ const CaseListWidget = ({ word }: IWidget) => {
   const [caseData, setCaseData] = useState<ICaseListData[]>();
   const [count, setCount] = useState<number>();
   useEffect(() => {
+    if (typeof word === "undefined") {
+      return;
+    }
     get<ICaseListResponse>(`/v2/case/${word}`).then((json) => {
       console.log("case", json);
       if (json.ok) {

+ 3 - 0
dashboard/src/components/dict/Compound.tsx

@@ -55,6 +55,9 @@ const CompoundWidget = ({ word, add, split, onSearch }: IWidget) => {
     }
   }, [add, compound]);
   useEffect(() => {
+    if (typeof word === "undefined") {
+      return;
+    }
     get<IApiResponseDictList>(`/v2/userdict?view=compound&word=${word}`).then(
       (json) => {
         if (json.ok) {