visuddhinanda 3 anni fa
parent
commit
d96fef6f5f

+ 6 - 3
dashboard/src/components/template/Wbw/WbwPali.tsx

@@ -1,5 +1,5 @@
 import { useState } from "react";
 import { useState } from "react";
-import { Popover } from "antd";
+import { Popover, Typography } from "antd";
 import { TagTwoTone, InfoCircleOutlined } from "@ant-design/icons";
 import { TagTwoTone, InfoCircleOutlined } from "@ant-design/icons";
 
 
 import WbwDetail from "./WbwDetail";
 import WbwDetail from "./WbwDetail";
@@ -7,7 +7,7 @@ import { IWbw } from "./WbwWord";
 import { bookMarkColor } from "./WbwDetailBookMark";
 import { bookMarkColor } from "./WbwDetailBookMark";
 import "./wbw.css";
 import "./wbw.css";
 import { PaliReal } from "../../../utils";
 import { PaliReal } from "../../../utils";
-
+const { Paragraph } = Typography;
 interface IWidget {
 interface IWidget {
   data: IWbw;
   data: IWbw;
   onSave?: Function;
   onSave?: Function;
@@ -51,7 +51,10 @@ const Widget = ({ data, onSave }: IWidget) => {
     : "white";
     : "white";
 
 
   const bookMarkIcon = data.bookMarkText ? (
   const bookMarkIcon = data.bookMarkText ? (
-    <Popover content={data.bookMarkText.value} placement="bottom">
+    <Popover
+      content={<Paragraph copyable>{data.bookMarkText.value}</Paragraph>}
+      placement="bottom"
+    >
       <TagTwoTone twoToneColor={color} />
       <TagTwoTone twoToneColor={color} />
     </Popover>
     </Popover>
   ) : (
   ) : (

+ 19 - 2
dashboard/src/components/template/Wbw/WbwWord.tsx

@@ -11,7 +11,7 @@ import WbwPage from "./WbwPage";
 import { useAppSelector } from "../../../hooks";
 import { useAppSelector } from "../../../hooks";
 import { add, wordList } from "../../../reducers/inline-dict";
 import { add, wordList } from "../../../reducers/inline-dict";
 import { get } from "../../../request";
 import { get } from "../../../request";
-import { IApiResponseDictList } from "../../api/Dict";
+import { IApiResponseDictList, IDictDataRequest } from "../../api/Dict";
 import store from "../../../store";
 import store from "../../../store";
 
 
 export type TFieldName =
 export type TFieldName =
@@ -137,8 +137,25 @@ const Widget = ({
     }
     }
     get<IApiResponseDictList>(`/v2/wbwlookup?word=${word}`).then((json) => {
     get<IApiResponseDictList>(`/v2/wbwlookup?word=${word}`).then((json) => {
       console.log("lookup ok", json.data.count);
       console.log("lookup ok", json.data.count);
-      store.dispatch(add([word, json.data.rows]));
+      //扫描结果将结果按照词头分开
+      /*
+      let wordList = new Map<string, IDictDataRequest[]>();
+      for (const word of json.data.rows) {
+        if (!wordList.has(word.word)) {
+          wordList.set(word.word, [word]);
+        } else {
+          const oldValue = wordList.get(word.word);
+          if (typeof oldValue === "undefined") {
+            wordList.set(word.word, [word]);
+          } else {
+            wordList.set(word.word, [...oldValue, word]);
+          }
+        }
+      }
+      store.dispatch(add(wordList));
+	  */
     });
     });
+
     console.log("lookup", word);
     console.log("lookup", word);
   };
   };
   if (wordData.type?.value === ".ctl.") {
   if (wordData.type?.value === ".ctl.") {

+ 18 - 2
dashboard/src/reducers/inline-dict.ts

@@ -22,8 +22,24 @@ export const slice = createSlice({
   name: "inline-dict",
   name: "inline-dict",
   initialState,
   initialState,
   reducers: {
   reducers: {
-    add: (state, action: PayloadAction<[string, IDictDataRequest[]]>) => {
-      state.wordMap.set(action.payload[0], action.payload[1]);
+    add: (state, action: PayloadAction<IDictDataRequest[]>) => {
+      let words: string[] = [];
+      for (const iterator of action.payload) {
+        if (!words.includes(iterator.word)) {
+          words.push(iterator.word);
+        }
+      }
+      /*
+      const keys = action.payload.keys();
+      for (const key in keys) {
+        if (Object.prototype.hasOwnProperty.call(keys, key)) {
+          const value = action.payload.get(key);
+          if (typeof value !== "undefined") {
+            state.wordMap.set(key, value);
+          }
+        }
+      }
+*/
     },
     },
   },
   },
 });
 });