From 2bc4ac1d3403269b9f0e8bed09244c0ed3efd861 Mon Sep 17 00:00:00 2001 From: luoer Date: Tue, 10 Oct 2023 17:46:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=BB=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/components/ImagePicker.vue | 16 ++ src/components/editor/config/block.ts | 35 +++ src/components/editor/config/blocker.ts | 26 +++ src/components/editor/config/container.ts | 11 + src/components/editor/config/context.ts | 15 ++ src/components/editor/config/index.ts | 5 +- src/components/editor/index.vue | 39 +++- src/components/editor/items/index.ts | 11 + src/components/editor/items/text/index.ts | 23 +- src/components/editor/items/text/option.vue | 74 +++++++ src/components/editor/panel-left/index.vue | 45 ++-- .../editor/panel-main/components/block.vue | 60 +++++ .../editor/panel-main/components/header.vue | 93 ++++++++ src/components/editor/panel-main/index.vue | 208 ++++++++++-------- src/components/editor/panel-right/index.vue | 9 +- .../editor/panel-right/text-attr.vue | 6 +- src/types/auto-component.d.ts | 17 +- 17 files changed, 567 insertions(+), 126 deletions(-) create mode 100644 src/components/editor/components/ImagePicker.vue create mode 100644 src/components/editor/config/block.ts create mode 100644 src/components/editor/config/blocker.ts create mode 100644 src/components/editor/config/container.ts create mode 100644 src/components/editor/config/context.ts create mode 100644 src/components/editor/items/index.ts create mode 100644 src/components/editor/panel-main/components/block.vue create mode 100644 src/components/editor/panel-main/components/header.vue diff --git a/src/components/editor/components/ImagePicker.vue b/src/components/editor/components/ImagePicker.vue new file mode 100644 index 0000000..8079942 --- /dev/null +++ b/src/components/editor/components/ImagePicker.vue @@ -0,0 +1,16 @@ + + + + + diff --git a/src/components/editor/config/block.ts b/src/components/editor/config/block.ts new file mode 100644 index 0000000..4123ef4 --- /dev/null +++ b/src/components/editor/config/block.ts @@ -0,0 +1,35 @@ +export interface Block { + id: string; + type: string; + x: number; + y: number; + w: number; + h: number; + xFixed: boolean; + yFixed: boolean; + bgImage?: string; + bgColor?: string; + data: T; + meta: Record; + actived: false, + resizable: boolean, + draggable: boolean, +} + +export const DefaultBlock: Block = { + id: "", + type: "", + x: 0, + y: 0, + w: 50, + h: 50, + xFixed: false, + yFixed: false, + bgImage: "", + bgColor: "", + data: {}, + meta: {}, + actived: false, + resizable: true, + draggable: true, +}; diff --git a/src/components/editor/config/blocker.ts b/src/components/editor/config/blocker.ts new file mode 100644 index 0000000..dbb8d3b --- /dev/null +++ b/src/components/editor/config/blocker.ts @@ -0,0 +1,26 @@ +import { Component } from "vue"; +import { Block } from "./block"; + +interface Blocker { + /** + * 组件默认值 + */ + initial: Block; + /** + * 渲染组件 + */ + render: Component; + /** + * 配置组件 + */ + option: Component; +} + +/** + * 定义组件 + * @param blocker 参数 + * @returns + */ +export const defineBlocker = (blocker: Blocker) => { + return blocker; +}; diff --git a/src/components/editor/config/container.ts b/src/components/editor/config/container.ts new file mode 100644 index 0000000..e4722f3 --- /dev/null +++ b/src/components/editor/config/container.ts @@ -0,0 +1,11 @@ + +export interface Container { + id: number | string; + title: string; + description?: string; + width: number; + height: number; + bgImage?: string; + bgColor?: string; + zoom: number; +} diff --git a/src/components/editor/config/context.ts b/src/components/editor/config/context.ts new file mode 100644 index 0000000..1a3f228 --- /dev/null +++ b/src/components/editor/config/context.ts @@ -0,0 +1,15 @@ +import { InjectionKey, Ref } from "vue"; +import { Block } from "./block"; +import { Container } from "./container"; + +export interface Context { + current: { + block: Block; + }; + blocks: Ref; + container: Ref; + setCurrentBlock: (block: Block) => void; +} + +export const ContextKey = Symbol('ContextKey') as InjectionKey; + diff --git a/src/components/editor/config/index.ts b/src/components/editor/config/index.ts index 4c2558a..8a0cef9 100644 --- a/src/components/editor/config/index.ts +++ b/src/components/editor/config/index.ts @@ -1 +1,4 @@ -export const ContextKey = Symbol('ContextKey'); \ No newline at end of file +export * from './block'; +export * from './blocker'; +export * from './container'; +export * from './context'; \ No newline at end of file diff --git a/src/components/editor/index.vue b/src/components/editor/index.vue index 751e933..941940b 100644 --- a/src/components/editor/index.vue +++ b/src/components/editor/index.vue @@ -20,20 +20,47 @@ diff --git a/src/components/editor/panel-left/index.vue b/src/components/editor/panel-left/index.vue index a9664a5..97bce3a 100644 --- a/src/components/editor/panel-left/index.vue +++ b/src/components/editor/panel-left/index.vue @@ -10,24 +10,12 @@ - Menu 2 - - - - Menu 3 - - - - Menu 4 + 当前组件 -
+
diff --git a/src/components/editor/panel-main/components/block.vue b/src/components/editor/panel-main/components/block.vue new file mode 100644 index 0000000..4f2f196 --- /dev/null +++ b/src/components/editor/panel-main/components/block.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/components/editor/panel-main/components/header.vue b/src/components/editor/panel-main/components/header.vue new file mode 100644 index 0000000..6578e8f --- /dev/null +++ b/src/components/editor/panel-main/components/header.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/src/components/editor/panel-main/index.vue b/src/components/editor/panel-main/index.vue index cf44e4f..bb130a5 100644 --- a/src/components/editor/panel-main/index.vue +++ b/src/components/editor/panel-main/index.vue @@ -1,68 +1,21 @@