Przeglądaj źródła

支持包含token的channel id

visuddhinanda 1 rok temu
rodzic
commit
b86fc9a494

+ 13 - 19
dashboard-v4/dashboard/src/components/template/Article.tsx

@@ -59,9 +59,15 @@ export const ArticleCtl = ({
     currMode = mode;
     currMode = mode;
   }
   }
 
 
-  const orgChannels = channel ? channel.split(",") : [];
+  const channelsToken = channel?.split(",").map((item) => item.split("@"));
+  channelsToken?.forEach((value) =>
+    sessionStorage.setItem(value[0], value[1] ?? "")
+  );
+  const orgChannels = channel
+    ? channel.split(",").map((item) => item.split("@")[0])
+    : [];
   const strUrlChannels = searchParams.get("channel");
   const strUrlChannels = searchParams.get("channel");
-  const urlChannels = strUrlChannels ? strUrlChannels.split(",") : [];
+  const urlChannels = strUrlChannels ? strUrlChannels.split("_") : [];
   const currChannels = [...orgChannels, ...urlChannels];
   const currChannels = [...orgChannels, ...urlChannels];
 
 
   const showModal = () => {
   const showModal = () => {
@@ -85,7 +91,7 @@ export const ArticleCtl = ({
       anthologyId={anthology}
       anthologyId={anthology}
       book={book}
       book={book}
       para={paragraphs}
       para={paragraphs}
-      channelId={currChannels.join(",")}
+      channelId={currChannels.join("_")}
       parentChannels={parentChannels}
       parentChannels={parentChannels}
       focus={focus}
       focus={focus}
       mode={currMode}
       mode={currMode}
@@ -96,7 +102,7 @@ export const ArticleCtl = ({
   );
   );
   let output = <></>;
   let output = <></>;
   let articleLink = `/article/${type}/${id}?mode=${currMode}`;
   let articleLink = `/article/${type}/${id}?mode=${currMode}`;
-  articleLink += channel ? `&channel=${channel}` : "";
+  articleLink += channel ? `&channel=${currChannels.join("_")}` : "";
 
 
   const OpenLink = (
   const OpenLink = (
     <Link to={articleLink} target="_blank">
     <Link to={articleLink} target="_blank">
@@ -112,9 +118,7 @@ export const ArticleCtl = ({
           <Typography.Link
           <Typography.Link
             onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
             onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
               if (event.ctrlKey || event.metaKey) {
               if (event.ctrlKey || event.metaKey) {
-                let link = `/article/${type}/${id}?mode=read`;
-                link += channel ? `&channel=${channel}` : "";
-                window.open(fullUrl(link), "_blank");
+                window.open(fullUrl(articleLink), "_blank");
               } else {
               } else {
                 showModal();
                 showModal();
               }
               }
@@ -135,11 +139,7 @@ export const ArticleCtl = ({
               >
               >
                 <Text>{aTitle}</Text>
                 <Text>{aTitle}</Text>
                 <Space>
                 <Space>
-                  <Link to={articleLink} target="_blank">
-                    {intl.formatMessage({
-                      id: "buttons.open.in.new.tab",
-                    })}
-                  </Link>
+                  {OpenLink}
                   {modalExtra}
                   {modalExtra}
                 </Space>
                 </Space>
               </div>
               </div>
@@ -171,13 +171,7 @@ export const ArticleCtl = ({
       );
       );
       break;
       break;
     case "link":
     case "link":
-      let link = `/article/${type}/${id}?mode=read`;
-      link += channel ? `&channel=${channel}` : "";
-      output = (
-        <Link to={link} target="_blank">
-          {aTitle}
-        </Link>
-      );
+      output = OpenLink;
       break;
       break;
     case "window":
     case "window":
       output = <div style={{ width: "100%" }}>{article}</div>;
       output = <div style={{ width: "100%" }}>{article}</div>;