visuddhinanda 2 лет назад
Родитель
Сommit
0345dbb4a1

+ 7 - 0
dashboard/src/components/template/SentEdit/SentCell.tsx

@@ -16,6 +16,7 @@ import SentWbwEdit, { sentSave } from "./SentWbwEdit";
 import { getEnding } from "../../../reducers/nissaya-ending-vocabulary";
 import { nissayaBase } from "../Nissaya/NissayaMeaning";
 import { anchor, message } from "../../../reducers/discussion";
+import TextDiff from "../../general/TextDiff";
 
 interface IWidget {
   initValue?: ISentence;
@@ -24,6 +25,8 @@ interface IWidget {
   isPr?: boolean;
   editMode?: boolean;
   compact?: boolean;
+  showDiff?: boolean;
+  diffText?: string | null;
   onChange?: Function;
 }
 const SentCellWidget = ({
@@ -33,6 +36,8 @@ const SentCellWidget = ({
   isPr = false,
   editMode = false,
   compact = false,
+  showDiff = false,
+  diffText,
   onChange,
 }: IWidget) => {
   const intl = useIntl();
@@ -222,6 +227,8 @@ const SentCellWidget = ({
                   }}
                 />
               )
+            ) : showDiff ? (
+              <TextDiff content={sentData.content} oldContent={diffText} />
             ) : (
               <MdView
                 style={{

+ 21 - 2
dashboard/src/components/template/SentEdit/SuggestionList.tsx

@@ -1,4 +1,4 @@
-import { message, Skeleton } from "antd";
+import { message, Skeleton, Switch } from "antd";
 import { useEffect, useState } from "react";
 
 import { get } from "../../../request";
@@ -11,6 +11,7 @@ interface IWidget {
   para: number;
   wordStart: number;
   wordEnd: number;
+  content?: string | null;
   channel: IChannel;
   enable?: boolean;
   reload?: boolean;
@@ -23,6 +24,7 @@ const SuggestionListWidget = ({
   wordStart,
   wordEnd,
   channel,
+  content,
   reload = false,
   enable = true,
   onReload,
@@ -30,6 +32,7 @@ const SuggestionListWidget = ({
 }: IWidget) => {
   const [sentData, setSentData] = useState<ISentence[]>([]);
   const [loading, setLoading] = useState(false);
+  const [showDiff, setShowDiff] = useState(true);
   const load = () => {
     if (!enable) {
       return;
@@ -83,9 +86,25 @@ const SuggestionListWidget = ({
         <Skeleton />
       ) : (
         <>
+          <div style={{ textAlign: "right" }}>
+            {"文本比对"}
+            <Switch
+              size="small"
+              defaultChecked
+              onChange={(checked) => setShowDiff(checked)}
+            />
+          </div>
           {sentData.length > 0
             ? sentData.map((item, id) => {
-                return <SentCell value={item} key={id} isPr={true} />;
+                return (
+                  <SentCell
+                    value={item}
+                    key={id}
+                    isPr={true}
+                    showDiff={showDiff}
+                    diffText={content}
+                  />
+                );
               })
             : "没有修改建议"}
         </>