|
|
@@ -0,0 +1,73 @@
|
|
|
+import { Tabs, Button, Popover } from "antd";
|
|
|
+import { MenuOutlined, PushpinOutlined } from "@ant-design/icons";
|
|
|
+import PaliTextToc from "./PaliTextToc";
|
|
|
+import Find from "./Find";
|
|
|
+import Nav from "./Nav";
|
|
|
+
|
|
|
+interface IWidget {
|
|
|
+ type?: string;
|
|
|
+ articleId?: string;
|
|
|
+}
|
|
|
+const Widget = ({ type, articleId }: IWidget) => {
|
|
|
+ const id = articleId?.split("_");
|
|
|
+ let tocWidget = <></>;
|
|
|
+ if (id && id.length > 0) {
|
|
|
+ const sentId = id[0].split("-");
|
|
|
+ if (sentId.length > 1) {
|
|
|
+ tocWidget = (
|
|
|
+ <PaliTextToc book={parseInt(sentId[0])} para={parseInt(sentId[1])} />
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const styleTabBody: React.CSSProperties = {
|
|
|
+ width: 350,
|
|
|
+ height: "calc(100vh - 200px)",
|
|
|
+ overflowY: "scroll",
|
|
|
+ };
|
|
|
+ const mainMenuContent = (
|
|
|
+ <Tabs
|
|
|
+ size="small"
|
|
|
+ defaultActiveKey="1"
|
|
|
+ tabBarExtraContent={{
|
|
|
+ right: <Button type="text" size="small" icon={<PushpinOutlined />} />,
|
|
|
+ }}
|
|
|
+ items={[
|
|
|
+ {
|
|
|
+ label: `目录`,
|
|
|
+ key: "1",
|
|
|
+ children: <div style={styleTabBody}>{tocWidget}</div>,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: `定位`,
|
|
|
+ key: "2",
|
|
|
+ children: (
|
|
|
+ <div style={styleTabBody}>
|
|
|
+ <Nav />
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: `查找`,
|
|
|
+ key: "3",
|
|
|
+ children: (
|
|
|
+ <div style={styleTabBody}>
|
|
|
+ <Find />
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ );
|
|
|
+ return (
|
|
|
+ <Popover
|
|
|
+ placement="bottomLeft"
|
|
|
+ arrowPointAtCenter
|
|
|
+ content={mainMenuContent}
|
|
|
+ trigger="click"
|
|
|
+ >
|
|
|
+ <Button size="small" icon={<MenuOutlined />} />
|
|
|
+ </Popover>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default Widget;
|