SaveOrShare.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { useEditor } from "@/modules/editor";
  2. import { Button } from "ant-design-vue";
  3. import { defineUI, queenApi } from "queenjs";
  4. import { TipIcons } from "../../TipIcons";
  5. import PreviewDesignModal from "./PreviewDesignModal";
  6. import PublishDesignModal from "./PublishDesignModal";
  7. export default defineUI({
  8. setup() {
  9. const editor = useEditor();
  10. const { store, actions, controls } = editor;
  11. function showPreviewModal() {
  12. controls.screenCtrl.saveScreenPage();
  13. const rootPage = controls.pageCtrl.rootPage;
  14. rootPage.value.pageMode = controls.screenCtrl.state.screen.pageMode;
  15. rootPage.value.pageSizeType =
  16. controls.screenCtrl.state.screen.pageSizeType;
  17. queenApi.dialog(
  18. <PreviewDesignModal data={controls.pageCtrl.designData} />,
  19. {
  20. fullscreen: true,
  21. closable: false,
  22. }
  23. );
  24. }
  25. async function showPublishModal() {
  26. if (!controls.pageCtrl.designData.thumbnail) {
  27. await actions.updateThumbnailByScreenshot();
  28. }
  29. controls.screenCtrl.saveScreenPage();
  30. const rootPage = controls.pageCtrl.rootPage;
  31. rootPage.value.pageMode = controls.screenCtrl.state.screen.pageMode;
  32. rootPage.value.pageSizeType =
  33. controls.screenCtrl.state.screen.pageSizeType;
  34. await queenApi.dialog(
  35. <PublishDesignModal data={controls.pageCtrl.designData} />,
  36. {
  37. fullscreen: true,
  38. title: "作品信息",
  39. }
  40. );
  41. }
  42. return () => (
  43. <aside class="space-x-16px flex items-center">
  44. <TipIcons.Preview
  45. class="text-20px text-light-50 bg-dark-50 p-6px transform rotate-90 rounded cursor-pointer transition hover:(!bg-dark-100)"
  46. onClick={showPreviewModal}
  47. />
  48. {/* {store.isEditPage && (
  49. <Dropdown
  50. overlay={<ShareBox />}
  51. trigger="click"
  52. placement="bottomRight"
  53. >
  54. <Button
  55. type="default"
  56. class="text-12px bg-dark-50 hover:(bg-dark-100 border-transparent text-light-50)"
  57. >
  58. 分享
  59. </Button>
  60. </Dropdown>
  61. )} */}
  62. <Button
  63. class="text-12px text-dark-500 hover:text-dark-500"
  64. type="primary"
  65. onClick={() => actions.saveDesign()}
  66. >
  67. 保存
  68. </Button>
  69. <Button
  70. type="text"
  71. class="text-12px bg-dark-50 hover:(bg-dark-100 text-light-50) focus:(bg-dark-100)"
  72. onClick={() => showPublishModal()}
  73. >
  74. 发布
  75. </Button>
  76. </aside>
  77. );
  78. },
  79. });