Просмотр исходного кода

使用新的句子数据结构代替string

visuddhinanda 3 лет назад
Родитель
Сommit
eafdd1193f
1 измененных файлов с 41 добавлено и 39 удалено
  1. 41 39
      dashboard/src/components/template/SentRead.tsx

+ 41 - 39
dashboard/src/components/template/SentRead.tsx

@@ -1,54 +1,56 @@
 import { Tooltip, Button } from "antd";
 import MdView from "./MdView";
+import { ISentence } from "./SentEdit";
 
 interface IWidgetSentReadFrame {
-	origin?: string[];
-	translation?: string[];
-	layout?: "row" | "column";
-	sentId?: string;
+  origin?: ISentence[];
+  translation?: ISentence[];
+  layout?: "row" | "column";
+  sentId?: string;
 }
 const SentReadFrame = ({
-	origin,
-	translation,
-	layout = "column",
-	sentId,
+  origin,
+  translation,
+  layout = "column",
+  sentId,
 }: IWidgetSentReadFrame) => {
-	return (
-		<Tooltip
-			placement="topLeft"
-			color="white"
-			title={
-				<Button type="link" size="small">
-					aa
-				</Button>
-			}
-		>
-			<div style={{ display: "flex", flexDirection: layout }}>
-				<div style={{ flex: "5", color: "#9f3a01" }}>
-					{origin?.map((item, id) => {
-						return <MdView key={id} html={item} />;
-					})}
-				</div>
-				<div style={{ flex: "5" }}>
-					{translation?.map((item, id) => {
-						return <MdView key={id} html={item} />;
-					})}
-				</div>
-			</div>
-		</Tooltip>
-	);
+  return (
+    <Tooltip
+      placement="topLeft"
+      color="white"
+      title={
+        <Button type="link" size="small">
+          aa
+        </Button>
+      }
+    >
+      <div style={{ display: "flex", flexDirection: layout }}>
+        <div style={{ flex: "5", color: "#9f3a01" }}>
+          {origin?.map((item, id) => {
+            return <MdView key={id} html={item.html} />;
+          })}
+        </div>
+        <div style={{ flex: "5" }}>
+          {translation?.map((item, id) => {
+            if (item.html.indexOf("<hr>") >= 0) console.log(item.html);
+            return <MdView key={id} html={item.html} />;
+          })}
+        </div>
+      </div>
+    </Tooltip>
+  );
 };
 
 interface IWidgetTerm {
-	props: string;
+  props: string;
 }
 const Widget = ({ props }: IWidgetTerm) => {
-	const prop = JSON.parse(atob(props)) as IWidgetSentReadFrame;
-	return (
-		<>
-			<SentReadFrame {...prop} />
-		</>
-	);
+  const prop = JSON.parse(atob(props)) as IWidgetSentReadFrame;
+  return (
+    <>
+      <SentReadFrame {...prop} />
+    </>
+  );
 };
 
 export default Widget;