Skip to content

Commit 0d06c93

Browse files
committed
Merge branch '1.3.x'
2 parents 530c826 + 25f497d commit 0d06c93

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

frontend/src/pages/aippIndex/index.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,45 @@ const AippIndex = () => {
128128
dispatch(setAppInfo(aippRef.current));
129129
}
130130
}
131+
132+
// 遍历 configFormProperties[0].children 的所有子孙节点,按 name 建立映射
133+
const buildNameToNodeMap = (nodes: any[]): Record<string, any> => {
134+
const map: Record<string, any> = {};
135+
136+
const traverse = (node: any) => {
137+
if (node.name) {
138+
map[node.name] = node;
139+
}
140+
if (Array.isArray(node.children)) {
141+
node.children.forEach(traverse);
142+
}
143+
}
144+
nodes.forEach(traverse);
145+
return map;
146+
}
147+
131148
// 保存配置
132149
const saveConfig = (data) => {
133150
updateFormInfo(tenantId, appId, {config: aippRef.current.config, ...data}).then((res) => {
134151
if (res.code === 0) {
135152
dispatch(setTestStatus(null));
136153
setSaveTime(getCurrentTime());
154+
155+
aippRef.current.flowGraph.appearance = JSON.parse(data.graph);
156+
if (aippRef.current?.configFormProperties?.[0]?.children && Array.isArray(data.input)) {
157+
const nodeMap = buildNameToNodeMap(aippRef.current.configFormProperties[0].children);
158+
159+
for (const item of data.input) {
160+
const targetNode = nodeMap[item.name];
161+
if (targetNode) {
162+
// 赋值:用 item.defaultValue 作为当前值(根据你给的数据结构)
163+
targetNode.defaultValue = item.defaultValue;
164+
}
165+
}
166+
}
167+
aippRef.current = JSON.parse(JSON.stringify(aippRef.current));
168+
dispatch(setAppInfo(aippRef.current));
169+
RefreshChatStyle(aippRef.current);
137170
if (inspirationRefresh.current) {
138171
inspirationRefresh.current = false;
139172
let key = getUiD();

0 commit comments

Comments
 (0)