Quellcode durchsuchen

:fire: 文集列表

visuddhinanda vor 2 Jahren
Ursprung
Commit
d04735f452
1 geänderte Dateien mit 6 neuen und 18 gelöschten Zeilen
  1. 6 18
      dashboard/src/components/article/ArticleView.tsx

+ 6 - 18
dashboard/src/components/article/ArticleView.tsx

@@ -6,6 +6,7 @@ import TocPath, { ITocPathNode } from "../corpus/TocPath";
 import PaliChapterChannelList from "../corpus/PaliChapterChannelList";
 import { ArticleType } from "./Article";
 import VisibleObserver from "../general/VisibleObserver";
+import { useEffect, useState } from "react";
 
 const { Paragraph, Title, Text } = Typography;
 export interface IFirstAnthology {
@@ -52,6 +53,10 @@ const ArticleViewWidget = ({
   onPathChange,
   onAnthologySelect,
 }: IWidgetArticleData) => {
+  const [currPath, setCurrPath] = useState(path);
+
+  useEffect(() => setCurrPath(path), [path]);
+
   let currChannelList = <></>;
   switch (type) {
     case "chapter":
@@ -86,25 +91,8 @@ const ArticleViewWidget = ({
       </div>
 
       <Space direction="vertical">
-        <Text>
-          {path.length === 0 && anthology ? (
-            <>
-              <Text>{"文集:"}</Text>
-              <Button
-                type="link"
-                onClick={() => {
-                  if (typeof onAnthologySelect !== "undefined") {
-                    onAnthologySelect(anthology.id);
-                  }
-                }}
-              >
-                {anthology.title}
-              </Button>
-            </>
-          ) : undefined}
-        </Text>
         <TocPath
-          data={path}
+          data={currPath}
           channel={channels}
           onChange={(
             node: ITocPathNode,