Quote.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 = ({
  16. paraId,
  17. paliPath,
  18. channel,
  19. pali,
  20. error,
  21. message,
  22. }: IWidgetQuoteCtl) => {
  23. const intl = useIntl();
  24. const show = pali ? pali : paraId;
  25. let textShow = <></>;
  26. if (typeof error !== "undefined") {
  27. textShow = <Text type="danger">{show}</Text>;
  28. } else {
  29. textShow = <Link>{show}</Link>;
  30. }
  31. const userCard = (
  32. <>
  33. <ProCard
  34. style={{ maxWidth: 500, minWidth: 300 }}
  35. actions={[
  36. <Button type="link" size="small" icon={<SearchOutlined />}>
  37. 分栏打开
  38. </Button>,
  39. <Button type="link" size="small" icon={<SearchOutlined />}>
  40. {intl.formatMessage({
  41. id: "buttons.open.in.new.tab",
  42. })}
  43. </Button>,
  44. <Button type="link" size="small" icon={<CopyOutlined />}>
  45. 复制引用
  46. </Button>,
  47. ]}
  48. >
  49. <div>{message ? message : ""}</div>
  50. </ProCard>
  51. </>
  52. );
  53. return (
  54. <>
  55. <Popover content={userCard} placement="bottom">
  56. {textShow}
  57. </Popover>
  58. </>
  59. );
  60. };
  61. interface IWidget {
  62. props: string;
  63. }
  64. const Widget = ({ props }: IWidget) => {
  65. const prop = JSON.parse(atob(props)) as IWidgetQuoteCtl;
  66. console.log(prop);
  67. return (
  68. <>
  69. <QuoteCtl {...prop} />
  70. </>
  71. );
  72. };
  73. export default Widget;