feat(scene-editor): 优化多楼层场景保存逻辑,为每个楼层注入楼层号,增强数据完整性

This commit is contained in:
xudan 2025-10-22 10:19:01 +08:00
parent 7d0abea45e
commit e7e53a9622

View File

@ -139,7 +139,20 @@ const saveScene = async (payload?: SaveScenePayload) => {
let dataToSave: string | undefined;
if (floorScenes.value.length > 1) {
dataToSave = JSON.stringify(floorScenes.value);
// JSON floor 1
const floorsWithIndex = floorScenes.value.map((scene: any, idx: number) => {
try {
const obj = typeof scene === 'string' ? JSON.parse(scene) : scene;
if (obj && typeof obj === 'object') {
return { ...obj, floor: idx + 1 };
}
return obj;
} catch {
//
return scene;
}
});
dataToSave = JSON.stringify(floorsWithIndex);
} else {
const singleScene = floorScenes.value[0];
if (typeof singleScene === 'string') {