diff --git a/packages/common/component/BlockDeployDialog.vue b/packages/common/component/BlockDeployDialog.vue index dd2b911f7..c86793e3c 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 { useBlock, 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,13 @@ export default { const setVisible = (visible) => emit('update:visible', visible) + const { setSaved } = useCanvas() + + const isSameBlock = () => { + const currentBlock = useBlock().getCurrentBlock() + return props.block?.id === currentBlock?.id + } + const deployBlock = async () => { deployBlockRef.value.validate((valid) => { const { publishBlock } = getMetaApi(META_APP.BlockManage) @@ -186,6 +193,9 @@ export default { } publishBlock(params) setVisible(false) + if (formState.needToSave && isSameBlock()) { + 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..bfa4ac51a 100644 --- a/packages/plugins/block/src/js/blockSetting.jsx +++ b/packages/plugins/block/src/js/blockSetting.jsx @@ -646,6 +646,10 @@ const updateBlock = (block = {}) => { * @returns */ const generateBlockDeps = (children, deps = { scripts: [], styles: new Set() }) => { + if (!Array.isArray(children)) { + return + } + children.forEach((child) => { const component = useMaterial().getMaterial(child.componentName)