Browse Source

从/v2/corpus-sent获取句子块

visuddhinanda 2 years ago
parent
commit
11ae168867
1 changed files with 10 additions and 2 deletions
  1. 10 2
      dashboard/src/components/discussion/DiscussionAnchor.tsx

+ 10 - 2
dashboard/src/components/discussion/DiscussionAnchor.tsx

@@ -1,5 +1,6 @@
 import { useEffect, useState } from "react";
 import { useEffect, useState } from "react";
 import { get } from "../../request";
 import { get } from "../../request";
+import { IArticleResponse } from "../api/Article";
 import { ICommentAnchorResponse } from "../api/Comment";
 import { ICommentAnchorResponse } from "../api/Comment";
 import { ISentenceResponse } from "../api/Corpus";
 import { ISentenceResponse } from "../api/Corpus";
 import MdView from "../template/MdView";
 import MdView from "../template/MdView";
@@ -31,11 +32,18 @@ const DiscussionAnchorWidget = ({ resId, resType, topicId }: IWidget) => {
       case "sentence":
       case "sentence":
         get<ISentenceResponse>(`/v2/sentence/${resId}`).then((json) => {
         get<ISentenceResponse>(`/v2/sentence/${resId}`).then((json) => {
           if (json.ok) {
           if (json.ok) {
-            setContent(json.data.html);
+            const id = `${json.data.book}-${json.data.paragraph}-${json.data.word_start}-${json.data.word_end}`;
+            const channel = json.data.channel.id;
+            const url = `/v2/corpus-sent/${id}?mode=edit&channels=${channel}`;
+            console.log("url", url);
+            get<IArticleResponse>(url).then((json) => {
+              if (json.ok) {
+                setContent(json.data.content);
+              }
+            });
           }
           }
         });
         });
         break;
         break;
-
       default:
       default:
         break;
         break;
     }
     }