import { useState } from "react"; import { Button, Dropdown, Space, Typography } from "antd"; import { ShareAltOutlined, ExportOutlined, ForkOutlined, InboxOutlined, } from "@ant-design/icons"; import ExportModal from "./ExportModal"; import { ArticleType } from "../article/Article"; import AddToAnthology from "../article/AddToAnthology"; import { useAppSelector } from "../../hooks"; import { currentUser } from "../../reducers/current-user"; import { fullUrl } from "../../utils"; const { Text } = Typography; interface IWidget { type?: ArticleType; articleId?: string; book?: string | null; para?: string | null; channelId?: string | null; anthologyId?: string | null; } const ShareButtonWidget = ({ type, book, para, channelId, articleId, anthologyId, }: IWidget) => { const [exportOpen, setExportOpen] = useState(false); const [addToAnthologyOpen, setAddToAnthologyOpen] = useState(false); const user = useAppSelector(currentUser); return ( <> {"Export"} {"PDF,Word,Html"} ), key: "export", icon: , }, { label: "添加到文集", key: "add_to_anthology", icon: , disabled: type === "article" ? false : true, }, { label: "创建副本", key: "fork", icon: , disabled: user && type === "article" ? false : true, }, ], onClick: ({ key }) => { switch (key) { case "export": setExportOpen(true); break; case "add_to_anthology": setAddToAnthologyOpen(true); break; case "fork": const url = `/studio/${user?.nickName}/article/create?parent=${articleId}`; window.open(fullUrl(url), "_blank"); break; default: break; } }, }} >