Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimize block code saving and publishing logic #996

Open
wants to merge 5 commits into
base: refactor/develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/common/component/BlockDeployDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
Expand All @@ -186,6 +193,9 @@ export default {
}
publishBlock(params)
setVisible(false)
if (formState.needToSave && isSameBlock()) {
setSaved(true)
}
formState.deployInfo = ''
formState.version = ''
formState.needToSave = true
Expand Down
4 changes: 4 additions & 0 deletions packages/plugins/block/src/js/blockSetting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading