mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-17 08:54:19 +08:00
编排添加系统信息
This commit is contained in:
@@ -59,3 +59,7 @@ export const FileOperationEditor = defineAsyncComponent(() =>
|
||||
export const SystemCommandEditor = defineAsyncComponent(() =>
|
||||
import("components/composer/system/SystemCommandEditor.vue")
|
||||
);
|
||||
|
||||
export const OsEditor = defineAsyncComponent(() =>
|
||||
import("components/composer/system/OsEditor.vue")
|
||||
);
|
||||
|
||||
@@ -25,9 +25,15 @@ export const systemCommands = {
|
||||
value: "quickcomposer.system.exec",
|
||||
label: "执行系统命令",
|
||||
desc: "执行系统命令并返回输出结果",
|
||||
config: [],
|
||||
component: "SystemCommandEditor",
|
||||
icon: "terminal",
|
||||
},
|
||||
{
|
||||
value: "quickcomposer.system.os",
|
||||
label: "系统信息",
|
||||
desc: "获取操作系统相关信息",
|
||||
component: "OsEditor",
|
||||
icon: "computer",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@ const customComponentGuide = {
|
||||
},
|
||||
},
|
||||
parseCodeToArgvs: {
|
||||
description: "解析代码字符串为参数对象",
|
||||
description: "解析代码字符串为参数对象,严禁使用eval",
|
||||
parameters: "code - 要解析的代码字符串",
|
||||
implementation: {
|
||||
steps: [
|
||||
|
||||
@@ -219,7 +219,22 @@ export const parseFunction = (functionStr, options = {}) => {
|
||||
throw new Error("Not a valid function call");
|
||||
}
|
||||
|
||||
const functionName = callExpression.callee.name;
|
||||
// 处理函数名,支持成员方法调用
|
||||
let name;
|
||||
if (callExpression.callee.type === "MemberExpression") {
|
||||
// 递归获取完整的成员访问路径
|
||||
const getMemberPath = (node) => {
|
||||
if (node.type === "Identifier") {
|
||||
return node.name;
|
||||
} else if (node.type === "MemberExpression") {
|
||||
return `${getMemberPath(node.object)}.${node.property.name}`;
|
||||
}
|
||||
return "";
|
||||
};
|
||||
name = getMemberPath(callExpression.callee);
|
||||
} else {
|
||||
name = callExpression.callee.name;
|
||||
}
|
||||
|
||||
// 递归处理AST节点
|
||||
const processNode = (node, currentPath = "") => {
|
||||
@@ -260,6 +275,9 @@ export const parseFunction = (functionStr, options = {}) => {
|
||||
);
|
||||
case "ObjectProperty":
|
||||
return processNode(node.value, currentPath);
|
||||
case "MemberExpression":
|
||||
// 处理成员表达式
|
||||
return getMemberPath(node);
|
||||
default:
|
||||
console.warn("Unhandled node type:", node.type);
|
||||
return null;
|
||||
@@ -271,7 +289,7 @@ export const parseFunction = (functionStr, options = {}) => {
|
||||
);
|
||||
|
||||
return {
|
||||
functionName,
|
||||
name,
|
||||
args,
|
||||
};
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user