mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-18 01:44:36 +08:00
统一参数变量命名
This commit is contained in:
@@ -132,7 +132,7 @@ export default defineComponent({
|
|||||||
return `${funcName}(${newArgvs.join(",")})`;
|
return `${funcName}(${newArgvs.join(",")})`;
|
||||||
},
|
},
|
||||||
parseCodeToArgvs(code) {
|
parseCodeToArgvs(code) {
|
||||||
const argvs = window.lodashM.cloneDeep(this.defaultArgvs);
|
let argvs = window.lodashM.cloneDeep(this.defaultArgvs);
|
||||||
if (!code) return argvs;
|
if (!code) return argvs;
|
||||||
|
|
||||||
const variableFormatPaths = [];
|
const variableFormatPaths = [];
|
||||||
@@ -144,12 +144,11 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const { args } = parseFunction(code, { variableFormatPaths });
|
argvs = parseFunction(code, { variableFormatPaths }).argvs;
|
||||||
return args;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("解析参数失败:", e);
|
console.log("解析参数失败:", e);
|
||||||
return argvs;
|
|
||||||
}
|
}
|
||||||
|
return argvs;
|
||||||
},
|
},
|
||||||
getSummary(argvs) {
|
getSummary(argvs) {
|
||||||
// 虽然header里对溢出做了处理,但是这里截断主要是为了节省存储空间
|
// 虽然header里对溢出做了处理,但是这里截断主要是为了节省存储空间
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ export default defineComponent({
|
|||||||
try {
|
try {
|
||||||
const variableFormatPaths = ["arg0.text"];
|
const variableFormatPaths = ["arg0.text"];
|
||||||
const params = parseFunction(code, { variableFormatPaths });
|
const params = parseFunction(code, { variableFormatPaths });
|
||||||
return params.args[0];
|
return params.argvs[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("解析加密参数失败:", e);
|
console.error("解析加密参数失败:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ export default defineComponent({
|
|||||||
if (!result) return this.defaultArgvs;
|
if (!result) return this.defaultArgvs;
|
||||||
|
|
||||||
const operation = result.name.split(".").pop();
|
const operation = result.name.split(".").pop();
|
||||||
const args = result.args;
|
const args = result.argvs;
|
||||||
|
|
||||||
const newArgvs = {
|
const newArgvs = {
|
||||||
...this.defaultArgvs,
|
...this.defaultArgvs,
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ export default defineComponent({
|
|||||||
try {
|
try {
|
||||||
const variableFormatPaths = ["arg0.text"];
|
const variableFormatPaths = ["arg0.text"];
|
||||||
const params = parseFunction(code, { variableFormatPaths });
|
const params = parseFunction(code, { variableFormatPaths });
|
||||||
return params.args[0];
|
return params.argvs[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("解析加密参数失败:", e);
|
console.error("解析加密参数失败:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ export default defineComponent({
|
|||||||
if (!result) return this.defaultArgvs;
|
if (!result) return this.defaultArgvs;
|
||||||
|
|
||||||
const operation = result.name.split(".").pop();
|
const operation = result.name.split(".").pop();
|
||||||
const [data, method, options] = result.args;
|
const [data, method, options] = result.argvs;
|
||||||
|
|
||||||
const newArgvs = {
|
const newArgvs = {
|
||||||
...this.defaultArgvs,
|
...this.defaultArgvs,
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ export default defineComponent({
|
|||||||
"arg0.newPath",
|
"arg0.newPath",
|
||||||
];
|
];
|
||||||
const result = parseFunction(code, { variableFormatPaths });
|
const result = parseFunction(code, { variableFormatPaths });
|
||||||
let params = result.args[0];
|
let params = result.argvs[0];
|
||||||
|
|
||||||
// 根据不同操作类型处理特定参数
|
// 根据不同操作类型处理特定参数
|
||||||
switch (params.operation) {
|
switch (params.operation) {
|
||||||
|
|||||||
@@ -421,9 +421,9 @@ export default defineComponent({
|
|||||||
console.warn("axios 参数解析失败:", code);
|
console.warn("axios 参数解析失败:", code);
|
||||||
return argvs;
|
return argvs;
|
||||||
}
|
}
|
||||||
const url = result.args[0] || "";
|
const url = result.argvs[0] || "";
|
||||||
const data = hasData ? result.args[1] : {};
|
const data = hasData ? result.argvs[1] : {};
|
||||||
const config = result.args[hasData ? 2 : 1] || {};
|
const config = result.argvs[hasData ? 2 : 1] || {};
|
||||||
const {
|
const {
|
||||||
"Content-Type": contentType,
|
"Content-Type": contentType,
|
||||||
"User-Agent": userAgent,
|
"User-Agent": userAgent,
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ export default defineComponent({
|
|||||||
if (!result) return this.defaultArgvs;
|
if (!result) return this.defaultArgvs;
|
||||||
|
|
||||||
const operation = result.name.split(".").pop();
|
const operation = result.name.split(".").pop();
|
||||||
const [firstArg, secondArg] = result.args;
|
const [firstArg, secondArg] = result.argvs;
|
||||||
|
|
||||||
const newArgvs = {
|
const newArgvs = {
|
||||||
...this.defaultArgvs,
|
...this.defaultArgvs,
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ export default defineComponent({
|
|||||||
if (!result) return this.defaultArgvs;
|
if (!result) return this.defaultArgvs;
|
||||||
|
|
||||||
const operation = result.name.split(".").pop();
|
const operation = result.name.split(".").pop();
|
||||||
const [firstArg, secondArg, thirdArg] = result.args;
|
const [firstArg, secondArg, thirdArg] = result.argvs;
|
||||||
|
|
||||||
const newArgvs = {
|
const newArgvs = {
|
||||||
...this.defaultArgvs,
|
...this.defaultArgvs,
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
// 获取操作名称(方法名)
|
// 获取操作名称(方法名)
|
||||||
const operation = result.name.split(".").pop();
|
const operation = result.name.split(".").pop();
|
||||||
const [params = {}] = result.args;
|
const [params = {}] = result.argvs;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...this.defaultArgvs,
|
...this.defaultArgvs,
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ export default defineComponent({
|
|||||||
if (!result) return this.defaultArgvs;
|
if (!result) return this.defaultArgvs;
|
||||||
|
|
||||||
const operation = result.name.split(".").pop();
|
const operation = result.name.split(".").pop();
|
||||||
const [firstArg, secondArg] = result.args;
|
const [firstArg, secondArg] = result.argvs;
|
||||||
|
|
||||||
const newArgvs = {
|
const newArgvs = {
|
||||||
...this.defaultArgvs,
|
...this.defaultArgvs,
|
||||||
@@ -362,7 +362,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
case "join":
|
case "join":
|
||||||
case "resolve":
|
case "resolve":
|
||||||
newArgvs.paths = result.args.map((arg) => arg);
|
newArgvs.paths = result.argvs.map((arg) => arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "relative":
|
case "relative":
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ export default defineComponent({
|
|||||||
if (!result) return this.defaultArgvs;
|
if (!result) return this.defaultArgvs;
|
||||||
|
|
||||||
// 返回解析结果
|
// 返回解析结果
|
||||||
const [command, options = {}] = result.args;
|
const [command, options = {}] = result.argvs;
|
||||||
return {
|
return {
|
||||||
command: command || this.defaultArgvs.command,
|
command: command || this.defaultArgvs.command,
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ const customComponentGuide = {
|
|||||||
if (!result) return this.defaultArgvs;
|
if (!result) return this.defaultArgvs;
|
||||||
|
|
||||||
// 处理解析结果
|
// 处理解析结果
|
||||||
const [url, config] = result.args;
|
const [url, config] = result.argvs;
|
||||||
|
|
||||||
// 返回处理后的参数对象
|
// 返回处理后的参数对象
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -303,13 +303,13 @@ export const parseFunction = (functionStr, options = {}) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const args = callExpression.arguments.map((arg, index) =>
|
const argvs = callExpression.arguments.map((arg, index) =>
|
||||||
processNode(arg, `arg${index}`)
|
processNode(arg, `arg${index}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
args,
|
argvs,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("Failed to parse function:", e);
|
console.warn("Failed to parse function:", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user