import { IArticleDataResponse } from "../api/Article"; import TypeArticle from "./TypeArticle"; import TypeAnthology from "./TypeAnthology"; import TypeTerm from "./TypeTerm"; import TypePali from "./TypePali"; import "./article.css"; import TypePage from "./TypePage"; import TypeCSPara from "./TypeCSPara"; import { ISearchParams } from "../../pages/library/article/show"; import TypeCourse from "./TypeCourse"; import { useEffect, useState } from "react"; import { fullUrl } from "../../utils"; import TypeSeries from "./TypeSeries"; import DiscussionCount from "../discussion/DiscussionCount"; export type ArticleMode = "read" | "edit" | "wbw"; export type ArticleType = | "anthology" | "article" | "series" | "chapter" | "para" | "cs-para" | "sent" | "sim" | "page" | "textbook" | "exercise" | "exercise-list" | "sent-original" | "sent-commentary" | "sent-nissaya" | "sent-translation" | "term"; /** * 每种article type 对应的路由参数 * article/id?anthology=id&channel=id1,id2&mode=ArticleMode * chapter/book-para?channel=id1,id2&mode=ArticleMode * para/book?par=para1,para2&channel=id1,id2&mode=ArticleMode * cs-para/book-para?channel=id1,id2&mode=ArticleMode * sent/id?channel=id1,id2&mode=ArticleMode * sim/id?channel=id1,id2&mode=ArticleMode * textbook/articleId?course=id&mode=ArticleMode * exercise/articleId?course=id&exercise=id&username=name&mode=ArticleMode * exercise-list/articleId?course=id&exercise=id&mode=ArticleMode * sent-original/id */ interface IWidget { type?: ArticleType; articleId?: string; mode?: ArticleMode | null; channelId?: string | null; parentChannels?: string[]; book?: string | null; para?: string | null; anthologyId?: string | null; courseId?: string | null; active?: boolean; focus?: string | null; hideInteractive?: boolean; hideTitle?: boolean; isSubWindow?: boolean; onArticleChange?: Function; onLoad?: Function; onAnthologySelect?: Function; onTitle?: Function; onArticleEdit?: Function; } const ArticleWidget = ({ type, book, para, channelId, parentChannels, articleId, anthologyId, courseId, mode = "read", active = false, focus, hideInteractive = false, hideTitle = false, isSubWindow = false, onArticleChange, onLoad, onAnthologySelect, onTitle, onArticleEdit, }: IWidget) => { const [currId, setCurrId] = useState(articleId); useEffect(() => setCurrId(articleId), [articleId]); return (