Skip to content

Commit 610a46c

Browse files
committed
feat: 适配嵌套 Config
1 parent ff77066 commit 610a46c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

SuperAutoIsland.Frontend/src/blockly/utils/superGenerator.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export function addMetaBlock(metadata: Metadata) {
140140
isReporter: metadata.isRule,
141141
},
142142
(block, generator) => {
143-
let argsCode = '{';
143+
let argsCode = '(() => { let a = {};';
144144
for (let [argName, argType] of args) {
145145
let value;
146146
switch (argType) {
@@ -156,9 +156,17 @@ export function addMetaBlock(metadata: Metadata) {
156156
value = { TRUE: true, FALSE: false }[value as "TRUE" | "FALSE"];
157157
break;
158158
}
159-
argsCode += `${argName}: ${value}, `;
159+
160+
if (argName.includes(".")) {
161+
const parts = argName.split(".");
162+
for (let i = 1; i < parts.length; i++) {
163+
const path = parts.slice(0, i).join(".");
164+
argsCode += `if (!a.${path}) a.${path} = {};\n`;
165+
}
166+
}
167+
argsCode += `a.${argName} = ${value};`;
160168
}
161-
argsCode += '}';
169+
argsCode += 'return a; })()';
162170

163171
if (metadata.isRule) {
164172
return [`await getRuleState("${metadata.id}", ${argsCode})\n`, Order.MEMBER];

0 commit comments

Comments
 (0)