fix: 优化场景加载逻辑,处理空场景和非字符串地图输入,确保菜单配置正确显示

This commit is contained in:
xudan 2025-10-14 14:05:56 +08:00
parent d1e63284da
commit 49f87fd1cb
2 changed files with 7 additions and 1 deletions

View File

@ -117,6 +117,12 @@ function processContextMenu(
// 获取菜单配置
const menuConfig = getMenuConfig(parsedData.type, parsedData, services);
// 如果菜单类型为 'default',则不显示菜单
if (menuConfig.menuType === 'default') {
manager.close(); // 确保菜单已关闭
return;
}
// 更新状态
manager.setState({
visible: true,

View File

@ -80,7 +80,7 @@ export class EditorService extends Meta2d {
detail?: Partial<GroupSceneDetail>,
isImport = false,
): Promise<void> {
const scene: StandardScene = map ? JSON.parse(map) : {};
const scene: StandardScene = (isString(map) ? (map ? JSON.parse(map) : {}) : map) || {};
if (!isEmpty(detail?.group)) {
scene.robotGroups = [detail.group];
scene.robots = detail.robots;