恢复挂载行为树请求
This commit is contained in:
@@ -72,7 +72,7 @@ import { createGraphScenarioElement, createGraphTaskElementFromScenario } from '
|
|||||||
|
|
||||||
import PlatformCard from './platform-card.vue';
|
import PlatformCard from './platform-card.vue';
|
||||||
import NodesCard from './nodes-card.vue';
|
import NodesCard from './nodes-card.vue';
|
||||||
import { findOneScenarioById, saveScenario, findRelations } from './api';
|
import { findOneScenarioById, saveScenario, findRelations, getAllBehaviorTreesBySceneId } from './api';
|
||||||
import { resolveConnectionRelation } from './relation';
|
import { resolveConnectionRelation } from './relation';
|
||||||
import { generateRandomCommunicationData } from './random-data-generator';
|
import { generateRandomCommunicationData } from './random-data-generator';
|
||||||
import { convertRecordsToGraphContainer, type CommunicationRecord } from './data-converter';
|
import { convertRecordsToGraphContainer, type CommunicationRecord } from './data-converter';
|
||||||
@@ -241,9 +241,11 @@ export default defineComponent({
|
|||||||
|
|
||||||
currentScenarioEditing.value = true;
|
currentScenarioEditing.value = true;
|
||||||
|
|
||||||
// 如果场景有ID且没有已保存的图数据,尝试从后端加载通信关系
|
// 并行加载通信关系和行为树列表
|
||||||
if (scenario.id > 0 && !nodeGraph) {
|
if (scenario.id > 0) {
|
||||||
try {
|
try {
|
||||||
|
// 1. 加载通信关系(如果没有已保存的图数据)
|
||||||
|
if (!nodeGraph) {
|
||||||
message.loading({ content: '正在加载通信关系...', key: 'loading-relations' });
|
message.loading({ content: '正在加载通信关系...', key: 'loading-relations' });
|
||||||
const response = await findRelations(scenario.id);
|
const response = await findRelations(scenario.id);
|
||||||
|
|
||||||
@@ -288,9 +290,25 @@ export default defineComponent({
|
|||||||
} else {
|
} else {
|
||||||
message.warning({ content: '该场景暂无通信关系数据', key: 'loading-relations' });
|
message.warning({ content: '该场景暂无通信关系数据', key: 'loading-relations' });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 加载行为树列表并缓存到graph对象
|
||||||
|
const treesResponse = await getAllBehaviorTreesBySceneId(scenario.id);
|
||||||
|
if (treesResponse.code === 200 && treesResponse.data) {
|
||||||
|
console.log('[communication] 行为树列表加载完成:', treesResponse.data.length, '个');
|
||||||
|
// 将行为树列表存储到graph对象中供node.vue使用
|
||||||
|
if (graph.value) {
|
||||||
|
(graph.value as any).behaviorTrees = treesResponse.data;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('[communication] 行为树列表加载失败或为空');
|
||||||
|
if (graph.value) {
|
||||||
|
(graph.value as any).behaviorTrees = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('从后端加载通信关系失败:', error);
|
console.error('从后端加载数据失败:', error);
|
||||||
message.error({ content: '加载通信关系失败,请手动点击"从后端加载"', key: 'loading-relations' });
|
message.error({ content: '加载数据失败', key: 'loading-relations' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user