From b7d451b5fb9ccb4cafe605b478eafa9e84423a25 Mon Sep 17 00:00:00 2001 From: sunlizhou <296190577@qq.com> Date: Thu, 30 Nov 2023 17:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=84=E7=A7=8Dconfig?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 353 ++++++++++++---------- src/engineer/components/Canvas.vue | 4 +- src/engineer/configs/BackgroundConfig.vue | 62 ++++ src/engineer/configs/BooleanConfig.vue | 32 ++ src/engineer/configs/ListConfig.vue | 4 +- src/engineer/configs/MarkConfig.vue | 34 +++ src/engineer/configs/ObjectConfig.vue | 35 +++ src/engineer/configs/TextConfig.vue | 3 +- src/engineer/configs/render.ts | 8 + src/engineer/context.ts | 21 +- src/engineer/types.ts | 2 + 11 files changed, 381 insertions(+), 177 deletions(-) diff --git a/src/App.vue b/src/App.vue index 69cd4e6..b58a4de 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,102 +5,107 @@ import DddBuilder, { hash } from './engineer' let nextId = Date.now() -const blocks = ref([{ - vid: hash(`${++nextId}`), - mid: '', - theme: { - radius: 24, - color: 'yellow', - }, - children: { - type: 'text', - key: 'textName', - }, -}, { - vid: hash(`${++nextId}`), - mid: '', - theme: { - color: 'pink', - margin: 12, - flexible: true, - }, - children: { - type: 'image', - key: 'imageKey', - link: 'linkKey', - radius: 24, - }, -}, { - vid: hash(`${++nextId}`), - mid: '', - theme: { - color: '#fafbfc', - margin: 12, - padding: 24, - mainAlign: 'center', - crossAlign: 'center', - flexible: true, - }, - children: { - type: 'audio', - key: 'audioKey', - title: 'title', - }, -}, { - vid: hash(`${++nextId}`), - mid: '', - theme: { - radius: 24, - color: 'teal', - }, - children: [{ - theme: { - flexible: true, - gap: 12, - crossAlign: 'center', - }, - children: [{ - theme: { - padding: 12, - margin: 12, - grow: 1, - }, - children: { - vid: hash(`${++nextId}`), - theme: { - fontSize: 32, - }, - children: 'left', - }, - }, { - vid: hash(`${++nextId}`), - theme: { - width: 'auto', - padding: { - vertical: 4, - horizontal: 12, - }, - color: 'pink', - radius: 16, - }, - children: 'right222', - }, { - theme: { - width: 48, - }, - }], - }], -}, ...Array.from(Array.from({length: 3})).map((_, i) => ({ - vid: hash(`${++nextId}`), - mid: '', - children: [{ - vid: hash(`${++nextId}`), - theme: { - fontSize: 22, - }, - children: `测试${i}`, - }], -}))]) +const blocks = ref([ +// { +// vid: hash(`${++nextId}`), +// mid: '', +// theme: { +// radius: 24, +// color: 'yellow', +// }, +// children: { +// type: 'text', +// key: 'textName', +// }, +// }, { +// vid: hash(`${++nextId}`), +// mid: '', +// theme: { +// color: 'pink', +// margin: 12, +// flexible: true, +// }, +// children: { +// type: 'image', +// key: 'imageKey', +// link: 'linkKey', +// radius: 24, +// }, +// }, { +// vid: hash(`${++nextId}`), +// mid: '', +// theme: { +// color: '#fafbfc', +// margin: 12, +// padding: 24, +// mainAlign: 'center', +// crossAlign: 'center', +// flexible: true, +// }, +// children: { +// type: 'audio', +// key: 'audioKey', +// title: 'title', +// }, +// }, { +// vid: hash(`${++nextId}`), +// mid: '', +// theme: { +// radius: 24, +// color: 'teal', +// }, +// children: [{ +// theme: { +// flexible: true, +// gap: 12, +// crossAlign: 'center', +// }, +// children: [{ +// theme: { +// padding: 12, +// margin: 12, +// grow: 1, +// }, +// children: { +// vid: hash(`${++nextId}`), +// theme: { +// fontSize: 32, +// }, +// children: 'left', +// }, +// }, { +// vid: hash(`${++nextId}`), +// theme: { +// width: 'auto', +// padding: { +// vertical: 4, +// horizontal: 12, +// }, +// color: 'pink', +// radius: 16, +// }, +// children: 'right222', +// }, { +// theme: { +// width: 48, +// }, +// } +// ], +// } +// ], +// }, ...Array.from(Array.from({length: 3})).map((_, i) => ({ +// vid: hash(`${++nextId}`), +// mid: '', +// children: [{ +// vid: hash(`${++nextId}`), +// theme: { +// fontSize: 22, +// }, +// children: `测试${i}`, +// }], +// })) + +]) const categories = ref([{icon: 'trash', text: '媒体'}, {icon: 'trash', text: '图表'}, {icon: 'trash', text: '商品'}, {icon: 'trash', text: '功能'}, {icon: 'trash', text: '素材'}].map(c => ({ ...c, @@ -134,66 +139,84 @@ categories.value.unshift({ maxReferenceCount: -1, referenceCount: 0, image: undefined, - configs: [{ - type: 'list', - field: 'items', - label: '', - help: '最多可添加10张图片,建议宽度750px;鼠标拖拽左侧圆点可调整图片顺序', - addable: true, - configs: [{ - type: 'image', - field: 'image', - // 表示内联数据 - inlines: [{ - type: 'text', - field: 'title', - label: '标题', - help: '选填,不超过 4 个字', - }, { - type: 'text', - field: 'link', - label: '链接', - // help: '请输入链接', // 自动生成:"请输入${label}" + configs: [ + { + type: 'list', + field: 'items', + label: '', + help: '最多可添加10张图片,建议宽度750px;鼠标拖拽左侧圆点可调整图片顺序', + addable: true, + configs: [{ + type: 'image', + field: 'image', + // 表示内联数据 + inlines: [{ + type: 'text', + field: 'title', + label: '标题', + help: '选填,不超过 4 个字', + }, { + type: 'text', + field: 'link', + label: '链接', + // help: '请输入链接', // 自动生成:"请输入${label}" + }], + label: '图片', + required: true, }], - label: '图片', - required: true, - }], - }, { - type: 'object', - field: 'indicator', - label: '指示器', - configs: [{ - type: 'mark', - field: 'style', - label: '指示器样式', - values: [{label: '圆形', value: 'circle'}, {label: '直线', value: 'line'}, {label: '数字', value: 'number'}], - }, { - type: 'mark', - field: 'position', - label: '指示器位置', - values: [{label: '居左', value: 'left'}, {label: '居中', value: 'center'}, {label: '居右', value: 'right'}], - }, { - type: 'color', - field: 'color', - label: '指示器颜色', - }], - }, { - type: 'object', - field: 'background', - label: '背景', - configs: [{ - type: 'bool', - field: 'enabled', - label: '是否显示背景色', - }, { - type: 'background', - field: 'value', - // 背景的不同实现方式,可以在里面添加 image 选项来支持图片 - // 这里只能支持颜色和渐变, - features: ['color', 'gradient'], + }, + { + type: 'object', + field: 'indicator', + label: '指示器', + configs: [{ + type: 'mark', + field: 'style', + label: '指示器样式', + values: [{label: '圆形', value: 'circle'}, {label: '直线', value: 'line'}, {label: '数字', value: 'number'}], + }, { + type: 'mark', + field: 'position', + label: '指示器位置', + values: [{label: '居左', value: 'left'}, {label: '居中', value: 'center'}, {label: '居右', value: 'right'}], + }, + { + type: 'color', + field: 'color', + label: '指示器颜色', + }], + }, + { + type: 'object', + field: 'background', label: '背景', + configs: [{ + type: 'boolean', + field: 'enabled', + label: '是否显示背景色', + }, { + type: 'background', + field: 'value', + // 背景的不同实现方式,可以在里面添加 image 选项来支持图片 + // 这里只能支持颜色和渐变, + features: ['color', 'gradient'], + label: '背景', + }], }], - }], + init: { + items: [ + { + image: '', + // title: '', + // link: '', + } + ], + indicator: { + style: 'circle', + color: '#000000', + position: 'left', + } + }, theme: { height: 200, padding: { @@ -210,7 +233,7 @@ categories.value.unshift({ radius: 12.0, textAlign: 'center', }, - children: '内容', + children: '设置轮播图', }], }, { @@ -259,17 +282,17 @@ categories.value.unshift({ }) const data = ref>>({ - [blocks.value[0].vid]: { - textName: '测试 2222', - }, - [blocks.value[1].vid]: { - imageKey: 'https://www.w3schools.com/css/paris.jpg', - linkKey: 'https://docs.taro.zone/canIUse/', - }, - [blocks.value[2].vid]: { - audioKey: 'https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3', - title: '啊哈哈', - }, + // [blocks.value[0].vid]: { + // textName: '测试 2222', + // }, + // [blocks.value[1].vid]: { + // imageKey: 'https://www.w3schools.com/css/paris.jpg', + // linkKey: 'https://docs.taro.zone/canIUse/', + // }, + // [blocks.value[2].vid]: { + // audioKey: 'https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3', + // title: '啊哈哈', + // }, }) diff --git a/src/engineer/components/Canvas.vue b/src/engineer/components/Canvas.vue index 0c56a6f..3973a67 100644 --- a/src/engineer/components/Canvas.vue +++ b/src/engineer/components/Canvas.vue @@ -1,7 +1,7 @@ + + + diff --git a/src/engineer/configs/BooleanConfig.vue b/src/engineer/configs/BooleanConfig.vue index e69de29..27e439c 100644 --- a/src/engineer/configs/BooleanConfig.vue +++ b/src/engineer/configs/BooleanConfig.vue @@ -0,0 +1,32 @@ + + + diff --git a/src/engineer/configs/ListConfig.vue b/src/engineer/configs/ListConfig.vue index 5dab41e..052fe4b 100644 --- a/src/engineer/configs/ListConfig.vue +++ b/src/engineer/configs/ListConfig.vue @@ -1,6 +1,5 @@ + diff --git a/src/engineer/configs/ObjectConfig.vue b/src/engineer/configs/ObjectConfig.vue index e69de29..c569c03 100644 --- a/src/engineer/configs/ObjectConfig.vue +++ b/src/engineer/configs/ObjectConfig.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/engineer/configs/TextConfig.vue b/src/engineer/configs/TextConfig.vue index 2c1b3f1..4a58e38 100644 --- a/src/engineer/configs/TextConfig.vue +++ b/src/engineer/configs/TextConfig.vue @@ -7,14 +7,13 @@ defineOptions({ }) const props = defineProps<{ - field: string // arr.0.text + field: string label: string help?: string required?: boolean }>() const data = useSource(props.field) -// const text = ref(data.value ?? '')