mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-20 19:20:37 +08:00
增强 FlowTabs 和变量管理:引入了 VariableManager 组件以更好地处理变量,更新了 ComposerFlow 以支持自定义变量,并改进了 VariableList 中的变量选择界面。增加了切换变量管理的功能,并调整了代码生成以包含参数和局部变量。
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
export function generateCode(flow) {
|
||||
const { commands, name, label } = flow;
|
||||
const { commands, name, label, customVariables = [] } = flow;
|
||||
|
||||
const params = customVariables.filter((v) => v.type === "param") || [];
|
||||
const manualVars =
|
||||
customVariables.filter((v) => v.type === "var") || [];
|
||||
// 检查是否包含异步函数
|
||||
const hasAsyncFunction = commands.some((cmd) => cmd.isAsync);
|
||||
|
||||
@@ -8,8 +12,13 @@ export function generateCode(flow) {
|
||||
|
||||
code.push(`// ${label}`);
|
||||
// 生成函数声明
|
||||
code.push(`${hasAsyncFunction ? "async " : ""}function ${funcName}() {`);
|
||||
code.push(
|
||||
`${hasAsyncFunction ? "async " : ""}function ${funcName}(${params
|
||||
.map((p) => p.name)
|
||||
.join(", ")}) {`
|
||||
);
|
||||
|
||||
code.push(manualVars.map((v) => ` let ${v.name} = ${v.value};`).join("\n"));
|
||||
const indent = " ";
|
||||
|
||||
commands.forEach((cmd) => {
|
||||
|
||||
Reference in New Issue
Block a user