Promotion.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { initEditor } from "@/modules/editor";
  2. import { isPc } from "@queenjs/utils";
  3. import { defineComponent } from "vue";
  4. export default defineComponent(() => {
  5. const editor = initEditor();
  6. const params = new URLSearchParams(location.href.split("?")[1]);
  7. const id = params.get("id");
  8. editor.actions.switchMode("preview");
  9. if (id) {
  10. editor.actions.initDesign(id);
  11. editor.controls.wxCtrl.setup(window.location.href);
  12. editor.actions.on("initDesign:success", () => {
  13. const data = editor.store.designData;
  14. document.title = data.title;
  15. const shareData = {
  16. title: data.title,
  17. link: location.href,
  18. imgUrl: data.thumbnail || "",
  19. desc: data.desc,
  20. };
  21. editor.controls.wxCtrl.setShareData(shareData);
  22. editor.controls.wxCtrl.setShare(shareData);
  23. });
  24. }
  25. // fetch("https://restapi.amap.com/v3/ip?key=6f53b2e09f72ad63423b2da6e08b25d7").then(response=>{
  26. // return response.json();
  27. // }).then(data=>{
  28. // console.log(data);
  29. // })
  30. return () => (
  31. <div class="flex items-center justify-center h-100vh bg-gray-100">
  32. <div class={isPc() ? `h-668px scrollbar` : `h-full`}>
  33. <editor.components.Preview />
  34. </div>
  35. </div>
  36. );
  37. });