fix(editor): runtimeUrl更新后需要重新设置runtime的dsl

This commit is contained in:
roymondchen 2025-07-24 11:24:36 +08:00
parent 01b7b58065
commit d31a544a23
2 changed files with 23 additions and 21 deletions

View File

@ -129,7 +129,7 @@
<script lang="ts" setup>
import { EventEmitter } from 'events';
import { provide, watch } from 'vue';
import { provide } from 'vue';
import type { MApp } from '@tmagic/core';
@ -211,22 +211,6 @@ const stageOptions: StageOptions = {
stageOverlayService.set('stageOptions', stageOptions);
watch(
() => props.runtimeUrl,
(url) => {
if (!url) {
return;
}
const stage = editorService.get('stage');
if (!stage) {
return;
}
stage.reloadIframe(url);
},
);
provide('services', services);
provide('codeOptions', props.codeOptions);

View File

@ -347,6 +347,26 @@ export const initServiceEvents = (
},
);
watch(
() => props.runtimeUrl,
(url) => {
if (!url) {
return;
}
const stage = editorService.get('stage');
if (!stage) {
return;
}
stage.reloadIframe(url);
stage.renderer?.once('runtime-ready', (runtime) => {
runtime.updateRootConfig?.(cloneDeep(toRaw(editorService.get('root')))!);
});
},
);
const getStage = (): Promise<StageCore> => {
const stage = editorService.get('stage');
if (stage) {
@ -434,7 +454,7 @@ export const initServiceEvents = (
delete value.dataSourceCondDeps;
}
const handler = async () => {
(async () => {
const nodeId = editorService.get('node')?.id || props.defaultSelected;
let node;
if (nodeId) {
@ -453,9 +473,7 @@ export const initServiceEvents = (
if (toRaw(value) !== toRaw(preValue)) {
emit('update:modelValue', value);
}
};
handler();
})();
};
// 新增节点,收集依赖