Skip to content

Commit

Permalink
fix: resolve some schema update issue (#956)
Browse files Browse the repository at this point in the history
* fix: resolve some schema update issue

1. 调整画布宽度时,画布选中框不及时更新的 bug
2. 空页面的时候,拖拽组件到画布提示两次新建页面的 bug
3. importSchema 的时候,清空选择
4. 页面 schema 保存的时候,设置保存状态为 false
5. 增强 AdvanceConfig 配置对 props 的容错

* fix: updateRect async change to callback style

* fix: first time enter app should show empty page warning
  • Loading branch information
chilingling authored Dec 25, 2024
1 parent 526cfd4 commit bc0eb01
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/canvas/DesignCanvas/src/DesignCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ export default {
// 1. 页面或区块状态是未保存状态(尝试编辑)
// 2. 页面刷新或第一次进入页面(含从别的页面或区块切换到别的页面或区块)
// 3. 页面上已经有弹窗,不允许重复弹窗
// 4. 当前历史堆栈为0,且当前未保存状态和上一次未保存状态不一致,不重复弹窗
const showConfirm = !isSaved || pageSchema !== oldPageSchema
if (!showConfirm || showModal) {
if (!showConfirm || showModal || (useHistory().historyState?.index === 0 && isSaved !== oldIsSaved)) {
return
}
Expand Down
2 changes: 2 additions & 0 deletions packages/canvas/DesignCanvas/src/api/useCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ const importSchema = (data) => {
resetCanvasState({
pageSchema: importData
})

canvasApi.value?.clearSelect?.()
}

const exportSchema = () => {
Expand Down
11 changes: 10 additions & 1 deletion packages/canvas/container/src/components/CanvasResize.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</template>
<script>
import { ref, computed, watch, nextTick } from 'vue'
import { useLayout } from '@opentiny/tiny-engine-meta-register'
import { useLayout, useCanvas } from '@opentiny/tiny-engine-meta-register'
import { canvasState } from '../container'
export default {
Expand Down Expand Up @@ -106,6 +106,15 @@ export default {
{ flush: 'post' }
)
watch(
() => sizeStyle.value,
() => {
nextTick(() => {
useCanvas().canvasApi.value?.updateRect?.()
})
}
)
return {
onMouseDown,
onMouseMove,
Expand Down
6 changes: 5 additions & 1 deletion packages/plugins/schema/src/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ export default {
componentName: pageState.pageSchema.componentName
}
useCanvas().importSchema(value)
const { importSchema, setSaved } = useCanvas()
importSchema(value)
setSaved(false)
// TODO: 历史堆栈
// useHistory().addHistory()
state.pageData = ''
Expand Down
2 changes: 1 addition & 1 deletion packages/settings/events/src/components/AdvanceConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default {
}
const isNumber = Number(value).toString() !== 'NaN'
let newPropsKey = schema.props.key
let newPropsKey = schema.props?.key
if (value && !isNumber) {
newPropsKey = {
Expand Down

0 comments on commit bc0eb01

Please sign in to comment.