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

Merge branch 'agile' of https://github.com/iapt-platform/mint into agile

bhikkhu-kosalla-china 1 год назад
Родитель
Сommit
b37c0fb227

+ 7 - 3
dashboard/src/components/discussion/DiscussionButton.tsx

@@ -10,11 +10,15 @@ import { discussionList } from "../../reducers/discussion-count";
 import { IDiscussionCountData, IDiscussionCountWbw } from "../api/Comment";
 import { useEffect, useState } from "react";
 
-export const openDiscussion = (resId: string, withStudent: boolean) => {
+export const openDiscussion = (
+  resId: string,
+  resType: TResType,
+  withStudent: boolean
+) => {
   const data: IShowDiscussion = {
     type: "discussion",
     resId: resId,
-    resType: "sentence",
+    resType: resType,
     withStudent: withStudent,
   };
   console.debug("discussion show", data);
@@ -107,7 +111,7 @@ const DiscussionButton = ({
         }}
         onClick={(event) => {
           if (resId) {
-            openDiscussion(resId, wbw ? true : false);
+            openDiscussion(resId, resType, wbw ? true : false);
           }
         }}
       >

+ 19 - 14
dashboard/src/components/general/NissayaCardTable.tsx

@@ -1,8 +1,11 @@
-import { Button, Space, Table, Tag } from "antd";
+import { Button, Space, Table, Tag, Typography } from "antd";
 import lodash from "lodash";
 import { useEffect, useState } from "react";
 import { ArrowRightOutlined } from "@ant-design/icons";
 import Marked from "./Marked";
+import GrammarLookup from "../dict/GrammarLookup";
+
+const { Link } = Typography;
 
 const randomString = () =>
   lodash.times(20, () => lodash.random(35).toString(36)).join("");
@@ -111,7 +114,7 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
           title: "本词特征",
           dataIndex: "from",
           key: "from",
-          width: 40,
+          width: "10%",
           render: (value, record, index) => {
             return (
               <Space>
@@ -136,12 +139,14 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
           title: "关系",
           dataIndex: "relation",
           key: "relation",
-          width: "22%",
+          width: "30%",
           render: (value, record, index) => {
             return (
-              <Space>
-                {record.relation}
-                {record.localRelation}
+              <Space direction="vertical">
+                <GrammarLookup word={record.relation}>
+                  <Link>{record.relation}</Link>
+                </GrammarLookup>
+                <div>{record.localRelation}</div>
               </Space>
             );
           },
@@ -150,6 +155,7 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
           title: "目标词特征",
           dataIndex: "to",
           key: "to",
+          width: "20%",
           render: (value, record, index) => {
             if (record.isChildren) {
               return (
@@ -183,22 +189,21 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
         {
           title: "含义",
           dataIndex: "address",
-          width: "30%",
+          width: "40%",
           key: "address",
           render: (value, record, index) => {
             if (record.isChildren) {
               return undefined;
             } else {
-              return <Marked text={record.category?.note} />;
+              return (
+                <div>
+                  <Marked text={record.category?.note} />
+                  <div>{record.translation}</div>
+                </div>
+              );
             }
           },
         },
-        {
-          title: "翻译建议",
-          dataIndex: "translation",
-          width: "20%",
-          key: "translation",
-        },
       ]}
       dataSource={tableData}
     />

+ 1 - 1
dashboard/src/components/template/SentRead.tsx

@@ -174,7 +174,7 @@ const SentReadFrame = ({
                         break;
                       case "discussion":
                         if (item.id) {
-                          openDiscussion(item.id, false);
+                          openDiscussion(item.id, "sentence", false);
                         }
                         break;
                       case "pr":

+ 2 - 1
dashboard/src/components/template/Wbw/WbwDetailRelation.tsx

@@ -111,7 +111,8 @@ const WbwDetailRelationWidget = ({
 
   useEffect(() => {
     let grammar = data.case?.value
-      ?.replace("#", "$")
+      ?.replace("v:ind", "v")
+      .replace("#", "$")
       .replace(":", "$")
       .replaceAll(".", "")
       .split("$");

+ 2 - 1
dashboard/src/components/template/Wbw/WbwPali.tsx

@@ -111,7 +111,8 @@ const WbwPaliWidget = ({
     console.debug("relation match data=", data);
 
     let grammar = data.case?.value
-      ?.replace("#", "$")
+      ?.replace("v:ind", "v")
+      .replace("#", "$")
       .replace(":", "$")
       .replaceAll(".", "")
       .split("$");

+ 47 - 1
dashboard/src/components/template/WbwSent.tsx

@@ -4,7 +4,7 @@ import { MoreOutlined, ExclamationCircleOutlined } from "@ant-design/icons";
 
 import { useAppSelector } from "../../hooks";
 import { mode as _mode } from "../../reducers/article-mode";
-import { get, post } from "../../request";
+import { delete_, get, post } from "../../request";
 import { ArticleMode } from "../article/Article";
 import WbwWord, {
   IWbw,
@@ -30,6 +30,7 @@ import TimeShow from "../general/TimeShow";
 import moment from "moment";
 import { courseInfo } from "../../reducers/current-course";
 import { ISentenceWbwListResponse } from "../api/Corpus";
+import { IDeleteResponse } from "../api/Article";
 
 export const getWbwProgress = (data: IWbw[], answer?: IWbw[]) => {
   //计算完成度
@@ -774,6 +775,28 @@ export const WbwSentCtl = ({
     }
   });
 
+  const deleteWbw = () => {
+    const url = `/v2/wbw-sentence/${book}-${para}-${wordStart}-${wordEnd}?channel=${channelId}`;
+    console.info("api request", url);
+    setLoading(true);
+    delete_<IDeleteResponse>(url)
+      .then((json) => {
+        console.debug("api response", json);
+        if (json.ok) {
+          message.success(
+            intl.formatMessage(
+              { id: "message.delete.success" },
+              { count: json.data }
+            )
+          );
+        } else {
+          message.error(json.message);
+        }
+      })
+      .finally(() => setLoading(false))
+      .catch((e) => console.log("Oops errors!", e));
+  };
+
   return (
     <div style={{ width: "100%" }}>
       <div
@@ -828,6 +851,17 @@ export const WbwSentCtl = ({
                 }),
                 danger: true,
               },
+              {
+                type: "divider",
+              },
+              {
+                key: "delete",
+                label: intl.formatMessage({
+                  id: "buttons.delete.wbw.sentence",
+                }),
+                danger: true,
+                disabled: true,
+              },
             ],
             onClick: ({ key }) => {
               console.log(`Click on item ${key}`);
@@ -870,6 +904,18 @@ export const WbwSentCtl = ({
                     },
                   });
                   break;
+                case "delete":
+                  modal.confirm({
+                    title: "清除逐词解析数据",
+                    icon: <ExclamationCircleOutlined />,
+                    content: "删除整句的逐词解析数据,此操作不可恢复",
+                    okText: "确认",
+                    cancelText: "取消",
+                    onOk: () => {
+                      deleteWbw();
+                    },
+                  });
+                  break;
               }
             },
           }}

+ 1 - 1
dashboard/src/components/term/GrammarBook.tsx

@@ -129,7 +129,7 @@ const GrammarBookWidget = () => {
                 let weight = 0;
                 const wordBegin = item.word
                   .toLocaleLowerCase()
-                  .indexOf(keyWord);
+                  .indexOf(keyWord.toLocaleLowerCase());
                 if (wordBegin >= 0) {
                   weight += (1 / (wordBegin + 1)) * 1000;
                   const wordRemain =

+ 1 - 0
dashboard/src/locales/en-US/buttons.ts

@@ -93,6 +93,7 @@ const items = {
   "buttons.select.channel": "Select Channel",
   "buttons.set.display.mode": "Display Mode",
   "buttons.manage": "Manage",
+  "buttons.delete.wbw.sentence": "Delete Wbw",
 };
 
 export default items;

+ 1 - 0
dashboard/src/locales/en-US/message.ts

@@ -14,6 +14,7 @@ const items = {
   "message.password.reset": "please set new password",
   "message.get.token.fail": "get token fail",
   "message.confirm-password.validate.fail": "password validate fail",
+  "message.delete.success": "delete record {count}",
 };
 
 export default items;

+ 1 - 0
dashboard/src/locales/zh-Hans/buttons.ts

@@ -93,6 +93,7 @@ const items = {
   "buttons.select.channel": "选择版本风格",
   "buttons.set.display.mode": "显示模式",
   "buttons.manage": "管理",
+  "buttons.delete.wbw.sentence": "删除整句逐词解析",
 };
 
 export default items;

+ 1 - 0
dashboard/src/locales/zh-Hans/message.ts

@@ -14,6 +14,7 @@ const items = {
   "message.password.reset": "请设置新的密码",
   "message.get.token.fail": "获取token失败",
   "message.confirm-password.validate.fail": "两次密码不一致",
+  "message.delete.success": "成功删除{count}条数据",
 };
 
 export default items;