fix(editor): 页面切换不在重新渲染画布

This commit is contained in:
roymondchen 2022-11-29 16:58:00 +08:00
parent 239b5d3efe
commit b7934f9f51
2 changed files with 11 additions and 2 deletions

View File

@ -27,7 +27,7 @@
</template>
<script lang="ts" setup name="MEditorStage">
import { computed, inject, markRaw, onMounted, onUnmounted, ref, toRaw, watch, watchEffect } from 'vue';
import { computed, inject, markRaw, nextTick, onMounted, onUnmounted, ref, toRaw, watch, watchEffect } from 'vue';
import { cloneDeep } from 'lodash-es';
import type { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
@ -96,6 +96,15 @@ watch(root, (root) => {
}
});
watch(page, (page) => {
if (runtime && page) {
runtime.updatePageId?.(page.id);
nextTick(() => {
stage?.select(page.id);
});
}
});
const resizeObserver = new ResizeObserver((entries) => {
for (const { contentRect } of entries) {
services?.uiService.set('stageContainerRect', {

View File

@ -3,7 +3,7 @@
<Breadcrumb></Breadcrumb>
<slot name="stage">
<MagicStage :key="page?.id" :stage-content-menu="stageContentMenu"></MagicStage>
<MagicStage v-if="page" :stage-content-menu="stageContentMenu"></MagicStage>
</slot>
<slot name="workspace-content"></slot>