visuddhinanda 2 лет назад
Родитель
Сommit
2e76370a70

+ 4 - 0
dashboard/src/components/article/ToolButtonToc.tsx

@@ -10,14 +10,17 @@ interface IWidget {
   type?: ArticleType;
   articleId?: string;
   anthologyId?: string | null;
+  channels?: string[];
   onSelect?: Function;
 }
 const ToolButtonTocWidget = ({
   type,
   articleId,
   anthologyId,
+  channels,
   onSelect,
 }: IWidget) => {
+  //TODO 都放return里面
   let tocWidget = <></>;
   if (type === "chapter" || type === "para") {
     if (articleId) {
@@ -41,6 +44,7 @@ const ToolButtonTocWidget = ({
       tocWidget = (
         <AnthologyTocTree
           anthologyId={anthologyId}
+          channels={channels}
           onArticleSelect={(anthologyId: string, keys: string[]) => {
             if (typeof onSelect !== "undefined" && keys.length > 0) {
               onSelect(keys[0]);

+ 9 - 7
dashboard/src/pages/library/article/show.tsx

@@ -300,6 +300,7 @@ const Widget = () => {
                 <ToolButtonToc
                   type={type as ArticleType}
                   articleId={id}
+                  channels={searchParams.get("channel")?.split("_")}
                   anthologyId={searchParams.get("anthology")}
                   onSelect={(key: Key) => {
                     console.log("toc click", key);
@@ -347,13 +348,14 @@ const Widget = () => {
               articleId={id}
               anthologyId={searchParams.get("anthology")}
               mode={searchParams.get("mode") as ArticleMode}
-              onArticleChange={(article: string, target?: string) => {
-                console.log("article change", article, target);
-                let mType = type;
-                if (article.split("-").length === 2) {
-                  mType = "chapter";
-                }
-                let url = `/article/${mType}/${article}?mode=${currMode}`;
+              onArticleChange={(
+                newType: ArticleType,
+                article: string,
+                target?: string
+              ) => {
+                console.log("article change", newType, article, target);
+
+                let url = `/article/${newType}/${article}?mode=${currMode}`;
                 searchParams.forEach((value, key) => {
                   console.log(value, key);
                   if (key !== "mode") {