Application.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { useEditor } from "@/modules/editor";
  2. import { ICompKeys } from "@/modules/editor/typings";
  3. import { css } from "@linaria/core";
  4. import { useReactive } from "@queenjs/use";
  5. import { Tooltip } from "ant-design-vue";
  6. import { defineComponent } from "vue";
  7. import { Container, Draggable } from "vue-dndrop";
  8. export default defineComponent({
  9. setup() {
  10. const editor = useEditor();
  11. const { compUICtrl } = editor.controls;
  12. const state = useReactive(() => ({
  13. basicComps() {
  14. return ["Map"].map(
  15. (key) => compUICtrl.state.components.get(key) as any
  16. );
  17. },
  18. }));
  19. return () => {
  20. return (
  21. <Container
  22. class={basicStyle}
  23. orientation="horizontal"
  24. behaviour="copy"
  25. group-name="canvas"
  26. get-child-payload={(index: number) => {
  27. return state.basicComps[index].compKey;
  28. }}
  29. >
  30. {state.basicComps.map((item) => {
  31. return (
  32. <Draggable key={item.compKey} class="!leading-0">
  33. <div
  34. class="draggable-item"
  35. onClick={() =>
  36. editor.actions.clickCompToDesign(item.compKey as ICompKeys)
  37. }
  38. >
  39. <span>
  40. <img
  41. class="h-24px m-4px pointer-events-none"
  42. src={item.thumbnail}
  43. />
  44. </span>
  45. <span class="pl-10px">{item.name}</span>
  46. </div>
  47. </Draggable>
  48. );
  49. })}
  50. </Container>
  51. );
  52. };
  53. },
  54. });
  55. const basicStyle = css`
  56. display: flex;
  57. align-items: center;
  58. .draggable-item {
  59. border-radius: 4px;
  60. margin: 0 4px;
  61. cursor: pointer;
  62. &:hover {
  63. background-color: darken(@inf-component-bg, 3%);
  64. }
  65. }
  66. `;