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

onArticleChange 添加参数定义

visuddhinanda 1 год назад
Родитель
Сommit
62ecaab639

+ 7 - 2
dashboard/src/components/article/Article.tsx

@@ -60,7 +60,12 @@ interface IWidget {
   hideInteractive?: boolean;
   hideTitle?: boolean;
   isSubWindow?: boolean;
-  onArticleChange?: Function;
+  onArticleChange?: (
+    type: ArticleType,
+    id: string,
+    target: string,
+    param?: ISearchParams[]
+  ) => void;
   onLoad?: Function;
   onAnthologySelect?: Function;
   onTitle?: Function;
@@ -166,7 +171,7 @@ const ArticleWidget = ({
             type: ArticleType,
             id: string,
             target: string,
-            param: ISearchParams[]
+            param?: ISearchParams[]
           ) => {
             if (typeof onArticleChange !== "undefined") {
               onArticleChange(type, id, target, param);

+ 14 - 3
dashboard/src/components/article/TypeCSPara.tsx

@@ -10,6 +10,7 @@ import NavigateButton from "./NavigateButton";
 import ArticleSkeleton from "./ArticleSkeleton";
 import ErrorResult from "../general/ErrorResult";
 import "./article.css";
+import { ISearchParams } from "../../pages/library/article/show";
 
 interface IParam {
   articleId?: string;
@@ -22,7 +23,12 @@ interface IWidget {
   articleId?: string;
   mode?: ArticleMode | null;
   channelId?: string | null;
-  onArticleChange?: Function;
+  onArticleChange?: (
+    type: ArticleType,
+    id: string,
+    target: string,
+    param?: ISearchParams[]
+  ) => void;
   onFinal?: Function;
   onLoad?: Function;
 }
@@ -107,9 +113,14 @@ const TypeCSParaWidget = ({
             type={"para"}
             hideNav
             {...paramPali}
-            onArticleChange={(type: ArticleType, id: string) => {
+            onArticleChange={(
+              type: ArticleType,
+              id: string,
+              target: string,
+              param?: ISearchParams[] | undefined
+            ) => {
               if (typeof onArticleChange !== "undefined") {
-                onArticleChange(type, id);
+                onArticleChange(type, id, target, param);
               }
             }}
           />

+ 13 - 3
dashboard/src/components/article/TypePage.tsx

@@ -12,6 +12,7 @@ import ArticleSkeleton from "./ArticleSkeleton";
 import ErrorResult from "../general/ErrorResult";
 import "./article.css";
 import { fullUrl } from "../../utils";
+import { ISearchParams } from "../../pages/library/article/show";
 
 interface IParam {
   articleId?: string;
@@ -25,7 +26,12 @@ interface IWidget {
   mode?: ArticleMode | null;
   channelId?: string | null;
   focus?: string | null;
-  onArticleChange?: Function;
+  onArticleChange?: (
+    type: ArticleType,
+    id: string,
+    target: string,
+    param?: ISearchParams[]
+  ) => void;
   onFinal?: Function;
   onLoad?: Function;
 }
@@ -159,9 +165,13 @@ const TypePageWidget = ({
             hideNav
             {...paramPali}
             focus={focus}
-            onArticleChange={(type: ArticleType, id: string) => {
+            onArticleChange={(
+              type: ArticleType,
+              id: string,
+              target: string
+            ) => {
               if (typeof onArticleChange !== "undefined") {
-                onArticleChange(type, id);
+                onArticleChange(type, id, target);
               }
             }}
           />

+ 7 - 2
dashboard/src/components/article/TypePali.tsx

@@ -31,7 +31,12 @@ interface IWidget {
   active?: boolean;
   focus?: string | null;
   hideNav?: boolean;
-  onArticleChange?: Function;
+  onArticleChange?: (
+    type: ArticleType,
+    id: string,
+    target: string,
+    param?: ISearchParams[]
+  ) => void;
   onFinal?: Function;
   onLoad?: Function;
   onTitle?: Function;
@@ -352,7 +357,7 @@ const TypePaliWidget = ({
                   }
                 }
                 if (typeof onArticleChange !== "undefined") {
-                  onArticleChange(type, newId, target, param);
+                  onArticleChange(type as ArticleType, newId, target, param);
                 }
               }}
             />