Explorar el Código

wbw real 可以为null

visuddhinanda hace 2 años
padre
commit
f8b5c2a979

+ 3 - 0
dashboard/src/components/template/Wbw/WbwCase.tsx

@@ -37,6 +37,9 @@ const WbwCaseWidget = ({ data, display, onSplit, onChange }: IWidget) => {
 
   const inlineDict = useAppSelector(_inlineDict);
   useEffect(() => {
+    if (!data.real.value) {
+      return;
+    }
     if (inlineDict.wordIndex.includes(data.real.value)) {
       const result = inlineDict.wordList.filter(
         (word) => word.word === data.real.value

+ 1 - 1
dashboard/src/components/template/Wbw/WbwDetailAdvance.tsx

@@ -36,7 +36,7 @@ const WbwDetailAdvanceWidget = ({ data, onChange }: IWidget) => {
       <Input
         showCount
         maxLength={512}
-        defaultValue={data.real?.value}
+        defaultValue={data.real?.value ? data.real?.value : ""}
         onChange={onRealChange}
       />
     </>

+ 3 - 0
dashboard/src/components/template/Wbw/WbwDetailFactor.tsx

@@ -55,6 +55,9 @@ const WbwDetailFactorWidget = ({ data, onChange }: IWidget) => {
   }, [data.factors]);
 
   useEffect(() => {
+    if (!data.real.value) {
+      return;
+    }
     const factors = getFactorsInDict(
       data.real.value,
       inlineDict.wordIndex,

+ 3 - 0
dashboard/src/components/template/Wbw/WbwFactors.tsx

@@ -57,6 +57,9 @@ const WbwFactorsWidget = ({ data, display, onChange }: IWidget) => {
   const inlineDict = useAppSelector(_inlineDict);
 
   useEffect(() => {
+    if (!data.real.value) {
+      return;
+    }
     if (inlineDict.wordIndex.includes(data.real.value)) {
       const result = inlineDict.wordList.filter(
         (word) => word.word === data.real.value

+ 1 - 1
dashboard/src/components/template/Wbw/WbwMeaningSelect.tsx

@@ -54,7 +54,7 @@ const WbwMeaningSelectWidget = ({ data, onSelect }: IWidget) => {
 
   useEffect(() => {
     //判断单词列表里面是否有这个词
-    if (typeof data.real === "undefined") {
+    if (typeof data.real === "undefined" || data.real.value === null) {
       return;
     }
     if (inlineDict.wordIndex.includes(data.real.value)) {

+ 4 - 4
dashboard/src/components/template/Wbw/WbwWord.tsx

@@ -1,5 +1,4 @@
 import { useState, useEffect, useRef } from "react";
-import type { UploadFile } from "antd/es/upload/interface";
 
 import { useAppSelector } from "../../../hooks";
 import { add, updateIndex, wordIndex } from "../../../reducers/inline-dict";
@@ -70,7 +69,7 @@ export interface IWbw {
   para: number;
   sn: number[];
   word: WbwElement<string>;
-  real: WbwElement<string>;
+  real: WbwElement<string | null>;
   meaning?: WbwElement<string | null>;
   type?: WbwElement<string | null>;
   grammar?: WbwElement<string | null>;
@@ -192,7 +191,7 @@ const WbwWordWidget = ({
   };
 
   if (wordData.type?.value === ".ctl.") {
-    if (wordData.word.value.includes("para")) {
+    if (wordData.word.value?.includes("para")) {
       return <WbwPara data={wordData} />;
     } else {
       return <WbwPage data={wordData} />;
@@ -207,7 +206,8 @@ const WbwWordWidget = ({
           if (
             intervalRef.current === null &&
             wordData.real &&
-            wordData.real.value?.length > 0
+            wordData.real.value &&
+            wordData.real.value.length > 0
           ) {
             //开始计时,计时结束查字典
             let words: string[] = [wordData.real.value];

+ 5 - 3
dashboard/src/components/template/WbwSent.tsx

@@ -39,7 +39,7 @@ interface IMagicDictResponse {
 interface IWbwXml {
   id: string;
   pali: WbwElement<string>;
-  real?: WbwElement<string>;
+  real?: WbwElement<string | null>;
   type?: WbwElement<string | null>;
   gramma?: WbwElement<string | null>;
   mean?: WbwElement<string | null>;
@@ -137,10 +137,11 @@ export const WbwSentCtl = ({
         (value) =>
           value.type?.value !== null &&
           value.type?.value !== ".ctl." &&
+          value.real.value &&
           value.real.value.length > 0
       )
       .forEach((value) => {
-        words.set(value.real.value, 1);
+        words.set(value.real.value ? value.real.value : "", 1);
         if (value.parent?.value) {
           words.set(value.parent.value, 1);
         }
@@ -366,7 +367,7 @@ export const WbwSentCtl = ({
         : ["", ""];
 
       wordData.push({
-        word: data.real.value,
+        word: data.real.value ? data.real.value : "",
         type: wordType,
         grammar: wordGrammar,
         mean: data.meaning?.value,
@@ -434,6 +435,7 @@ export const WbwSentCtl = ({
                   value.sn.length === e.sn.length &&
                   e.sn.slice(0, e.sn.length - 1).join() ===
                     value.sn.slice(0, e.sn.length - 1).join() &&
+                  value.real.value &&
                   value.real.value.length > 0
                 ) {
                   return true;