|
@@ -1,81 +1,160 @@
|
|
-import { useEditor } from "@/modules/editor";
|
|
|
|
-import { css } from "@linaria/core";
|
|
|
|
-import { useReactive } from "@queenjs/use";
|
|
|
|
|
|
+import { Button } from "ant-design-vue";
|
|
|
|
+import { computed, reactive } from "vue";
|
|
|
|
+
|
|
|
|
+import { IconImage, IconShape, IconTpl, IconVideo } from "@/assets/icons";
|
|
|
|
+import { css, cx } from "@linaria/core";
|
|
|
|
+import { IconCube } from "@queenjs/icons";
|
|
import { defineUI } from "queenjs";
|
|
import { defineUI } from "queenjs";
|
|
import CustomComps from "./CustomComps";
|
|
import CustomComps from "./CustomComps";
|
|
-import Frames from "./Frames";
|
|
|
|
-import { MySources } from "./MySources";
|
|
|
|
|
|
+import Shapes from "./Shapes";
|
|
|
|
+import { Sources } from "./Sources";
|
|
|
|
+import Templates from "./Templates";
|
|
|
|
+
|
|
|
|
+const tabs = [
|
|
|
|
+ {
|
|
|
|
+ title: "图片",
|
|
|
|
+ icon: IconImage,
|
|
|
|
+ content: [
|
|
|
|
+ {
|
|
|
|
+ title: "平台",
|
|
|
|
+ component: Sources,
|
|
|
|
+ props: { sourceType: "Image", sourceFrom: "system" },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "我的",
|
|
|
|
+ component: Sources,
|
|
|
|
+ props: { sourceType: "Image", sourceFrom: "user" },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "形状",
|
|
|
|
+ icon: IconShape,
|
|
|
|
+ component: Shapes,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "视频",
|
|
|
|
+ icon: IconVideo,
|
|
|
|
+ content: [
|
|
|
|
+ {
|
|
|
|
+ title: "平台",
|
|
|
|
+ component: Sources,
|
|
|
|
+ props: { sourceType: "Video", sourceFrom: "system" },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "我的",
|
|
|
|
+ component: Sources,
|
|
|
|
+ props: { sourceType: "Video", sourceFrom: "user" },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "组件",
|
|
|
|
+ icon: IconCube,
|
|
|
|
+ content: [
|
|
|
|
+ {
|
|
|
|
+ title: "平台",
|
|
|
|
+ component: CustomComps,
|
|
|
|
+ props: { compType: "senior" },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "我的",
|
|
|
|
+ component: CustomComps,
|
|
|
|
+ props: { compType: "user" },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "模板",
|
|
|
|
+ icon: IconTpl,
|
|
|
|
+ component: Templates,
|
|
|
|
+ },
|
|
|
|
+];
|
|
|
|
|
|
export default defineUI({
|
|
export default defineUI({
|
|
setup() {
|
|
setup() {
|
|
- const editor = useEditor();
|
|
|
|
- const { compUICtrl, frameControl } = editor.controls;
|
|
|
|
-
|
|
|
|
- const tabs = [
|
|
|
|
- { label: "模板", value: "frame" },
|
|
|
|
- { label: "平台组件", value: "senior" },
|
|
|
|
- { label: "我的组件", value: "user" },
|
|
|
|
- { label: "我的素材", value: "source" },
|
|
|
|
- ];
|
|
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ const state = reactive({
|
|
|
|
+ tabIndex: 0,
|
|
|
|
+ compIndexs: [0, 0, 0, 0, 0],
|
|
|
|
+ currentTab: computed(() => {
|
|
|
|
+ return tabs[state.tabIndex];
|
|
|
|
+ }),
|
|
|
|
+ currCompIndex: computed(() => {
|
|
|
|
+ return state.compIndexs[state.tabIndex];
|
|
|
|
+ }),
|
|
|
|
+ });
|
|
|
|
|
|
- const state = useReactive(() => ({
|
|
|
|
- currTabType: "frame",
|
|
|
|
- basicComps() {
|
|
|
|
- return ["Text", "Image", "Video", "Web3D"].map(
|
|
|
|
- (key) => compUICtrl.state.components.get(key) as any
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
- currComps() {
|
|
|
|
- return Array.from(compUICtrl.state.components.values()).filter(
|
|
|
|
- (item) => state.currTabType === item.compType
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
- }));
|
|
|
|
|
|
+ return () => {
|
|
|
|
+ const { tabIndex, currentTab, currCompIndex } = state;
|
|
|
|
+ const currComp = currentTab.component
|
|
|
|
+ ? currentTab
|
|
|
|
+ : currentTab.content?.[state.currCompIndex];
|
|
|
|
|
|
- return () => (
|
|
|
|
- <div class="h-full flex flex-col">
|
|
|
|
- <div class="p-16px border-bottom !border-2px">资源中心</div>
|
|
|
|
- <div class="m-16px flex-1 flex flex-col h-0">
|
|
|
|
- <div class={tabStyle}>
|
|
|
|
- {tabs.map((item) => {
|
|
|
|
|
|
+ return (
|
|
|
|
+ <div class="h-full flex">
|
|
|
|
+ <div class="w-70px pt-16px border-right !border-2px">
|
|
|
|
+ {tabs.map((record, index) => {
|
|
return (
|
|
return (
|
|
- <span
|
|
|
|
- class={[state.currTabType === item.value && "checked"]}
|
|
|
|
- onClick={() => (state.currTabType = item.value)}
|
|
|
|
|
|
+ <div
|
|
|
|
+ key={index}
|
|
|
|
+ class={cx(
|
|
|
|
+ tabItem,
|
|
|
|
+ "relative mt-10px py-8px text-center cursor-pointer text-light-50 transition",
|
|
|
|
+ state.tabIndex == index && "active"
|
|
|
|
+ )}
|
|
|
|
+ onClick={() => (state.tabIndex = index)}
|
|
>
|
|
>
|
|
- {item.label}
|
|
|
|
- </span>
|
|
|
|
|
|
+ <record.icon class="text-24px" />
|
|
|
|
+ <div class="text-center mt-2px">{record.title}</div>
|
|
|
|
+ </div>
|
|
);
|
|
);
|
|
})}
|
|
})}
|
|
</div>
|
|
</div>
|
|
- {state.currTabType == "frame" && (
|
|
|
|
- <Frames
|
|
|
|
- class="flex-1 -mx-16px p-16px"
|
|
|
|
- dataSource={frameControl.listCtrl.state.list}
|
|
|
|
- />
|
|
|
|
- )}
|
|
|
|
- {(state.currTabType == "user" || state.currTabType == "senior") && (
|
|
|
|
- <CustomComps
|
|
|
|
- class="flex-1 -mx-16px p-16px"
|
|
|
|
- components={state.currComps}
|
|
|
|
|
|
+ <div class="flex-1 h-1/1 overflow-hidden flex flex-col">
|
|
|
|
+ {currentTab.content && (
|
|
|
|
+ <div class="my-5px ml-10px space-x-10px">
|
|
|
|
+ {currentTab.content?.map((item: any, index: number) => (
|
|
|
|
+ <Button
|
|
|
|
+ key={index}
|
|
|
|
+ type="text"
|
|
|
|
+ class={cx(
|
|
|
|
+ "transition",
|
|
|
|
+ currCompIndex == index && "font-bold"
|
|
|
|
+ )}
|
|
|
|
+ onClick={() => (state.compIndexs[tabIndex] = index)}
|
|
|
|
+ >
|
|
|
|
+ {item?.title}
|
|
|
|
+ </Button>
|
|
|
|
+ ))}
|
|
|
|
+ </div>
|
|
|
|
+ )}
|
|
|
|
+
|
|
|
|
+ <currComp.component
|
|
|
|
+ class="flex-1 h-1/1 px-16px mb-10px overflow-y-auto"
|
|
|
|
+ {...currComp.props}
|
|
/>
|
|
/>
|
|
- )}
|
|
|
|
- {state.currTabType == "source" && (
|
|
|
|
- <MySources class="flex-1 -mx-16px p-16px" />
|
|
|
|
- )}
|
|
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
- );
|
|
|
|
|
|
+ );
|
|
|
|
+ };
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
|
|
-const tabStyle = css`
|
|
|
|
- @apply text-16px my-16px space-x-10px;
|
|
|
|
-
|
|
|
|
- span {
|
|
|
|
- cursor: pointer;
|
|
|
|
- &.checked {
|
|
|
|
- font-weight: bold;
|
|
|
|
|
|
+const tabItem = css`
|
|
|
|
+ &:hover {
|
|
|
|
+ color: @inf-primary-color;
|
|
|
|
+ }
|
|
|
|
+ &.active {
|
|
|
|
+ color: @inf-primary-color;
|
|
|
|
+ &:before {
|
|
|
|
+ content: "";
|
|
|
|
+ position: absolute;
|
|
|
|
+ left: 0;
|
|
|
|
+ top: 0;
|
|
|
|
+ height: 100%;
|
|
|
|
+ width: 3px;
|
|
|
|
+ background-color: @inf-primary-color;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
`;
|