编排添加系统信息

This commit is contained in:
fofolee
2025-01-05 12:10:23 +08:00
parent e94118881a
commit 00ddba20ec
7 changed files with 499 additions and 4 deletions

View File

@@ -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")
);

View File

@@ -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",
},
],
};

View File

@@ -91,7 +91,7 @@ const customComponentGuide = {
},
},
parseCodeToArgvs: {
description: "解析代码字符串为参数对象",
description: "解析代码字符串为参数对象严禁使用eval",
parameters: "code - 要解析的代码字符串",
implementation: {
steps: [

View File

@@ -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) {