import { useEditor } from "@/modules/editor";
import { clipboard } from "@/utils";
import { useQRCode } from "@vueuse/integrations/useQRCode";
import { Button } from "ant-design-vue";
import { defineComponent } from "vue";

export const ShareBox = defineComponent({
  setup() {
    const { store } = useEditor();
    let shareLink = location.origin + "/share.html?id=" + store.designData._id;
    // if (location.host == "www.infish.cn") {
    //   shareLink =
    //     location.origin +
    //     "/projects/queenshowv1/share.html?id=" +
    //     store.designData._id;
    // }

    const qrUrl = useQRCode(shareLink);

    return () => (
      <div class="p-20px bg-dark-500 text-center">
        <img src={qrUrl.value} />
        <div class="mb-20px"></div>
        <Button onClick={() => clipboard.copy(shareLink)}>复制链接</Button>
      </div>
    );
  },
});
