Explorar el Código

组件属性展开

visuddhinanda hace 3 años
padre
commit
a14542be43
Se han modificado 1 ficheros con 12 adiciones y 4 borrados
  1. 12 4
      dashboard/src/components/article/AnthologyDetail.tsx

+ 12 - 4
dashboard/src/components/article/AnthologyDetail.tsx

@@ -30,14 +30,15 @@ const defaultData: IAnthologyData = {
 interface IWidgetAnthologyDetail {
 interface IWidgetAnthologyDetail {
   aid?: string;
   aid?: string;
   channels?: string[];
   channels?: string[];
+  onArticleSelect?: Function;
 }
 }
-const Widget = (prop: IWidgetAnthologyDetail) => {
+const Widget = ({ aid, channels, onArticleSelect }: IWidgetAnthologyDetail) => {
   const [tableData, setTableData] = useState(defaultData);
   const [tableData, setTableData] = useState(defaultData);
 
 
   useEffect(() => {
   useEffect(() => {
     console.log("useEffect");
     console.log("useEffect");
-    fetchData(prop.aid);
-  }, [prop.aid]);
+    fetchData(aid);
+  }, [aid]);
 
 
   function fetchData(id?: string) {
   function fetchData(id?: string) {
     get<IAnthologyResponse>(`/v2/anthology/${id}`)
     get<IAnthologyResponse>(`/v2/anthology/${id}`)
@@ -77,7 +78,14 @@ const Widget = (prop: IWidgetAnthologyDetail) => {
       </div>
       </div>
       <Title level={5}>目录</Title>
       <Title level={5}>目录</Title>
 
 
-      <TocTree treeData={tableData.articles} />
+      <TocTree
+        treeData={tableData.articles}
+        onSelect={(keys: string[]) => {
+          if (typeof onArticleSelect !== "undefined") {
+            onArticleSelect(keys);
+          }
+        }}
+      />
     </>
     </>
   );
   );
 };
 };