Просмотр исходного кода

:sparkles: 导航条中间的路径

visuddhinanda 2 лет назад
Родитель
Сommit
10c8c964a1
1 измененных файлов с 15 добавлено и 0 удалено
  1. 15 0
      dashboard/src/components/article/TypeArticleReader.tsx

+ 15 - 0
dashboard/src/components/article/TypeArticleReader.tsx

@@ -230,6 +230,7 @@ const TypeArticleReaderWidget = ({
           <NavigateButton
             prevTitle={nav?.prev?.title}
             nextTitle={nav?.next?.title}
+            path={currPath}
             onNext={() => {
               if (typeof onArticleChange !== "undefined") {
                 onArticleChange("article", nav?.next?.article_id);
@@ -240,6 +241,20 @@ const TypeArticleReaderWidget = ({
                 onArticleChange("article", nav?.prev?.article_id);
               }
             }}
+            onPathChange={(key: string) => {
+              if (typeof onArticleChange !== "undefined") {
+                const node = currPath?.find((value) => value.key === key);
+                if (node) {
+                  let newType = type;
+                  if (node.level === 0) {
+                    newType = "anthology";
+                  } else {
+                    newType = "article";
+                  }
+                  onArticleChange(newType, node.key, "_self");
+                }
+              }
+            }}
           />
 
           <InteractiveArea resType={"article"} resId={articleId} />