index.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { useEditor } from "@/modules/editor";
  2. import { defineUI } from "queenjs";
  3. import { TipIcons } from "../../TipIcons";
  4. import { Dropdown } from "ant-design-vue";
  5. import { css } from "@linaria/core";
  6. import { useLauncher } from "@/modules/launcher";
  7. import AiText from "./AiText";
  8. import { reactive } from "vue";
  9. export default defineUI({
  10. setup() {
  11. const { actions, controls } = useEditor();
  12. const launcher = useLauncher();
  13. const { history } = controls.historyCtrl;
  14. const state = reactive({
  15. aiVisible: false,
  16. });
  17. return () => (
  18. <>
  19. <div class="absolute top-20px left-20px space-x-10px z-999">
  20. <TipIcons.Undo
  21. disable={ !controls.historyCtrl.state.enable || !history.state.canUndo}
  22. class={btnCls}
  23. onClick={() => history.undo()}
  24. />
  25. <TipIcons.Redo
  26. disable={ !controls.historyCtrl.state.enable || !history.state.canRedo}
  27. class={btnCls}
  28. onClick={() => history.redo()}
  29. />
  30. </div>
  31. <div class="absolute top-20px right-20px space-x-10px z-999">
  32. <Dropdown
  33. overlay={
  34. <AiText
  35. onVisible={(v) => {
  36. state.aiVisible = v;
  37. }}
  38. />
  39. }
  40. destroyPopupOnHide={true}
  41. placement="bottom"
  42. visible={state.aiVisible}
  43. >
  44. <TipIcons.AiText
  45. class={btnCls}
  46. onClick={() => {
  47. state.aiVisible = !state.aiVisible;
  48. }}
  49. />
  50. </Dropdown>
  51. <TipIcons.Screenshot
  52. class={btnCls}
  53. onClick={() => actions.updateThumbnailByScreenshot(true)}
  54. />
  55. </div>
  56. <div class="absolute bottom-20px right-20px z-999">
  57. <TipIcons.QueenService
  58. class={btnCls}
  59. onClick={() => {
  60. launcher.showModal(<launcher.components.Viewport />, {
  61. width: "400px",
  62. });
  63. }}
  64. />
  65. </div>
  66. </>
  67. );
  68. },
  69. });
  70. const btnCls = css`
  71. padding: 10px;
  72. border-radius: 50%;
  73. background-color: #333;
  74. @apply shadow;
  75. `;