index.tsx 968 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { wxController } from "@/controllers/wxController";
  2. import { Dict_Apis } from "@/dict";
  3. import { initEditor } from "@/modules/editor";
  4. import { defineComponent } from "vue";
  5. export default defineComponent(() => {
  6. const editor = initEditor();
  7. const params = new URLSearchParams(location.href.split("?")[1]);
  8. const id = params.get("id");
  9. const wxSdk = new wxController();
  10. const url = `${Dict_Apis.promotion}/wechat/share?`;
  11. wxSdk.init(url);
  12. editor.actions.switchMode("preview");
  13. if (id) {
  14. editor.actions.initDesign(id);
  15. editor.actions.on("initDesign:success", () => {
  16. const data = editor.store.designData;
  17. document.title = data.title;
  18. const shareData = {
  19. title: data.title,
  20. link: location.href,
  21. imgUrl: data.thumbnail || "",
  22. desc: data.desc,
  23. };
  24. wxSdk.setShareData(shareData);
  25. wxSdk.setShare(shareData);
  26. });
  27. }
  28. return () => <editor.components.Preview />;
  29. });