App.tsx 816 B

123456789101112131415161718192021222324252627282930313233
  1. import { initRemSize } from "@/hooks/initRemSize";
  2. import { initEditor } from "@/modules/editor";
  3. import { defineComponent, onMounted } from "vue";
  4. import WxSdk from "./sdk";
  5. export const App = defineComponent(() => {
  6. const editor = initEditor();
  7. const params = new URLSearchParams(location.href.split("?")[1]);
  8. const id = params.get("id");
  9. editor.actions.switchMode("preview");
  10. initRemSize();
  11. if (id) {
  12. editor.actions.initDesign(id);
  13. editor.actions.on("initDesign:success", () => {
  14. const data = editor.store.designData;
  15. WxSdk.setShareData({
  16. title: data.title,
  17. link: location.href,
  18. imgUrl: data.thumbnail || "",
  19. desc: data.title,
  20. });
  21. });
  22. }
  23. onMounted(() => {
  24. WxSdk.init();
  25. });
  26. return () => <editor.components.Preview />;
  27. });