瀏覽代碼

加channel参数

visuddhinanda 2 年之前
父節點
當前提交
c7d1019792
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      dashboard/src/components/corpus/TocPath.tsx

+ 7 - 2
dashboard/src/components/corpus/TocPath.tsx

@@ -1,4 +1,4 @@
-import { useNavigate } from "react-router-dom";
+import { useNavigate, useSearchParams } from "react-router-dom";
 import { Breadcrumb, Popover, Tag, Typography } from "antd";
 
 import PaliText from "../template/Wbw/PaliText";
@@ -31,6 +31,7 @@ const TocPathWidget = ({
   onChange,
 }: IWidgetTocPath): JSX.Element => {
   const navigate = useNavigate();
+  const [searchParams, setSearchParams] = useSearchParams();
 
   const fullPath = (
     <Breadcrumb style={{ whiteSpace: "nowrap", width: "100%" }}>
@@ -52,7 +53,11 @@ const TocPathWidget = ({
                     type === "para"
                       ? `&book=${item.book}&par=${item.paragraph}`
                       : "";
-                  let url = `/article/${type}/${item.book}-${item.paragraph}?mode=read${param}`;
+                  const channel = searchParams.get("channel");
+                  const mode = searchParams.get("mode");
+                  const urlMode = mode ? mode : "read";
+                  let url = `/article/${type}/${item.book}-${item.paragraph}?mode=${urlMode}${param}`;
+                  url += channel ? `&channel=${channel}` : "";
                   if (e.ctrlKey || e.metaKey) {
                     window.open(fullUrl(url), "_blank");
                   } else {