|
|
@@ -1,7 +1,7 @@
|
|
|
-import { message } from "antd";
|
|
|
import { useEffect, useState } from "react";
|
|
|
-import { modeChange } from "../../reducers/article-mode";
|
|
|
+import { message } from "antd";
|
|
|
|
|
|
+import { modeChange } from "../../reducers/article-mode";
|
|
|
import { get } from "../../request";
|
|
|
import store from "../../store";
|
|
|
import { IArticleDataResponse, IArticleResponse } from "../api/Article";
|
|
|
@@ -12,10 +12,11 @@ export type ArticleType =
|
|
|
| "article"
|
|
|
| "chapter"
|
|
|
| "paragraph"
|
|
|
- | "cs-paragraph"
|
|
|
- | "sentence"
|
|
|
+ | "cs-para"
|
|
|
+ | "sent"
|
|
|
| "sim"
|
|
|
- | "page";
|
|
|
+ | "page"
|
|
|
+ | "textbook";
|
|
|
interface IWidgetArticle {
|
|
|
type?: string;
|
|
|
articleId?: string;
|
|
|
@@ -56,14 +57,50 @@ const Widget = ({
|
|
|
if (typeof type !== "undefined" && typeof articleId !== "undefined") {
|
|
|
let url = "";
|
|
|
switch (type) {
|
|
|
- case "corpus/article":
|
|
|
+ case "article":
|
|
|
url = `/v2/article/${articleId}?mode=${mode}`;
|
|
|
break;
|
|
|
- case "corpus/textbook":
|
|
|
- url = `/v2/article/${mode}?mode=read`;
|
|
|
+ case "textbook":
|
|
|
+ /**
|
|
|
+ * 从课本进入
|
|
|
+ * id两部分组成
|
|
|
+ * 课程id_文章id
|
|
|
+ */
|
|
|
+ const id = articleId.split("_");
|
|
|
+ if (id.length < 2) {
|
|
|
+ message.error("文章id期待2个,实际只给了一个");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ url = `/v2/article/${id[1]}?mode=${mode}&course=${id[0]}`;
|
|
|
+ break;
|
|
|
+ case "exercise":
|
|
|
+ /**
|
|
|
+ * 从练习进入
|
|
|
+ * id 由3部分组成
|
|
|
+ * 课程id_文章id_练习id
|
|
|
+ */
|
|
|
+ const exerciseId = articleId.split("_");
|
|
|
+ if (exerciseId.length < 3) {
|
|
|
+ message.error("练习id期待3个");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ url = `/v2/article/${exerciseId[1]}?mode=${mode}&course=${exerciseId[0]}&exercise=${exerciseId[2]}`;
|
|
|
+ break;
|
|
|
+ case "exercise-list":
|
|
|
+ /**
|
|
|
+ * 从练习进入
|
|
|
+ * id 由3部分组成
|
|
|
+ * 课程id_文章id_练习id
|
|
|
+ */
|
|
|
+ const exerciseListId = articleId.split("_");
|
|
|
+ if (exerciseListId.length < 3) {
|
|
|
+ message.error("练习id期待3个");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ url = `/v2/article/${exerciseListId[1]}?mode=${mode}&course=${exerciseListId[0]}&exercise=${exerciseListId[2]}&list=true`;
|
|
|
break;
|
|
|
default:
|
|
|
- url = `/v2/${type}/${articleId}/${mode}`;
|
|
|
+ url = `/v2/corpus/${type}/${articleId}/${mode}`;
|
|
|
break;
|
|
|
}
|
|
|
get<IArticleResponse>(url).then((json) => {
|