修复实体更新失效bug
This commit is contained in:
47
src/App.vue
47
src/App.vue
@@ -908,6 +908,10 @@ export default {
|
|||||||
const objectProperties = ref({});
|
const objectProperties = ref({});
|
||||||
const attachedComponentJson = ref([]);
|
const attachedComponentJson = ref([]);
|
||||||
|
|
||||||
|
// 实体编辑器JSON内容缓存
|
||||||
|
const entityJsonContent = ref('');
|
||||||
|
const componentsJsonContent = ref('');
|
||||||
|
|
||||||
// 默认配置和编辑器选项
|
// 默认配置和编辑器选项
|
||||||
const defaultSbpcfgHex = '04000000e5ffffff5300610074006900730066006100630074006f00720079002000dd84fe56167f918f6856d89ea48b73006200700063006600670000000e0300000000803f0000803f0000803f0000803f300000002f47616d652f466163746f727947616d652f2d5368617265642f426c75657072696e742f49636f6e4c696272617279000c00000049636f6e4c69627261727900010000000000000000000000000000000000000000';
|
const defaultSbpcfgHex = '04000000e5ffffff5300610074006900730066006100630074006f00720079002000dd84fe56167f918f6856d89ea48b73006200700063006600670000000e0300000000803f0000803f0000803f0000803f300000002f47616d652f466163746f727947616d652f2d5368617265642f426c75657072696e742f49636f6e4c696272617279000c00000049636f6e4c69627261727900010000000000000000000000000000000000000000';
|
||||||
|
|
||||||
@@ -958,7 +962,7 @@ export default {
|
|||||||
set: (value) => jsonEditorContent.value = value
|
set: (value) => jsonEditorContent.value = value
|
||||||
});
|
});
|
||||||
|
|
||||||
// 实体编辑器计算属性(保留进阶编辑功能)
|
// 实体编辑器计算属性(修复setter问题)
|
||||||
const filteredEntities = computed(() =>
|
const filteredEntities = computed(() =>
|
||||||
blueprintData.value.objects.filter(entity => entity?.type === 'SaveEntity')
|
blueprintData.value.objects.filter(entity => entity?.type === 'SaveEntity')
|
||||||
);
|
);
|
||||||
@@ -967,14 +971,29 @@ export default {
|
|||||||
selectedEntityIndex.value !== null ? filteredEntities.value[selectedEntityIndex.value] : null
|
selectedEntityIndex.value !== null ? filteredEntities.value[selectedEntityIndex.value] : null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 修复:恢复正确的getter/setter逻辑
|
||||||
const entityJson = computed({
|
const entityJson = computed({
|
||||||
get: () => selectedEntity.value ? JSON.stringify(selectedEntity.value, null, 2) : '',
|
get: () => {
|
||||||
set: (value) => {} // 将在更新按钮点击时处理
|
if (entityJsonContent.value) {
|
||||||
|
return entityJsonContent.value;
|
||||||
|
}
|
||||||
|
return selectedEntity.value ? JSON.stringify(selectedEntity.value, null, 2) : '';
|
||||||
|
},
|
||||||
|
set: (value) => {
|
||||||
|
entityJsonContent.value = value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const componentsJson = computed({
|
const componentsJson = computed({
|
||||||
get: () => selectedEntity.value?.components ? JSON.stringify(selectedEntity.value.components, null, 2) : '',
|
get: () => {
|
||||||
set: (value) => {} // 将在更新按钮点击时处理
|
if (componentsJsonContent.value) {
|
||||||
|
return componentsJsonContent.value;
|
||||||
|
}
|
||||||
|
return selectedEntity.value?.components ? JSON.stringify(selectedEntity.value.components, null, 2) : '';
|
||||||
|
},
|
||||||
|
set: (value) => {
|
||||||
|
componentsJsonContent.value = value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const attachedComponents = computed(() =>
|
const attachedComponents = computed(() =>
|
||||||
@@ -1064,6 +1083,8 @@ export default {
|
|||||||
selectedEntityIndex.value = null;
|
selectedEntityIndex.value = null;
|
||||||
activeTab.value = 'raw';
|
activeTab.value = 'raw';
|
||||||
jsonEditorContent.value = lastValidJson.value = '';
|
jsonEditorContent.value = lastValidJson.value = '';
|
||||||
|
entityJsonContent.value = '';
|
||||||
|
componentsJsonContent.value = '';
|
||||||
blueprintData.value = createEmptyBlueprintData();
|
blueprintData.value = createEmptyBlueprintData();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1078,6 +1099,8 @@ export default {
|
|||||||
selectedEntityIndex.value = null;
|
selectedEntityIndex.value = null;
|
||||||
activeTab.value = 'raw';
|
activeTab.value = 'raw';
|
||||||
jsonEditorContent.value = '';
|
jsonEditorContent.value = '';
|
||||||
|
entityJsonContent.value = '';
|
||||||
|
componentsJsonContent.value = '';
|
||||||
hasJsonChanges.value = false;
|
hasJsonChanges.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1367,10 +1390,13 @@ export default {
|
|||||||
updateBlueprintData(validation.data);
|
updateBlueprintData(validation.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 实体编辑器方法(保留进阶编辑功能)
|
// 实体编辑器方法(修复更新实体按钮失效问题)
|
||||||
const selectEntity = (index) => {
|
const selectEntity = (index) => {
|
||||||
selectedEntityIndex.value = index;
|
selectedEntityIndex.value = index;
|
||||||
activeTab.value = 'raw';
|
activeTab.value = 'raw';
|
||||||
|
// 清除缓存内容,确保显示最新数据
|
||||||
|
entityJsonContent.value = '';
|
||||||
|
componentsJsonContent.value = '';
|
||||||
initObjectProperties();
|
initObjectProperties();
|
||||||
initAttachedComponentJson();
|
initAttachedComponentJson();
|
||||||
};
|
};
|
||||||
@@ -1394,15 +1420,18 @@ export default {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 修复:使用缓存内容而不是计算属性
|
||||||
const updateEntityFromJson = () => {
|
const updateEntityFromJson = () => {
|
||||||
try {
|
try {
|
||||||
const updatedEntity = JSON.parse(entityJson.value);
|
const updatedEntity = JSON.parse(entityJsonContent.value || entityJson.value);
|
||||||
const originalIndex = blueprintData.value.objects.findIndex(
|
const originalIndex = blueprintData.value.objects.findIndex(
|
||||||
e => e.instanceName === selectedEntity.value.instanceName
|
e => e.instanceName === selectedEntity.value.instanceName
|
||||||
);
|
);
|
||||||
|
|
||||||
if (originalIndex !== -1) {
|
if (originalIndex !== -1) {
|
||||||
blueprintData.value.objects[originalIndex] = updatedEntity;
|
blueprintData.value.objects[originalIndex] = updatedEntity;
|
||||||
|
// 清除缓存,确保下次显示更新后的数据
|
||||||
|
entityJsonContent.value = '';
|
||||||
initObjectProperties();
|
initObjectProperties();
|
||||||
syncJsonDisplay();
|
syncJsonDisplay();
|
||||||
jsonEditStatus.value = '实体更新成功,JSON已同步';
|
jsonEditStatus.value = '实体更新成功,JSON已同步';
|
||||||
@@ -1415,9 +1444,11 @@ export default {
|
|||||||
|
|
||||||
const updateComponents = () => {
|
const updateComponents = () => {
|
||||||
try {
|
try {
|
||||||
const updatedComponents = JSON.parse(componentsJson.value);
|
const updatedComponents = JSON.parse(componentsJsonContent.value || componentsJson.value);
|
||||||
if (selectedEntity.value) {
|
if (selectedEntity.value) {
|
||||||
selectedEntity.value.components = updatedComponents;
|
selectedEntity.value.components = updatedComponents;
|
||||||
|
// 清除缓存,确保下次显示更新后的数据
|
||||||
|
componentsJsonContent.value = '';
|
||||||
syncJsonDisplay();
|
syncJsonDisplay();
|
||||||
jsonEditStatus.value = '组件更新成功,JSON已同步';
|
jsonEditStatus.value = '组件更新成功,JSON已同步';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user