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(block-diff): 修复区块发布是查看差异保存时schema出错的bug #453

Merged
merged 4 commits into from
May 6, 2024
Merged
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
24 changes: 18 additions & 6 deletions packages/common/component/BlockDeployDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
:modal="false"
:fullscreen="true"
:append-to-body="true"
title="Schema 本地与线上差异"
title="Schema 线上与本地差异"
>
<vue-monaco
v-if="state.compareVisible"
Expand Down Expand Up @@ -82,8 +82,9 @@ import {
FormItem as TinyFormItem
} from '@opentiny/vue'
import { theme } from '@opentiny/tiny-engine-controller/adapter'
import { useLayout } from '@opentiny/tiny-engine-controller'
import { useLayout, useNotify } from '@opentiny/tiny-engine-controller'
import { getSchema, setSchema } from '@opentiny/tiny-engine-canvas'
import { constants } from '@opentiny/tiny-engine-utils'
import VueMonaco from './VueMonaco.vue'

export default {
Expand All @@ -106,6 +107,7 @@ export default {
},
emits: ['update:visible'],
setup(props, { emit, attrs }) {
const { COMPONENT_NAME } = constants
const formState = reactive({
deployInfo: '',
version: '',
Expand Down Expand Up @@ -212,10 +214,20 @@ export default {
}

const save = () => {
const pageSchema = JSON.parse(state.newCode)
setSchema(pageSchema)

close()
if (!state.newCode) {
close()
return
}
try {
const pageSchema = JSON.parse(state.newCode)
setSchema({ ...pageSchema, componentName: COMPONENT_NAME.Block })
close()
} catch (err) {
useNotify({
type: 'error',
message: '代码静态检查有错误,请先修改后再保存'
})
}
}

return {
Expand Down
Loading