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

Merge pull request #1888 from visuddhinanda/agile

支持章节模式
visuddhinanda 2 лет назад
Родитель
Сommit
50ffcd47f6

+ 1 - 0
dashboard/src/components/discussion/DiscussionCreate.tsx

@@ -77,6 +77,7 @@ const DiscussionCreateWidget = ({
         <div>
           <ProForm<IComment>
             formRef={formRef}
+            autoFocusFirstInput={false}
             onFinish={async (values) => {
               //新建
               console.log("create", resId, resType, currParent, topic);

+ 6 - 0
dashboard/src/components/template/Article.tsx

@@ -11,6 +11,8 @@ export type TDisplayStyle = "modal" | "card" | "toggle" | "link";
 interface IWidgetChapterCtl {
   type?: ArticleType;
   id?: string;
+  book?: string;
+  paragraphs?: string;
   channel?: string;
   title?: React.ReactNode;
   focus?: string | null;
@@ -24,6 +26,8 @@ export const ArticleCtl = ({
   channel,
   title,
   focus,
+  book,
+  paragraphs,
   style = "modal",
   modalExtra,
 }: IWidgetChapterCtl) => {
@@ -45,6 +49,8 @@ export const ArticleCtl = ({
       active={true}
       type={type}
       articleId={id}
+      book={book}
+      para={paragraphs}
       channelId={channel}
       focus={focus}
       mode="read"

+ 9 - 0
dashboard/src/components/template/ParaHandle.tsx

@@ -46,6 +46,12 @@ export const ParaHandleCtl = ({
         id: "labels.curr.paragraph.copy.quote.link.tpl",
       }),
       children: [
+        {
+          key: "quote-link-tpl-c",
+          label: intl.formatMessage({
+            id: "labels.page.number.type.c",
+          }),
+        },
         {
           key: "quote-link-tpl-m",
           label: intl.formatMessage({
@@ -97,6 +103,9 @@ export const ParaHandleCtl = ({
       case "copy-sent":
         copyToClipboard(sentences.map((item) => `{{${item}}}`).join(""));
         break;
+      case "quote-link-tpl-c":
+        copyToClipboard(`{{ql|type=c|book=${book}|para=${para}}}`);
+        break;
       case "quote-link-tpl-m":
         copyToClipboard(`{{ql|type=m|book=${book}|para=${para}}}`);
         break;

+ 20 - 5
dashboard/src/components/template/QuoteLink.tsx

@@ -16,6 +16,7 @@ interface IWidgetQuoteLinkCtl {
   para?: number;
   term?: IWidgetTermCtl;
   title?: string;
+  chapter?: string;
   found: boolean;
 }
 const QuoteLinkCtl = ({
@@ -28,12 +29,21 @@ const QuoteLinkCtl = ({
   para,
   term,
   title,
+  chapter,
   found,
 }: IWidgetQuoteLinkCtl) => {
-  const [validPage, setValidPage] = useState(false);
   const [tpl, setTpl] = useState<string>();
   let textShow = volume === 0 ? page : ` ${volume}.${page}`;
+  if (type === "c") {
+    textShow = ` ${chapter}`;
+  }
   console.debug("found", found);
+  useEffect(() => {
+    if (type === "c") {
+      setTpl(`{{ql|type=${type}|book=${book}|para=${para}}}`);
+    }
+  }, [book, para, type]);
+
   useEffect(() => {
     if (
       typeof type !== "undefined" &&
@@ -41,7 +51,6 @@ const QuoteLinkCtl = ({
       typeof volume !== "undefined" &&
       typeof page !== "undefined"
     ) {
-      setValidPage(found);
       setTpl(
         `{{ql|type=${type}|bookname=${bookName}|volume=${volume}|page=${page}}}`
       );
@@ -50,8 +59,10 @@ const QuoteLinkCtl = ({
 
   return (
     <>
-      {validPage ? (
+      {found ? (
         <ArticleCtl
+          book={book?.toString()}
+          paragraphs={para?.toString()}
           title={
             title ? (
               title
@@ -62,9 +73,13 @@ const QuoteLinkCtl = ({
               </>
             )
           }
-          type={"page"}
+          type={type === "c" ? "para" : "page"}
           focus={book && para ? `${book}-${para}` : undefined}
-          id={`${type}_${bookName}_${volume}_${page}`}
+          id={
+            type === "c"
+              ? `${book}-${para}`
+              : `${type}_${bookName}_${volume}_${page}`
+          }
           style={style}
           modalExtra={
             <Text style={{ marginRight: 8 }} copyable={{ text: tpl }}>

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

@@ -32,6 +32,7 @@ const items = {
   "labels.curr.paragraph.copy.quote.link.tpl": "复制引用模版",
   "labels.input": "input",
   "labels.selected": "Selected",
+  "labels.page.number.type.c": "Chapter Title",
 };
 
 export default items;

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

@@ -32,6 +32,7 @@ const items = {
   "labels.curr.paragraph.copy.quote.link.tpl": "复制引用模版",
   "labels.input": "请输入",
   "labels.selected": "已经选择",
+  "labels.page.number.type.c": "章节名称",
 };
 
 export default items;