From f315bdfaf1ce3debdcefa58f365cb0aa845cd2ff Mon Sep 17 00:00:00 2001 From: lhuans Date: Thu, 2 Nov 2023 00:54:12 -0700 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E9=A1=B5=E9=9D=A2=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E8=BE=93=E5=87=BA=E9=85=8D=E7=BD=AE=EF=BC=8C=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=86=85=E6=9C=89=E5=86=85=E5=AE=B9=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=9B=BF=E6=8D=A2=E4=B8=BA=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=96=87=E6=A1=88=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/component/MetaCodeEditor.vue | 29 ++++++++++--------- packages/plugins/page/src/PageInputOutput.vue | 15 ++++++++-- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/packages/common/component/MetaCodeEditor.vue b/packages/common/component/MetaCodeEditor.vue index 62f4f653d9..2977b040c8 100644 --- a/packages/common/component/MetaCodeEditor.vue +++ b/packages/common/component/MetaCodeEditor.vue @@ -10,19 +10,19 @@
{{ editorTipsTitle }}
{{ editorState.showEditorDemo ? $t('common.collapseExample') : $t('common.expandExample') }} @@ -35,11 +35,11 @@
{{ editorState.errorMsg }}
@@ -273,8 +273,9 @@ export default { } .full-width { border: 1px solid #adb0b8; - border-radius: 2px; + border-radius: 6px; padding: 4px 8px; + height: 32px; display: flex; justify-content: space-between; align-items: center; diff --git a/packages/plugins/page/src/PageInputOutput.vue b/packages/plugins/page/src/PageInputOutput.vue index f54967ab33..19dedd2551 100644 --- a/packages/plugins/page/src/PageInputOutput.vue +++ b/packages/plugins/page/src/PageInputOutput.vue @@ -7,22 +7,24 @@ class="life-cycle-alert" > - + - + @@ -86,12 +88,16 @@ export default { } } + const isExitValue = (value) => + (Array.isArray(value) && value.length > 0) || (typeof value === 'object' && Object.keys(value).length > 0) + return { inputValue, outputValue, saveInputValue, saveOutputValue, - pageSettingState + pageSettingState, + isExitValue } } } @@ -120,6 +126,9 @@ export default { .input-output-form { margin-top: 16px; margin-left: 28px; + .item-wrap { + width: 348px; + } :deep(.tiny-form-item) { .tiny-form-item__label { font-size: 14px; From 25e0efc3a1dee72669f1cb97e1f38aee328d846a Mon Sep 17 00:00:00 2001 From: lhuans Date: Thu, 2 Nov 2023 18:34:39 -0700 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E6=96=B9=E6=B3=95=E5=90=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9B=B4=E5=8A=A0=E7=AC=A6=E5=90=88=E8=AF=AD?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugins/page/src/PageInputOutput.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/plugins/page/src/PageInputOutput.vue b/packages/plugins/page/src/PageInputOutput.vue index 19dedd2551..ae3855b1bf 100644 --- a/packages/plugins/page/src/PageInputOutput.vue +++ b/packages/plugins/page/src/PageInputOutput.vue @@ -13,7 +13,7 @@ title="输入配置" button-text="输入配置" language="json" - :buttonShowContent="isExitValue(inputValue)" + :buttonShowContent="hasContent(inputValue)" single @save="saveInputValue" > @@ -24,7 +24,7 @@ title="输出配置" button-text="输出配置" language="json" - :buttonShowContent="isExitValue(outputValue)" + :buttonShowContent="hasContent(outputValue)" single @save="saveOutputValue" > @@ -88,7 +88,7 @@ export default { } } - const isExitValue = (value) => + const hasContent = (value) => (Array.isArray(value) && value.length > 0) || (typeof value === 'object' && Object.keys(value).length > 0) return { @@ -97,7 +97,7 @@ export default { saveInputValue, saveOutputValue, pageSettingState, - isExitValue + hasContent } } } From 13fb4d2911e8fc71775c527c241ef212b47c7341 Mon Sep 17 00:00:00 2001 From: lhuans Date: Sun, 14 Jan 2024 19:17:10 -0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=201.=20=E7=BB=99=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=B9=E5=85=83=E7=B4=A0(=E4=B8=8E?= =?UTF-8?q?=E5=87=BA=E7=A0=81=E3=80=81=E9=A2=84=E8=A7=88=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E4=B8=80=E8=87=B4)=E3=80=822.=20=E9=80=89=E4=B8=AD=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E7=9B=B8=E5=BD=93=E4=BA=8E=E9=80=89=E4=B8=AD=E6=A0=B9?= =?UTF-8?q?=E8=8A=82=E7=82=B9=EF=BC=8C=E5=8F=B3=E4=BE=A7=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=BC=9A=E5=87=BA=E7=8E=B0=E5=8F=AF=E4=BB=A5=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=9A=84=E8=8A=82=E7=82=B9=E3=80=823.=20?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=94=AF=E6=8C=81=E7=BB=99=E6=A0=B9=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=B7=BB=E5=8A=A0=E7=B1=BB=E5=90=8D=EF=BC=8Cid?= =?UTF-8?q?=E3=80=81ref=EF=BC=8C=E5=B9=B6=E4=BF=AE=E6=94=B9=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E3=80=82=204.=20=E6=94=AF=E6=8C=81=E7=BB=99=E6=A0=B9?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=B7=BB=E5=8A=A0=E4=BA=8B=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/render/RenderMain.js | 11 ++++++--- packages/controller/src/useProperties.js | 24 +++++++++++++++---- packages/design-core/src/DesignCanvas.vue | 16 ++++++++++--- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/packages/canvas/src/components/render/RenderMain.js b/packages/canvas/src/components/render/RenderMain.js index 532821b706..922b354b80 100644 --- a/packages/canvas/src/components/render/RenderMain.js +++ b/packages/canvas/src/components/render/RenderMain.js @@ -376,6 +376,13 @@ export default { ) }, render() { + // 渲染画布增加根节点,与出码和预览保持一致 + const rootChildrenSchema = { + componentName: 'div', + props: schema.props, + children: schema.children + } + return h( 'tiny-i18n-host', { @@ -384,9 +391,7 @@ export default { ref: 'page', className: 'design-page' }, - schema.children?.length - ? schema.children.map((child) => h(renderer, { schema: child, parent: schema })) - : [h(CanvasEmpty)] + schema.children?.length ? h(renderer, { schema: rootChildrenSchema, parent: schema }) : [h(CanvasEmpty)] ) } } diff --git a/packages/controller/src/useProperties.js b/packages/controller/src/useProperties.js index 81e132aed7..a1fb135e29 100644 --- a/packages/controller/src/useProperties.js +++ b/packages/controller/src/useProperties.js @@ -12,10 +12,12 @@ import { toRaw, nextTick, shallowReactive, ref } from 'vue' import { getNode, setState, updateRect } from '@opentiny/tiny-engine-canvas' +import { constants } from '@opentiny/tiny-engine-utils' import useCanvas from './useCanvas' import useResource from './useResource' import useTranslate from './useTranslate' +const { COMPONENT_NAME } = constants const propsUpdateKey = ref(0) const otherBaseKey = { @@ -150,11 +152,19 @@ const properties = shallowReactive({ parent: null }) +const isPageOrBlock = (schema) => + schema.componentName === COMPONENT_NAME.Block || schema.componentName === COMPONENT_NAME.Page + const getProps = (schema, parent) => { - // 现在选中的节点和当前节点一样,不需要重新计算 - if (schema && properties.schema !== schema) { + // 1 现在选中的节点和当前节点一样,不需要重新计算, 2 默认进来由于scheme和properities.schema相等,因此判断如果是“页面或者区块”需要进入if判断 + if (schema && (properties.schema !== schema || isPageOrBlock(schema))) { const { props, componentName } = schema - const { schema: metaSchema, content, properties } = useResource().getMaterial(componentName) + // 若选中的是page或者 blcok,没有对应schema,ComponentName 给 div 设置根节点属性 + const { + schema: metaSchema, + content, + properties + } = useResource().getMaterial(isPageOrBlock(schema) ? 'div' : componentName) const schemaProps = properties || metaSchema?.properties || content?.schema?.properties || [] const propGroups = [...schemaProps] @@ -183,8 +193,14 @@ const setProp = (name, value) => { } // 没有父级,或者不在节点上面,要更新内容。就用setState - getNode(properties.schema.id, true).parent || setState(useCanvas().getPageSchema().state) + getNode(properties.schema.id, true)?.parent || setState(useCanvas().getPageSchema().state) propsUpdateKey.value++ + + // 更新根节点props不用updateRect + if (!properties.schema.id) { + return + } + nextTick(updateRect) } diff --git a/packages/design-core/src/DesignCanvas.vue b/packages/design-core/src/DesignCanvas.vue index d76bee21c5..303f0d39c2 100644 --- a/packages/design-core/src/DesignCanvas.vue +++ b/packages/design-core/src/DesignCanvas.vue @@ -15,7 +15,14 @@