ソースを参照

切换版本时保留当前mode

visuddhinanda 2 年 前
コミット
e795dcdca2
1 ファイル変更8 行追加6 行削除
  1. 8 6
      dashboard/src/components/corpus/ChapterInChannel.tsx

+ 8 - 6
dashboard/src/components/corpus/ChapterInChannel.tsx

@@ -7,10 +7,11 @@ import { IChannelApiData } from "../api/Channel";
 import ChannelListItem from "../channel/ChannelListItem";
 import ChannelListItem from "../channel/ChannelListItem";
 import TimeShow from "../general/TimeShow";
 import TimeShow from "../general/TimeShow";
 import { useIntl } from "react-intl";
 import { useIntl } from "react-intl";
-import { Link } from "react-router-dom";
+import { Link, useSearchParams } from "react-router-dom";
 import { IStudio } from "../auth/StudioName";
 import { IStudio } from "../auth/StudioName";
 import { useState } from "react";
 import { useState } from "react";
 import { ProgressOutlinedIcon } from "../../assets/icon";
 import { ProgressOutlinedIcon } from "../../assets/icon";
+import { ArticleMode } from "../article/Article";
 
 
 const { Text } = Typography;
 const { Text } = Typography;
 
 
@@ -38,6 +39,7 @@ const ChapterInChannelWidget = ({
   openTarget = "_blank",
   openTarget = "_blank",
 }: IWidgetChapterInChannel) => {
 }: IWidgetChapterInChannel) => {
   const intl = useIntl(); //i18n
   const intl = useIntl(); //i18n
+  const [searchParams, setSearchParams] = useSearchParams();
   const [open, setOpen] = useState(false);
   const [open, setOpen] = useState(false);
   const ChannelList = (channels: IChapterChannelData[]): JSX.Element => {
   const ChannelList = (channels: IChapterChannelData[]): JSX.Element => {
     return channels.length ? (
     return channels.length ? (
@@ -61,15 +63,15 @@ const ChapterInChannelWidget = ({
               }
               }
         }
         }
         renderItem={(item, id) => {
         renderItem={(item, id) => {
-          const channel = item.channel.id ? `?channel=${item.channel.id}` : "";
+          let url = `/article/chapter/${book}-${para}`;
+          const currMode = searchParams.get("mode");
+          url += currMode ? `?mode=${currMode}` : "?mode=read";
+          url += item.channel.id ? `&channel=${item.channel.id}` : "";
           return (
           return (
             <List.Item key={id}>
             <List.Item key={id}>
               <Row>
               <Row>
                 <Col span={12}>
                 <Col span={12}>
-                  <Link
-                    to={`/article/chapter/${book}-${para}${channel}`}
-                    target={openTarget}
-                  >
+                  <Link to={url}>
                     <ChannelListItem
                     <ChannelListItem
                       channel={item.channel}
                       channel={item.channel}
                       studio={item.studio}
                       studio={item.studio}