Quellcode durchsuchen

Merge pull request #2186 from visuddhinanda/agile

缅文语尾本词特征点击在侧边语法手册中打开
visuddhinanda vor 1 Jahr
Ursprung
Commit
4fc2f33efd

+ 1 - 1
dashboard/src/components/discussion/DiscussionButton.tsx

@@ -74,7 +74,7 @@ const DiscussionButton = ({
     );
     );
   }
   }
 
 
-  console.debug("DiscussionButton", discussions, wbw, withStudent);
+  //console.debug("DiscussionButton", discussions, wbw, withStudent);
 
 
   let currCount = CommentCount;
   let currCount = CommentCount;
   if (onlyMe) {
   if (onlyMe) {

+ 3 - 2
dashboard/src/components/general/NissayaCard.tsx

@@ -105,10 +105,11 @@ const NissayaCardWidget = ({
     }
     }
 
 
     const url = `/v2/nissaya-card/${text}?lang=${uiLang}&content_type=json`;
     const url = `/v2/nissaya-card/${text}?lang=${uiLang}&content_type=json`;
-    console.log("url", url);
+    console.debug("api request", url);
     setLoading(true);
     setLoading(true);
     get<INissayaCardResponse>(url)
     get<INissayaCardResponse>(url)
       .then((json) => {
       .then((json) => {
+        console.debug("api response", json);
         if (json.ok) {
         if (json.ok) {
           setCardData(json.data.row);
           setCardData(json.data.row);
           setTerm(json.data.ending);
           setTerm(json.data.ending);
@@ -169,7 +170,7 @@ const NissayaCardWidget = ({
       </div>
       </div>
       <Paragraph>{term?.meaning}</Paragraph>
       <Paragraph>{term?.meaning}</Paragraph>
       <MdView html={term?.html} />
       <MdView html={term?.html} />
-      {cardData ? <NissayaCardTable data={cardData} /> : undefined}
+      {cardData ? <NissayaCardTable data={cardData} /> : <></>}
     </div>
     </div>
   );
   );
 };
 };

+ 14 - 16
dashboard/src/components/general/NissayaCardTable.tsx

@@ -12,6 +12,7 @@ const randomString = () =>
 
 
 interface ICaseItem {
 interface ICaseItem {
   label: string;
   label: string;
+  case: string;
   link: string;
   link: string;
 }
 }
 interface IRelationNode {
 interface IRelationNode {
@@ -42,12 +43,11 @@ interface IWidget {
   data?: INissayaRelation[];
   data?: INissayaRelation[];
 }
 }
 const NissayaCardTableWidget = ({ data }: IWidget) => {
 const NissayaCardTableWidget = ({ data }: IWidget) => {
-  const [tableData, setTableData] = useState<DataType[]>();
-  useEffect(() => {
-    if (typeof data === "undefined") {
-      setTableData(undefined);
-      return;
-    }
+  let tableData: DataType[] = [];
+
+  if (typeof data === "undefined") {
+    tableData = [];
+  } else {
     console.log("data", data);
     console.log("data", data);
     let category: string[] = [];
     let category: string[] = [];
     let newData: DataType[] = [];
     let newData: DataType[] = [];
@@ -104,8 +104,9 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
       }
       }
     });
     });
     console.log("newData", newData);
     console.log("newData", newData);
-    setTableData(newData);
-  }, [data]);
+    tableData = newData;
+  }
+
   return (
   return (
     <Table
     <Table
       size="small"
       size="small"
@@ -120,14 +121,11 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
               <Space>
               <Space>
                 {record.from?.case?.map((item, id) => {
                 {record.from?.case?.map((item, id) => {
                   return (
                   return (
-                    <Button
-                      key={id}
-                      type="link"
-                      size="small"
-                      onClick={() => window.open(item.link, "_blank")}
-                    >
-                      <Tag>{item.label}</Tag>
-                    </Button>
+                    <GrammarLookup key={id} word={item.case}>
+                      <Link>
+                        <Tag>{item.label}</Tag>
+                      </Link>
+                    </GrammarLookup>
                   );
                   );
                 })}
                 })}
                 {record.from?.spell}
                 {record.from?.spell}

+ 0 - 2
dashboard/src/components/tag/TagSelectButton.tsx

@@ -33,8 +33,6 @@ const TagSelectButtonWidget = ({
   const studioName =
   const studioName =
     course?.course?.studio?.realName ?? user?.nickName ?? undefined;
     course?.course?.studio?.realName ?? user?.nickName ?? undefined;
 
 
-  console.debug("TagSelectButton studioName", studioName);
-
   return (
   return (
     <TagsManager
     <TagsManager
       title={selectorTitle}
       title={selectorTitle}

+ 36 - 3
dashboard/src/components/template/Wbw/RelaGraphic.tsx

@@ -1,4 +1,5 @@
 import { Typography } from "antd";
 import { Typography } from "antd";
+import { useIntl } from "react-intl";
 
 
 import Mermaid from "../../general/Mermaid";
 import Mermaid from "../../general/Mermaid";
 import { useAppSelector } from "../../../hooks";
 import { useAppSelector } from "../../../hooks";
@@ -6,7 +7,10 @@ import { getGrammar } from "../../../reducers/term-vocabulary";
 import { IWbwRelation } from "./WbwDetailRelation";
 import { IWbwRelation } from "./WbwDetailRelation";
 import { IWbw } from "./WbwWord";
 import { IWbw } from "./WbwWord";
 import { relationWordId } from "./WbwRelationAdd";
 import { relationWordId } from "./WbwRelationAdd";
-import { useIntl } from "react-intl";
+import store from "../../../store";
+import { openPanel } from "../../../reducers/right-panel";
+import { grammar } from "../../../reducers/command";
+import { fullUrl } from "../../../utils";
 
 
 const { Text } = Typography;
 const { Text } = Typography;
 
 
@@ -27,6 +31,32 @@ const RelaGraphicWidget = ({ wbwData }: IWidget) => {
   const terms = useAppSelector(getGrammar);
   const terms = useAppSelector(getGrammar);
   const intl = useIntl();
   const intl = useIntl();
 
 
+  const onLoad = () => {
+    const links = document.getElementsByTagName("a");
+    alert(links.length + "links");
+    // 为每个链接添加点击事件监听器
+    for (let i = 0; i < links.length; i++) {
+      (function (index) {
+        links[index].addEventListener("click", function (e) {
+          // 阻止链接的默认点击行为
+          e.preventDefault();
+          // 在这里执行你想在点击链接时执行的代码
+          console.log("链接被点击: ", this.href);
+          alert("链接被点击" + this.href);
+          const iPos = this.href.lastIndexOf("grammar/");
+          if (iPos >= 0) {
+            const word = this.href.substring(iPos + 8);
+            console.debug("relation graphic", word);
+            store.dispatch(grammar(word));
+            store.dispatch(openPanel("grammar"));
+          } else {
+            window.location.href = this.href;
+          }
+        });
+      })(i);
+    }
+  };
+
   const grammarStr = (input?: string | null) => {
   const grammarStr = (input?: string | null) => {
     if (!input) {
     if (!input) {
       return "";
       return "";
@@ -75,9 +105,12 @@ const RelaGraphicWidget = ({ wbwData }: IWidget) => {
               (value: IWbw) => relationWordId(value) === relation.dest_id
               (value: IWbw) => relationWordId(value) === relation.dest_id
             );
             );
             const toMeaning = pureMeaning(toWord?.meaning?.value);
             const toMeaning = pureMeaning(toWord?.meaning?.value);
+            const url = fullUrl("/term/list/" + relation.relation);
             const toGrammar = grammarStr(toWord?.case?.value);
             const toGrammar = grammarStr(toWord?.case?.value);
-
-            return `${relation.sour_id}("${relation.sour_spell}<br />${fromMeaning}<br />${fromGrammar}") --"${relation.relation}<br />${localName}"--> ${relation.dest_id}("${relation.dest_spell}<br />${toMeaning}<br />${toGrammar}")\n`;
+            const strFrom = `${relation.sour_id}("${relation.sour_spell}<br />${fromMeaning}<br />${fromGrammar}")`;
+            const strRelation = `"<a href='${url}' target='_blank'>${relation.relation}</a><br />${localName}"`;
+            const strTo = `${relation.dest_id}("${relation.dest_spell}<br />${toMeaning}<br />${toGrammar}")`;
+            return `${strFrom} --${strRelation}--> ${strTo}\n`;
           });
           });
           return graphic.join("");
           return graphic.join("");
         } else {
         } else {

+ 1 - 6
dashboard/src/components/template/Wbw/WbwDetailRelation.tsx

@@ -123,13 +123,12 @@ const WbwDetailRelationWidget = ({
         grammar = [data.grammar2?.value.replaceAll(".", "")];
         grammar = [data.grammar2?.value.replaceAll(".", "")];
       }
       }
     }
     }
-    console.log("relation match grammar", grammar);
     if (typeof grammar === "undefined") {
     if (typeof grammar === "undefined") {
       return;
       return;
     }
     }
 
 
     //找出符合条件的relation
     //找出符合条件的relation
-    console.debug("relation match data=", data);
+
     const filteredRelation = relations?.filter((value) => {
     const filteredRelation = relations?.filter((value) => {
       let caseMatch = true;
       let caseMatch = true;
       let spellMatch = true;
       let spellMatch = true;
@@ -159,12 +158,8 @@ const WbwDetailRelationWidget = ({
         // 使用正则表达式
         // 使用正则表达式
         spellMatch = regex.test(data.real.value);
         spellMatch = regex.test(data.real.value);
       }
       }
-
-      console.debug("relation match", value, caseMatch, spellMatch);
-
       return caseMatch && spellMatch;
       return caseMatch && spellMatch;
     });
     });
-    console.debug("relation match filteredRelation=", filteredRelation);
 
 
     setCurrRelation(filteredRelation);
     setCurrRelation(filteredRelation);
     setRelationOptions(filteredRelation);
     setRelationOptions(filteredRelation);

+ 0 - 4
dashboard/src/components/template/Wbw/WbwPali.tsx

@@ -108,8 +108,6 @@ const WbwPaliWidget = ({
    * 高亮可能的单词
    * 高亮可能的单词
    */
    */
   useEffect(() => {
   useEffect(() => {
-    console.debug("relation match data=", data);
-
     let grammar = data.case?.value
     let grammar = data.case?.value
       ?.replace("v:ind", "v")
       ?.replace("v:ind", "v")
       .replace("#", "$")
       .replace("#", "$")
@@ -150,8 +148,6 @@ const WbwPaliWidget = ({
           spellMatch = false;
           spellMatch = false;
         }
         }
       }
       }
-      console.debug("relation match", value, caseMatch, spellMatch);
-
       return caseMatch && spellMatch;
       return caseMatch && spellMatch;
     });
     });
     if (match && match.length > 0) {
     if (match && match.length > 0) {