ShareModal.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { clipboard } from "@/utils";
  2. import { Image } from "@queenjs/ui";
  3. import { useQRCode } from "@vueuse/integrations/useQRCode";
  4. import { Button, Input } from "ant-design-vue";
  5. import { defineComponent } from "vue";
  6. import { any } from "vue-types";
  7. export default defineComponent({
  8. props: {
  9. record: any().isRequired,
  10. },
  11. emits: ["edit", "update", "changeThumnb"],
  12. setup(props, { slots, emit }) {
  13. let shareLink = location.origin + "/share.html?id=" + props.record._id;
  14. if (location.host == "www.infish.cn") {
  15. shareLink =
  16. location.origin +
  17. "/projects/queenshow/share.html?id=" +
  18. props.record._id;
  19. }
  20. const qrUrl = useQRCode(shareLink, { margin: 2 });
  21. return () => {
  22. const { record } = props;
  23. return (
  24. <div class="flex items-start">
  25. <div>
  26. <div class="scrollbar w-375px h-600px pr-10px overflow-y-auto ">
  27. {slots.preview?.()}
  28. </div>
  29. <div class="mt-20px text-center">
  30. <Button type="primary" ghost onClick={() => emit("edit")}>
  31. 编辑作品
  32. </Button>
  33. </div>
  34. </div>
  35. <div class="flex-1 ml-40px">
  36. <h3 class="mb-20px text-16px">分享设置</h3>
  37. <div class="flex">
  38. <div class="relative">
  39. <Image
  40. class="w-80px h-80px object-contain rounded-4px border-1px border-solid border-[#434343]"
  41. src={record.thumbnail}
  42. />
  43. <div
  44. class="absolute left-0 bottom-0 w-1/1 text-center py-5px text-14px bg-dark-200 bg-opacity-80 cursor-pointer"
  45. onClick={() => emit("changeThumnb")}
  46. >
  47. 更换封面
  48. </div>
  49. </div>
  50. <div class="flex-1 ml-20px">
  51. <Input
  52. class="w-1/1"
  53. defaultValue={record.title}
  54. placeholder="请输入标题"
  55. onBlur={(e: any) => {
  56. const title = e.target.value;
  57. if (!title) return;
  58. emit("update", { title });
  59. }}
  60. />
  61. {/* <Input placeholder="请输入描述" class="mt-10px w-1/1" /> */}
  62. </div>
  63. </div>
  64. <div class="mt-40px flex">
  65. <div>
  66. <h3 class=" text-16px">二维码</h3>
  67. <img class="mt-20px w-120px" src={qrUrl.value} />
  68. <div class="mt-10px text-center">
  69. <span class="ml-5px text-12px opacity-80">
  70. 微信扫一扫分享
  71. </span>
  72. </div>
  73. </div>
  74. <div class="flex-1 w-0 ml-60px">
  75. <h3 class=" text-16px">链接分享</h3>
  76. <div class="mt-20px">
  77. <div class="w-1/1 py-4px px-10px border-solid border-1px border-[#434343] rounded-2px truncate opacity-80">
  78. {shareLink}
  79. </div>
  80. <Button
  81. class="mt-10px"
  82. type="primary"
  83. ghost
  84. onClick={() => clipboard.copy(shareLink)}
  85. >
  86. 复制链接
  87. </Button>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. );
  94. };
  95. },
  96. });