|
@@ -2,6 +2,9 @@ import { useEditor } from "@/modules/editor";
|
|
|
import { ICompKeys } from "@/modules/editor/typings";
|
|
|
import { Radio } from "ant-design-vue";
|
|
|
import { defineUI } from "queenjs";
|
|
|
+import { Container, Draggable } from "vue-dndrop";
|
|
|
+import * as basicUI from "../../CompUI/basicUI";
|
|
|
+import { css } from "@linaria/core";
|
|
|
|
|
|
export default defineUI({
|
|
|
setup() {
|
|
@@ -10,29 +13,78 @@ export default defineUI({
|
|
|
return () => (
|
|
|
<div class="h-full flex flex-col">
|
|
|
<div class="p-16px border-bottom !border-2px">资源中心</div>
|
|
|
- <div class="my-16px flex-1 flex flex-col h-0">
|
|
|
- <Radio.Group class="!mx-16px">
|
|
|
+ <div class="m-16px flex-1 flex flex-col h-0">
|
|
|
+ <Radio.Group>
|
|
|
<Radio.Button>模板</Radio.Button>
|
|
|
<Radio.Button>组件</Radio.Button>
|
|
|
</Radio.Group>
|
|
|
- <div class="p-16px space-y-10px flex-1 scrollbar ">
|
|
|
- {Object.entries(editor.config.compUI).map(([compKey, uiOpt], i) => {
|
|
|
+ <div class="text-16px font-bold my-16px">基础组件</div>
|
|
|
+ <Container
|
|
|
+ class={basicStyle}
|
|
|
+ orientation="horizontal"
|
|
|
+ behaviour="copy"
|
|
|
+ group-name="canvas"
|
|
|
+ get-child-payload={(index: number) => {
|
|
|
+ return Object.keys(basicUI)[index];
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {Object.entries(basicUI).map(([compKey, uiOpt]) => {
|
|
|
return (
|
|
|
- <div
|
|
|
- class="text-center leading-50px bg-dark-50 rounded"
|
|
|
- key={i}
|
|
|
- onClick={() =>
|
|
|
- editor.actions.addCompToDesign(compKey as ICompKeys)
|
|
|
- }
|
|
|
- >
|
|
|
- <img class="w-full rounded" src={uiOpt.options.thumbnail} alt="封面图" />
|
|
|
- {/* {uiOpt.options.name} */}
|
|
|
- </div>
|
|
|
+ <Draggable key={compKey}>
|
|
|
+ <div
|
|
|
+ class="draggable-item text-center"
|
|
|
+ onClick={() =>
|
|
|
+ editor.actions.addCompToDesign(compKey as ICompKeys)
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ class="w-full rounded pointer-events-none"
|
|
|
+ src={uiOpt.options.thumbnail}
|
|
|
+ alt="封面图"
|
|
|
+ />
|
|
|
+ {uiOpt.options.name}
|
|
|
+ </div>
|
|
|
+ </Draggable>
|
|
|
);
|
|
|
})}
|
|
|
- </div>
|
|
|
+ </Container>
|
|
|
+ <div class="text-16px font-bold my-16px">模块组件</div>
|
|
|
+ <Container
|
|
|
+ class="-mx-16px p-16px space-y-10px flex-1 scrollbar"
|
|
|
+ behaviour="copy"
|
|
|
+ group-name="canvas"
|
|
|
+ get-child-payload={(index: number) => {
|
|
|
+ return Object.keys(editor.config.compUI)[index];
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {Object.entries(editor.config.compUI).map(([compKey, uiOpt]) => {
|
|
|
+ return (
|
|
|
+ <Draggable>
|
|
|
+ <div
|
|
|
+ class="text-center leading-50px bg-dark-50 rounded draggable-item"
|
|
|
+ key={compKey}
|
|
|
+ onClick={() =>
|
|
|
+ editor.actions.addCompToDesign(compKey as ICompKeys)
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ class="w-full rounded pointer-events-none"
|
|
|
+ src={uiOpt.options.thumbnail}
|
|
|
+ alt="封面图"
|
|
|
+ />
|
|
|
+ {/* {uiOpt.options.name} */}
|
|
|
+ </div>
|
|
|
+ </Draggable>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </Container>
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|
|
|
},
|
|
|
});
|
|
|
+
|
|
|
+const basicStyle = css`
|
|
|
+ margin: -10px;
|
|
|
+ border-spacing: 10px;
|
|
|
+`;
|