Kaynağa Gözat

:fire: 多余的标点符号判断

visuddhinanda 2 yıl önce
ebeveyn
işleme
2480abbde6
1 değiştirilmiş dosya ile 26 ekleme ve 24 silme
  1. 26 24
      dashboard/src/components/template/Wbw/WbwReal.tsx

+ 26 - 24
dashboard/src/components/template/Wbw/WbwReal.tsx

@@ -1,5 +1,6 @@
-import { Tooltip } from "antd";
+import { Space, Tooltip } from "antd";
 import { Typography } from "antd";
+import Lookup from "../../dict/Lookup";
 
 import { IWbw, TWbwDisplayMode } from "./WbwWord";
 
@@ -16,32 +17,33 @@ const WbwFactorsWidget = ({ data, display, onChange }: IWidget) => {
     typeof data.real?.value === "string" &&
     data.real.value.trim().length > 0
   ) {
-    let wordReal = <></>;
-    if (display === "block" || display === "list") {
-      if (
-        typeof data.real?.value === "string" &&
-        data.real.value.trim().length > 0
-      ) {
-        if (display === "block") {
-          const shortString = data.real.value.slice(
-            0,
-            data.word.value.length * 1.3 + 3
-          );
-          if (shortString === data.real.value) {
-            wordReal = <span>{shortString}</span>;
-          } else {
-            wordReal = (
-              <Tooltip title={data.real.value}>{`${shortString}…`}</Tooltip>
-            );
-          }
-        } else {
-          wordReal = <span>{data.real.value}</span>;
-        }
+    let wordReal: React.ReactNode = <></>;
+
+    if (display === "block") {
+      //block 模式下 限制宽度
+      const shortString = data.real.value.slice(
+        0,
+        data.word.value.length * 1.3 + 3
+      );
+      if (shortString === data.real.value) {
+        wordReal = <span>{shortString}</span>;
       } else {
-        //空白的意思在逐词解析模式显示占位字符串
-        wordReal = <Text type="secondary">real</Text>;
+        wordReal = (
+          <Tooltip title={data.real.value}>{`${shortString}…`}</Tooltip>
+        );
       }
+    } else {
+      wordReal = (
+        <Space>
+          {data.real.value.split(" ").map((item, index) => (
+            <Lookup search={item} key={index}>
+              <Text type="secondary">{item}</Text>
+            </Lookup>
+          ))}
+        </Space>
+      );
     }
+
     return (
       <div className="wbw_word_item">
         <Text type="secondary">{wordReal}</Text>