Quote.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { Button, Popover } from "antd";
  2. import { Typography } from "antd";
  3. import { SearchOutlined, CopyOutlined } from "@ant-design/icons";
  4. import { ProCard } from "@ant-design/pro-components";
  5. import { useIntl } from "react-intl";
  6. const { Text, Link } = Typography;
  7. interface IWidgetQuoteCtl {
  8. paraId: string;
  9. paliPath?: string[];
  10. channel?: string;
  11. pali?: string;
  12. error?: boolean;
  13. message?: string;
  14. }
  15. const QuoteCtl = ({ paraId, pali, error, message }: IWidgetQuoteCtl) => {
  16. const intl = useIntl();
  17. const show = pali ? pali : paraId;
  18. let textShow = <></>;
  19. if (typeof error !== "undefined") {
  20. textShow = <Text type="danger">{show}</Text>;
  21. } else {
  22. textShow = <Link>{show}</Link>;
  23. }
  24. const userCard = (
  25. <>
  26. <ProCard
  27. style={{ maxWidth: 500, minWidth: 300 }}
  28. actions={[
  29. <Button type="link" size="small" icon={<SearchOutlined />}>
  30. 分栏打开
  31. </Button>,
  32. <Button type="link" size="small" icon={<SearchOutlined />}>
  33. {intl.formatMessage(
  34. {
  35. id: "buttons.open.in.new.tab",
  36. },
  37. { item: "" }
  38. )}
  39. </Button>,
  40. <Button type="link" size="small" icon={<CopyOutlined />}>
  41. 复制引用
  42. </Button>,
  43. ]}
  44. >
  45. <div>{message ? message : ""}</div>
  46. </ProCard>
  47. </>
  48. );
  49. return (
  50. <>
  51. <Popover content={userCard} placement="bottom">
  52. {textShow}
  53. </Popover>
  54. </>
  55. );
  56. };
  57. interface IWidget {
  58. props: string;
  59. }
  60. const Widget = ({ props }: IWidget) => {
  61. const prop = JSON.parse(atob(props)) as IWidgetQuoteCtl;
  62. console.log(prop);
  63. return (
  64. <>
  65. <QuoteCtl {...prop} />
  66. </>
  67. );
  68. };
  69. export default Widget;