Quote.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { ProCard } from "@ant-design/pro-components";
  2. import { Button, Popover } from "antd";
  3. import { SearchOutlined, CopyOutlined } from "@ant-design/icons";
  4. import { Typography } from "antd";
  5. const { Text, Link } = Typography;
  6. interface IWidgetQuoteCtl {
  7. paraId: string;
  8. paliPath?: string[];
  9. channel?: string;
  10. pali?: string;
  11. error?: boolean;
  12. message?: string;
  13. }
  14. const QuoteCtl = ({
  15. paraId,
  16. paliPath,
  17. channel,
  18. pali,
  19. error,
  20. message,
  21. }: IWidgetQuoteCtl) => {
  22. const show = pali ? pali : paraId;
  23. let textShow = <></>;
  24. if (typeof error !== "undefined") {
  25. textShow = <Text type="danger">{show}</Text>;
  26. } else {
  27. textShow = <Link>{show}</Link>;
  28. }
  29. const userCard = (
  30. <>
  31. <ProCard
  32. style={{ maxWidth: 500, minWidth: 300 }}
  33. actions={[
  34. <Button type="link" size="small" icon={<SearchOutlined />}>
  35. 分栏打开
  36. </Button>,
  37. <Button type="link" size="small" icon={<SearchOutlined />}>
  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;