Browse Source

Merge pull request #2163 from visuddhinanda/agile

onArticleChange 传参修改 type=textbook
visuddhinanda 1 year ago
parent
commit
560ca619ff

+ 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);
               }
             }}
           />

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

@@ -26,6 +26,7 @@ import { Link, useNavigate, useSearchParams } from "react-router-dom";
 import SelectChannel from "../course/SelectChannel";
 import { Space, Tag, Typography } from "antd";
 import { useIntl } from "react-intl";
+import { ISearchParams } from "../../pages/library/article/show";
 
 const { Text } = Typography;
 
@@ -53,7 +54,12 @@ interface IWidget {
   exerciseId?: string;
   userName?: string;
   active?: boolean;
-  onArticleChange?: Function;
+  onArticleChange?: (
+    type: ArticleType,
+    id: string,
+    target: string,
+    param?: ISearchParams[]
+  ) => void;
   onFinal?: Function;
   onLoad?: Function;
   onLoading?: Function;
@@ -224,9 +230,14 @@ const TypeCourseWidget = ({
         anthologyId={anthologyId}
         active={true}
         onArticleChange={(type: ArticleType, id: string, target: string) => {
-          if (type === "article") {
+          if (type === "article" && courseId && channelId) {
             if (typeof onArticleChange !== "undefined") {
-              onArticleChange(type, id, target);
+              let param: ISearchParams[] = [
+                { key: "course", value: courseId },
+                { key: "channel", value: channelId },
+              ];
+
+              onArticleChange("textbook", id, target, param);
             }
           } else {
             navigate(`/course/show/${courseId}`);

+ 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);
                 }
               }}
             />