From d43b739a9655d110fbc5cec23cead888df2ff4b1 Mon Sep 17 00:00:00 2001 From: SonyLeo <746591437@qq.com> Date: Mon, 6 Jan 2025 19:44:16 -0800 Subject: [PATCH 1/5] fix: resolve the block publish logic --- .../common/component/BlockDeployDialog.vue | 5 +- .../plugins/block/src/js/blockSetting.jsx | 65 ++++++++++--------- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/packages/common/component/BlockDeployDialog.vue b/packages/common/component/BlockDeployDialog.vue index dd2b911f7..0c87db0c9 100644 --- a/packages/common/component/BlockDeployDialog.vue +++ b/packages/common/component/BlockDeployDialog.vue @@ -81,7 +81,7 @@ import { Popover as TinyPopover, FormItem as TinyFormItem } from '@opentiny/vue' -import { useNotify, getMetaApi, META_APP } from '@opentiny/tiny-engine-meta-register' +import { useCanvas, useNotify, getMetaApi, META_APP } from '@opentiny/tiny-engine-meta-register' import { constants } from '@opentiny/tiny-engine-utils' import VueMonaco from './VueMonaco.vue' @@ -172,6 +172,8 @@ export default { const setVisible = (visible) => emit('update:visible', visible) + const { setSaved } = useCanvas() + const deployBlock = async () => { deployBlockRef.value.validate((valid) => { const { publishBlock } = getMetaApi(META_APP.BlockManage) @@ -186,6 +188,7 @@ export default { } publishBlock(params) setVisible(false) + setSaved(true) formState.deployInfo = '' formState.version = '' formState.needToSave = true diff --git a/packages/plugins/block/src/js/blockSetting.jsx b/packages/plugins/block/src/js/blockSetting.jsx index ab7c5c844..4b59a0049 100644 --- a/packages/plugins/block/src/js/blockSetting.jsx +++ b/packages/plugins/block/src/js/blockSetting.jsx @@ -646,42 +646,43 @@ const updateBlock = (block = {}) => { * @returns */ const generateBlockDeps = (children, deps = { scripts: [], styles: new Set() }) => { - children.forEach((child) => { - const component = useMaterial().getMaterial(child.componentName) - - if (!component) return - - const { npm, component: componentName } = component - - if (npm) { - const { package: pkg, exportName, css, version, script } = npm - const currentPkg = deps.scripts.find((item) => item.package === pkg) + if (Array.isArray(children)) { + children.forEach((child) => { + const component = useMaterial().getMaterial(child.componentName) + + if (!component) return + + const { npm, component: componentName } = component + + if (npm) { + const { package: pkg, exportName, css, version, script } = npm + const currentPkg = deps.scripts.find((item) => item.package === pkg) + + if (currentPkg) { + currentPkg.components[componentName] = exportName + } else { + deps.scripts.push({ + package: pkg, + version, + script, + css, + components: { + [componentName]: exportName + } + }) + } - if (currentPkg) { - currentPkg.components[componentName] = exportName - } else { - deps.scripts.push({ - package: pkg, - version, - script, - css, - components: { - [componentName]: exportName - } - }) + if (css) { + deps.styles.add(css) + } } - if (css) { - deps.styles.add(css) + // 递归查找子区块或子组件 + if (child.children) { + generateBlockDeps(child.children, deps) } - } - - // 递归查找子区块或子组件 - if (child.children) { - generateBlockDeps(child.children, deps) - } - }) - + }) + } return deps } From acca71f2af3e099e74c977ca9917d380fe9a7af4 Mon Sep 17 00:00:00 2001 From: SonyLeo <746591437@qq.com> Date: Mon, 6 Jan 2025 22:20:01 -0800 Subject: [PATCH 2/5] fix: add judgment conditions. --- packages/common/component/BlockDeployDialog.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/common/component/BlockDeployDialog.vue b/packages/common/component/BlockDeployDialog.vue index 0c87db0c9..a03841b92 100644 --- a/packages/common/component/BlockDeployDialog.vue +++ b/packages/common/component/BlockDeployDialog.vue @@ -188,7 +188,9 @@ export default { } publishBlock(params) setVisible(false) - setSaved(true) + if (formState.needToSave) { + setSaved(true) + } formState.deployInfo = '' formState.version = '' formState.needToSave = true From 2b2a8af3460787dadeb1b1b1302de9400eb0670c Mon Sep 17 00:00:00 2001 From: SonyLeo <746591437@qq.com> Date: Tue, 7 Jan 2025 04:33:48 -0800 Subject: [PATCH 3/5] fix: optimize judgement condition and return code --- .../common/component/BlockDeployDialog.vue | 11 ++- .../plugins/block/src/js/blockSetting.jsx | 69 ++++++++++--------- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/packages/common/component/BlockDeployDialog.vue b/packages/common/component/BlockDeployDialog.vue index a03841b92..4dbf80dfd 100644 --- a/packages/common/component/BlockDeployDialog.vue +++ b/packages/common/component/BlockDeployDialog.vue @@ -71,7 +71,7 @@