Ver Fonte

Merge pull request #2208 from visuddhinanda/agile

add ref
visuddhinanda há 1 ano atrás
pai
commit
05360690b9

+ 49 - 11
dashboard/src/components/article/ToolButtonSearch.tsx

@@ -1,23 +1,61 @@
 import { SearchOutlined } from "@ant-design/icons";
 import { SearchOutlined } from "@ant-design/icons";
 
 
 import ToolButton from "./ToolButton";
 import ToolButton from "./ToolButton";
+import { Input, Tree, TreeDataNode } from "antd";
+import { useSearchParams } from "react-router-dom";
+import { ArticleType } from "./Article";
+import { get } from "../../request";
+import { IArticleFtsListResponse } from "../api/Article";
+import { Key } from "antd/lib/table/interface";
+import { useState } from "react";
+
+const { Search } = Input;
 
 
 interface IWidget {
 interface IWidget {
-  type?: string;
+  type?: ArticleType;
   articleId?: string;
   articleId?: string;
+  anthologyId?: string;
+  channels?: string[];
 }
 }
-const ToolButtonSearchWidget = ({ type, articleId }: IWidget) => {
-  const id = articleId?.split("_");
-  let tocWidget = <></>;
-  if (id && id.length > 0) {
-    const sentId = id[0].split("-");
-    if (sentId.length > 1) {
-      tocWidget = <></>;
-    }
-  }
+const ToolButtonSearchWidget = ({
+  type,
+  articleId,
+  anthologyId,
+  channels,
+}: IWidget) => {
+  const [searchParams, setSearchParams] = useSearchParams();
+  const [treeNode, setTreeNode] = useState<TreeDataNode[]>();
+  const content = (
+    <>
+      <Search
+        placeholder="搜索本章节"
+        onSearch={(
+          value: string,
+          event?:
+            | React.ChangeEvent<HTMLInputElement>
+            | React.MouseEvent<HTMLElement, MouseEvent>
+            | React.KeyboardEvent<HTMLInputElement>
+            | undefined
+        ) => {
+          if (type === "article") {
+            let url = `/v2/article-fts?id=${articleId}&anthology=${anthologyId}&key=${value}`;
+            url += "&channel=" + channels?.join(",");
+            console.debug("api request", url);
+            get<IArticleFtsListResponse>(url).then((json) => {
+              console.debug("api response", json);
+              if (json.ok) {
+              }
+            });
+          }
+        }}
+        style={{ width: "100%" }}
+      />
+      <Tree onSelect={(selectedKeys: Key[]) => {}} treeData={treeNode} />
+    </>
+  );
 
 
   return (
   return (
-    <ToolButton title="搜索" icon={<SearchOutlined />} content={tocWidget} />
+    <ToolButton title="搜索" icon={<SearchOutlined />} content={content} />
   );
   );
 };
 };
 
 

+ 20 - 4
dashboard/src/components/export/ExportModal.tsx

@@ -176,21 +176,37 @@ const ExportModalWidget = ({
             bordered={false}
             bordered={false}
             options={[
             options={[
               {
               {
-                value: "markdown",
-                label: "Markdown",
+                value: "docx",
+                label: "Word",
               },
               },
               {
               {
                 value: "pdf",
                 value: "pdf",
                 label: "PDF",
                 label: "PDF",
               },
               },
               {
               {
-                value: "docx",
-                label: "Word",
+                value: "epub",
+                label: "epub电子书",
+              },
+              {
+                value: "markdown",
+                label: "Markdown",
               },
               },
               {
               {
                 value: "html",
                 value: "html",
                 label: "Html",
                 label: "Html",
               },
               },
+              {
+                value: "pptx",
+                label: "PPT幻灯片",
+              },
+              {
+                value: "txt",
+                label: "Text纯文本",
+              },
+              {
+                value: "tex",
+                label: "LaTex",
+              },
             ]}
             ]}
             onSelect={(value) => setFormat(value)}
             onSelect={(value) => setFormat(value)}
           />
           />

+ 3 - 0
dashboard/src/components/template/MdTpl.tsx

@@ -10,6 +10,7 @@ import ParaShell from "./ParaShell";
 import Qa from "./Qa";
 import Qa from "./Qa";
 import Quote from "./Quote";
 import Quote from "./Quote";
 import QuoteLink from "./QuoteLink";
 import QuoteLink from "./QuoteLink";
+import Reference from "./Reference";
 import SentEdit from "./SentEdit";
 import SentEdit from "./SentEdit";
 import SentRead from "./SentRead";
 import SentRead from "./SentRead";
 import Term from "./Term";
 import Term from "./Term";
@@ -63,6 +64,8 @@ const Widget = ({ tpl, props, children }: IWidgetMdTpl) => {
       return <Video props={props ? props : ""} />;
       return <Video props={props ? props : ""} />;
     case "grammar":
     case "grammar":
       return <GrammarTermLookup props={props ? props : ""} />;
       return <GrammarTermLookup props={props ? props : ""} />;
+    case "reference":
+      return <Reference props={props ? props : ""} />;
     default:
     default:
       return <>未定义模版({tpl})</>;
       return <>未定义模版({tpl})</>;
   }
   }

+ 54 - 0
dashboard/src/components/template/Reference.tsx

@@ -0,0 +1,54 @@
+import { Typography } from "antd";
+import { useIntl } from "react-intl";
+
+const { Text, Paragraph } = Typography;
+
+const ucFirst = (input: string) => {
+  if (typeof input !== "string" || input.length === 0) {
+    return input; // 如果输入不是字符串或者字符串为空,则直接返回原值
+  }
+  return input.charAt(0).toUpperCase() + input.slice(1);
+};
+
+interface IReference {
+  sn: number;
+  title: string;
+  copyright: string;
+}
+
+interface IReferenceCtl {
+  pali?: IReference[];
+}
+const ReferenceCtl = ({ pali }: IReferenceCtl) => {
+  const intl = useIntl();
+
+  const Reference = (ref: IReference) => {
+    return (
+      <Paragraph>{`[${ref.sn}] ${ucFirst(ref.title)} ${
+        ref.copyright
+      }`}</Paragraph>
+    );
+  };
+  return (
+    <>
+      {pali?.map((item, id) => {
+        return Reference(item);
+      })}
+    </>
+  );
+};
+
+interface IWidget {
+  props: string;
+}
+const Widget = ({ props }: IWidget) => {
+  const prop = JSON.parse(atob(props)) as IReferenceCtl;
+  console.log(prop);
+  return (
+    <>
+      <ReferenceCtl {...prop} />
+    </>
+  );
+};
+
+export default Widget;