Shapes.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { Container, Draggable } from "vue-dndrop";
  2. import { useEditor } from "@/modules/editor";
  3. import { useResource } from "@/modules/resource";
  4. import { Image, Loadmore } from "@queenjs/ui";
  5. import Empty from "@queenjs/ui/empty";
  6. import { defineUI } from "queenjs";
  7. export default defineUI({
  8. setup() {
  9. const editor = useEditor();
  10. const resource = useResource();
  11. resource.controls.sysSvgListCtrl.hasLimit = true;
  12. resource.controls.sysSvgListCtrl.loadPage(1);
  13. return () => {
  14. const ctrl = resource.controls.sysSvgListCtrl;
  15. const dataSource = ctrl.state.list;
  16. return (
  17. <div class="flex-1 overflow-x-hidden overflow-y-auto scrollbar">
  18. <Container
  19. class="grid grid-cols-4 gap-8px"
  20. behaviour="copy"
  21. group-name="canvas"
  22. animation-duration={0}
  23. get-child-payload={(index: number) => {
  24. return {
  25. type: "svg",
  26. data: dataSource[index],
  27. };
  28. }}
  29. >
  30. {dataSource.map((item: any) => {
  31. return (
  32. <Draggable key={item._id}>
  33. <div
  34. class="text-center leading-50px bg-dark-50 rounded draggable-item"
  35. key={item._id}
  36. // title={item.title}
  37. onClick={() => editor.actions.clickFrameToDesign(item)}
  38. >
  39. <Image
  40. class="w-full p-10px rounded pointer-events-none"
  41. src={item.file.url}
  42. // size={240}
  43. />
  44. </div>
  45. </Draggable>
  46. );
  47. })}
  48. </Container>
  49. {dataSource.length == 0 ? (
  50. <Empty />
  51. ) : (
  52. <Loadmore
  53. class="mt-20px"
  54. loading={ctrl.state.loading}
  55. canLoad={ctrl.state.canLoadNext}
  56. onChange={ctrl.loadNextPage}
  57. />
  58. )}
  59. </div>
  60. );
  61. };
  62. },
  63. });