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

Merge pull request #2016 from visuddhinanda/agile

nissaya支持术语
visuddhinanda 2 лет назад
Родитель
Сommit
5f7d50f1ef

+ 2 - 1
dashboard/src/components/dict/SearchVocabulary.tsx

@@ -103,7 +103,7 @@ const SearchVocabularyWidget = ({
       .then((json) => {
         const words: ValueType[] = json.data.rows
           .map((item) => {
-            let weight = item.count / item.strlen;
+            let weight = item.count / (item.strlen - value.length + 0.1);
             if (item.word.length === value.length) {
               weight = 100;
             }
@@ -115,6 +115,7 @@ const SearchVocabularyWidget = ({
             };
           })
           .sort((a, b) => b.weight - a.weight)
+          .slice(0, 7)
           .map((item) => {
             return renderItem(item.word, item.count, item.meaning);
           });

+ 21 - 1
dashboard/src/components/template/Builder/VideoTpl.tsx

@@ -1,9 +1,21 @@
 import { useEffect, useState } from "react";
 import { useIntl } from "react-intl";
-import { Divider, Input, Modal, Select, Space, Tabs, Typography } from "antd";
+import {
+  Button,
+  Divider,
+  Input,
+  Modal,
+  Select,
+  Space,
+  Tabs,
+  Typography,
+} from "antd";
+import { FolderOpenOutlined } from "@ant-design/icons";
 
 import { TDisplayStyle } from "../Article";
 import { VideoCtl } from "../Video";
+import AttachmentDialog from "../../attachment/AttachmentDialog";
+import { IAttachmentRequest } from "../../api/Attachments";
 
 const { TextArea } = Input;
 const { Paragraph } = Typography;
@@ -40,6 +52,14 @@ const VideoTplWidget = ({ url, title, style = "modal" }: IWidget) => {
   return (
     <>
       <Space direction="vertical" style={{ width: 500 }}>
+        <AttachmentDialog
+          trigger={<Button icon={<FolderOpenOutlined />}>网盘</Button>}
+          onSelect={(value: IAttachmentRequest) => {
+            console.debug("VideoTpl onSelect", value);
+            setCurrTitle(value.title);
+            setUrlText(value.url);
+          }}
+        />
         <Space style={{ width: 500 }}>
           {"标题:"}
           <Input

+ 2 - 2
dashboard/src/components/template/MdTpl.tsx

@@ -21,7 +21,7 @@ import Wd from "./Wd";
 interface IWidgetMdTpl {
   tpl?: string;
   props?: string;
-  children?: React.ReactNode;
+  children?: React.ReactNode | React.ReactNode[];
 }
 const Widget = ({ tpl, props, children }: IWidgetMdTpl) => {
   switch (tpl) {
@@ -44,7 +44,7 @@ const Widget = ({ tpl, props, children }: IWidgetMdTpl) => {
     case "article":
       return <Article props={props ? props : ""} />;
     case "nissaya":
-      return <Nissaya props={props ? props : ""} />;
+      return <Nissaya props={props ? props : ""}>{children}</Nissaya>;
     case "toggle":
       return <Toggle props={props ? props : undefined}>{children}</Toggle>;
     case "para":

+ 8 - 5
dashboard/src/components/template/Nissaya.tsx

@@ -7,12 +7,15 @@ import PaliText from "./Wbw/PaliText";
 interface IWidgetNissayaCtl {
   pali?: string;
   meaning?: string;
-  children?: React.ReactNode;
+  lang?: string;
+  children?: React.ReactNode | React.ReactNode[];
 }
-const NissayaCtl = ({ pali, meaning, children }: IWidgetNissayaCtl) => {
+const NissayaCtl = ({ pali, meaning, lang, children }: IWidgetNissayaCtl) => {
   const settings = useAppSelector(settingInfo);
   const layout = GetUserSetting("setting.nissaya.layout.read", settings);
   console.debug("NissayaCtl layout", layout);
+  const isArray = Array.isArray(children);
+  const meaning2 = isArray ? children[1] : "";
   return (
     <span
       style={{
@@ -27,18 +30,18 @@ const NissayaCtl = ({ pali, meaning, children }: IWidgetNissayaCtl) => {
         termToLocal={false}
         style={{ fontWeight: 700 }}
       />{" "}
-      <NissayaMeaning text={meaning} />
+      {lang === "my" ? <NissayaMeaning text={meaning} /> : <>{meaning2}</>}
     </span>
   );
 };
 
 interface IWidget {
   props: string;
-  children?: React.ReactNode;
+  children?: React.ReactNode | React.ReactNode[];
 }
 const Widget = ({ props, children }: IWidget) => {
   const prop = JSON.parse(atob(props)) as IWidgetNissayaCtl;
-  return <NissayaCtl {...prop} />;
+  return <NissayaCtl {...prop}>{children}</NissayaCtl>;
 };
 
 export default Widget;

+ 1 - 1
dashboard/src/components/template/SentEdit/SentCanRead.tsx

@@ -42,7 +42,7 @@ const SentCanReadWidget = ({
   const load = () => {
     const sentId = `${book}-${para}-${wordStart}-${wordEnd}`;
     let url = `/v2/sentence?view=sent-can-read&sentence=${sentId}&type=${type}&mode=edit&html=true`;
-    url += channelsId ? `&channels=${channelsId.join()}` : "";
+    url += channelsId ? `&excludes=${channelsId.join()}` : "";
     console.log("url", url);
     get<ISentenceListResponse>(url)
       .then((json) => {