Browse Source

Merge pull request #2164 from visuddhinanda/agile

添加相似句channel支持
visuddhinanda 1 year ago
parent
commit
f9a68fc7df

+ 2 - 1
dashboard/src/components/api/Channel.ts

@@ -5,7 +5,8 @@ export type TChannelType =
   | "nissaya"
   | "original"
   | "wbw"
-  | "commentary";
+  | "commentary"
+  | "similar";
 export interface IChannelApiData {
   id: string;
   name: string;

+ 4 - 0
dashboard/src/components/channel/ChannelTypeSelect.tsx

@@ -25,6 +25,10 @@ const ChannelTypeSelectWidget = ({ readonly }: IWidget) => {
       value: "original",
       label: intl.formatMessage({ id: "channel.type.original.label" }),
     },
+    {
+      value: "similar",
+      label: intl.formatMessage({ id: "channel.type.similar.label" }),
+    },
   ];
   return (
     <ProFormSelect

+ 12 - 0
dashboard/src/components/template/SentEdit/SentSim.tsx

@@ -5,6 +5,7 @@ import { ReloadOutlined } from "@ant-design/icons";
 import { get } from "../../../request";
 import { ISentenceSimListResponse, ISimSent } from "../../api/Corpus";
 import MdView from "../MdView";
+import SentCanRead from "./SentCanRead";
 
 interface IWidget {
   book: number;
@@ -15,6 +16,7 @@ interface IWidget {
   limit?: number;
   reload?: boolean;
   onReload?: Function;
+  onCreate?: Function;
 }
 const SentSimWidget = ({
   book,
@@ -25,6 +27,7 @@ const SentSimWidget = ({
   channelsId,
   reload = false,
   onReload,
+  onCreate,
 }: IWidget) => {
   const [initLoading, setInitLoading] = useState(true);
   const [loading, setLoading] = useState(false);
@@ -66,6 +69,15 @@ const SentSimWidget = ({
 
   return (
     <>
+      <SentCanRead
+        book={book}
+        para={para}
+        wordStart={wordStart}
+        wordEnd={wordEnd}
+        type="similar"
+        channelsId={channelsId}
+        onCreate={onCreate}
+      />
       <List
         loading={initLoading}
         header={

+ 3 - 1
dashboard/src/components/template/SentEdit/SentTab.tsx

@@ -77,6 +77,7 @@ const SentTabWidget = ({
   const [currTranNum, setCurrTranNum] = useState(tranNum);
   const [currNissayaNum, setCurrNissayaNum] = useState(nissayaNum);
   const [currCommNum, setCurrCommNum] = useState(commNum);
+  const [currSimilarNum, setCurrSimilarNum] = useState(simNum);
   const [showWbwProgress, setShowWbwProgress] = useState(false);
 
   console.log("SentTabWidget render");
@@ -333,7 +334,7 @@ const SentTabWidget = ({
               icon={<BlockOutlined />}
               type="original"
               sentId={id}
-              count={simNum}
+              count={currSimilarNum}
               title={intl.formatMessage({
                 id: "buttons.sim",
               })}
@@ -348,6 +349,7 @@ const SentTabWidget = ({
               wordEnd={parseInt(sId[3])}
               channelsId={channelsId}
               limit={5}
+              onCreate={() => setCurrSimilarNum((origin) => origin + 1)}
             />
           ),
         },

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

@@ -13,6 +13,7 @@ const items = {
   "channel.fields.lang.label": "语言",
   "channel.fields.type.label": "类型",
   "channel.fields.name.label": "名称",
+  "channel.type.similar.label": "Similar",
 };
 
 export default items;

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

@@ -13,6 +13,7 @@ const items = {
   "channel.fields.lang.label": "语言",
   "channel.fields.type.label": "类型",
   "channel.fields.name.label": "名称",
+  "channel.type.similar.label": "相似句",
 };
 
 export default items;