Przeglądaj źródła

Merge pull request #1847 from visuddhinanda/agile

#1799 添加段落模式翻页
visuddhinanda 2 lat temu
rodzic
commit
bd1c5bddf5

+ 8 - 2
dashboard/src/components/article/Article.tsx

@@ -6,6 +6,7 @@ import TypePali from "./TypePali";
 import "./article.css";
 import TypePage from "./TypePage";
 import TypeCSPara from "./TypeCSPara";
+import { ISearchParams } from "../../pages/library/article/show";
 
 export type ArticleMode = "read" | "edit" | "wbw";
 export type ArticleType =
@@ -132,9 +133,14 @@ const ArticleWidget = ({
           book={book}
           para={para}
           focus={focus}
-          onArticleChange={(type: ArticleType, id: string, target: string) => {
+          onArticleChange={(
+            type: ArticleType,
+            id: string,
+            target: string,
+            param: ISearchParams[]
+          ) => {
             if (typeof onArticleChange !== "undefined") {
-              onArticleChange(type, id, target);
+              onArticleChange(type, id, target, param);
             }
           }}
         />

+ 8 - 1
dashboard/src/components/article/TypePali.tsx

@@ -15,6 +15,7 @@ import ErrorResult from "../general/ErrorResult";
 import store from "../../store";
 import { refresh } from "../../reducers/focus";
 import Navigate from "./Navigate";
+import { ISearchParams } from "../../pages/library/article/show";
 
 interface IWidget {
   type?: ArticleType;
@@ -279,8 +280,14 @@ const TypePaliWidget = ({
                 if (event.ctrlKey || event.metaKey) {
                   target = "_blank";
                 }
+                let param: ISearchParams[] = [];
+                if (type === "para" && newId) {
+                  if (newId.split("-").length > 1) {
+                    param = [{ key: "par", value: newId.split("-")[1] }];
+                  }
+                }
                 if (typeof onArticleChange !== "undefined") {
-                  onArticleChange(type, newId, target);
+                  onArticleChange(type, newId, target, param);
                 }
               }}
             />

+ 14 - 2
dashboard/src/pages/library/article/show.tsx

@@ -51,6 +51,10 @@ import LoginAlertModal from "../../../components/auth/LoginAlertModal";
 import ShareButton from "../../../components/export/ShareButton";
 import ChannelAlert from "../../../components/channel/ChannelAlert";
 
+export interface ISearchParams {
+  key: string;
+  value: string;
+}
 /**
  * type:
  *   sent 句子
@@ -353,7 +357,8 @@ const Widget = () => {
               onArticleChange={(
                 newType: ArticleType,
                 article: string,
-                target?: string
+                target: string,
+                param?: ISearchParams[]
               ) => {
                 console.log("article change", newType, article, target);
                 scrollToTop();
@@ -361,7 +366,14 @@ const Widget = () => {
                 searchParams.forEach((value, key) => {
                   console.log(value, key);
                   if (key !== "mode") {
-                    url += `&${key}=${value}`;
+                    const paramValue = param?.find(
+                      (value) => value.key === key
+                    );
+                    if (paramValue) {
+                      url += `&${key}=${paramValue.value}`;
+                    } else {
+                      url += `&${key}=${value}`;
+                    }
                   }
                 });
                 if (target === "_blank") {