From e23d3e5e11d56d96098193d0f6193d1e9fcb826e Mon Sep 17 00:00:00 2001 From: fofolee Date: Tue, 7 Jan 2025 19:28:14 +0800 Subject: [PATCH] =?UTF-8?q?OS/URL/PATH/BUFFER=E7=BB=84=E4=BB=B6=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/lib/quickcomposer/network/url.js | 57 +- plugin/lib/quickcomposer/system/os.js | 8 +- plugin/lib/quickcomposer/system/path.js | 27 +- src/components/composer/ComposerCard.vue | 6 +- src/components/composer/MultiParams.vue | 1 - .../composer/common/ButtonGroup.vue | 70 ++ src/components/composer/common/ParamInput.vue | 8 + src/components/composer/data/BufferEditor.vue | 695 ------------------ src/components/composer/network/UrlEditor.vue | 455 ------------ src/components/composer/system/OsEditor.vue | 368 ---------- src/components/composer/system/PathEditor.vue | 438 ----------- src/js/composer/cardComponents.js | 12 - src/js/composer/commands/dataCommands.js | 348 ++++++++- src/js/composer/commands/networkCommands.js | 174 ++++- src/js/composer/commands/systemCommands.js | 248 ++++++- 15 files changed, 902 insertions(+), 2013 deletions(-) create mode 100644 src/components/composer/common/ButtonGroup.vue delete mode 100644 src/components/composer/data/BufferEditor.vue delete mode 100644 src/components/composer/network/UrlEditor.vue delete mode 100644 src/components/composer/system/OsEditor.vue delete mode 100644 src/components/composer/system/PathEditor.vue diff --git a/plugin/lib/quickcomposer/network/url.js b/plugin/lib/quickcomposer/network/url.js index f917480..bef341d 100644 --- a/plugin/lib/quickcomposer/network/url.js +++ b/plugin/lib/quickcomposer/network/url.js @@ -1,32 +1,57 @@ const url = require("url"); // URL 解析 -function parse(urlString, parseQueryString = false) { - return url.parse(urlString, parseQueryString); +function parse(urlString) { + try { + return url.parse(urlString, false); + } catch (error) { + throw new Error(`URL解析失败: ${error.message}`); + } } -// URL 格式化 -function format(urlObject) { - return url.format(urlObject); +// 格式化 URL +function format(protocol, auth, hostname, port, pathname, search, hash) { + try { + const urlObject = { + protocol, + auth, + hostname, + port, + pathname, + search, + hash, + }; + return url.format(urlObject); + } catch (error) { + throw new Error(`URL格式化失败: ${error.message}`); + } } // 解析查询字符串 -function parseQuery(query) { - const searchParams = new URLSearchParams(query); - const result = {}; - for (const [key, value] of searchParams) { - result[key] = value; +function parseQuery(queryString) { + try { + const searchParams = new URLSearchParams(queryString); + const result = {}; + for (const [key, value] of searchParams) { + result[key] = value; + } + return result; + } catch (error) { + throw new Error(`查询字符串解析失败: ${error.message}`); } - return result; } // 格式化查询字符串 -function formatQuery(queryObject) { - const searchParams = new URLSearchParams(); - for (const [key, value] of Object.entries(queryObject)) { - searchParams.append(key, value); +function formatQuery(queryParams) { + try { + const searchParams = new URLSearchParams(); + for (const [key, value] of Object.entries(queryParams)) { + searchParams.append(key, value); + } + return searchParams.toString(); + } catch (error) { + throw new Error(`查询字符串格式化失败: ${error.message}`); } - return searchParams.toString(); } // 解析路径名 diff --git a/plugin/lib/quickcomposer/system/os.js b/plugin/lib/quickcomposer/system/os.js index 83f390e..2260c2d 100644 --- a/plugin/lib/quickcomposer/system/os.js +++ b/plugin/lib/quickcomposer/system/os.js @@ -6,7 +6,7 @@ function arch() { } // 获取CPU信息 -function cpus({ format = "full" } = {}) { +function cpus(format = "full") { const cpuInfo = os.cpus(); if (format === "simple") { return cpuInfo.map(({ model, speed }) => ({ model, speed })); @@ -15,7 +15,7 @@ function cpus({ format = "full" } = {}) { } // 获取内存信息 -function memory({ type = "totalmem" } = {}) { +function memory(type = "totalmem") { switch (type) { case "totalmem": return os.totalmem(); @@ -27,7 +27,7 @@ function memory({ type = "totalmem" } = {}) { } // 获取网络信息 -function network({ type = "hostname", internal = false } = {}) { +function network(type = "hostname", internal = false) { switch (type) { case "hostname": return os.hostname(); @@ -50,7 +50,7 @@ function network({ type = "hostname", internal = false } = {}) { } // 获取平台信息 -function platform({ type = "platform" } = {}) { +function platform(type = "platform") { switch (type) { case "platform": return os.platform(); diff --git a/plugin/lib/quickcomposer/system/path.js b/plugin/lib/quickcomposer/system/path.js index b30a1c6..7c59cc5 100644 --- a/plugin/lib/quickcomposer/system/path.js +++ b/plugin/lib/quickcomposer/system/path.js @@ -5,7 +5,7 @@ const path = require("path"); * @param {string} p 要规范化的路径 * @returns {string} 规范化后的路径 */ -async function normalize(p) { +function normalize(p) { try { return path.normalize(p); } catch (error) { @@ -18,7 +18,7 @@ async function normalize(p) { * @param {...string} paths 路径片段 * @returns {string} 连接后的路径 */ -async function join(...paths) { +function join(...paths) { try { return path.join(...paths); } catch (error) { @@ -31,7 +31,7 @@ async function join(...paths) { * @param {string} p 要解析的路径 * @returns {Object} 解析结果,包含 root, dir, base, ext, name */ -async function parse(p) { +function parse(p) { try { return path.parse(p); } catch (error) { @@ -44,7 +44,7 @@ async function parse(p) { * @param {string} p 路径 * @returns {string} 目录名 */ -async function dirname(p) { +function dirname(p) { try { return path.dirname(p); } catch (error) { @@ -58,7 +58,7 @@ async function dirname(p) { * @param {string} [ext] 可选的扩展名,如果提供则从结果中移除 * @returns {string} 文件名 */ -async function basename(p, ext) { +function basename(p, ext = undefined) { try { return path.basename(p, ext); } catch (error) { @@ -71,7 +71,7 @@ async function basename(p, ext) { * @param {string} p 路径 * @returns {string} 扩展名 */ -async function extname(p) { +function extname(p) { try { return path.extname(p); } catch (error) { @@ -84,7 +84,7 @@ async function extname(p) { * @param {string} p 路径 * @returns {boolean} 是否为绝对路径 */ -async function isAbsolute(p) { +function isAbsolute(p) { try { return path.isAbsolute(p); } catch (error) { @@ -98,7 +98,7 @@ async function isAbsolute(p) { * @param {string} to 目标路径 * @returns {string} 相对路径 */ -async function relative(from, to) { +function relative(from, to) { try { return path.relative(from, to); } catch (error) { @@ -111,7 +111,7 @@ async function relative(from, to) { * @param {...string} paths 路径片段 * @returns {string} 解析后的绝对路径 */ -async function resolve(...paths) { +function resolve(...paths) { try { return path.resolve(...paths); } catch (error) { @@ -121,11 +121,16 @@ async function resolve(...paths) { /** * 格式化路径对象为路径字符串 - * @param {Object} pathObject 路径对象,包含 dir, root, base, name, ext + * @param {string} root 根路径 + * @param {string} dir 目录 + * @param {string} base 基本名称 + * @param {string} name 文件名 + * @param {string} ext 扩展名 * @returns {string} 格式化后的路径 */ -async function format(pathObject) { +function format(root, dir, base, name, ext) { try { + const pathObject = { root, dir, base, name, ext }; return path.format(pathObject); } catch (error) { throw new Error(`格式化路径失败: ${error.message}`); diff --git a/src/components/composer/ComposerCard.vue b/src/components/composer/ComposerCard.vue index 6762241..9c3bc99 100644 --- a/src/components/composer/ComposerCard.vue +++ b/src/components/composer/ComposerCard.vue @@ -55,7 +55,11 @@ diff --git a/src/components/composer/MultiParams.vue b/src/components/composer/MultiParams.vue index 40a7b89..19c8ddb 100644 --- a/src/components/composer/MultiParams.vue +++ b/src/components/composer/MultiParams.vue @@ -111,7 +111,6 @@ export default defineComponent({ this.updateModelValue(this.funcName, newArgvs); }, generateCode(funcName, argvs) { - console.log("argvs", argvs); /** * 字符串模式stringfiy后,null会变成'"null"', ''变成'""' * 变量模式stringify后,null变成'null', ''保持'' diff --git a/src/components/composer/common/ButtonGroup.vue b/src/components/composer/common/ButtonGroup.vue new file mode 100644 index 0000000..c2b406f --- /dev/null +++ b/src/components/composer/common/ButtonGroup.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/src/components/composer/common/ParamInput.vue b/src/components/composer/common/ParamInput.vue index 9f9ba04..2324960 100644 --- a/src/components/composer/common/ParamInput.vue +++ b/src/components/composer/common/ParamInput.vue @@ -72,6 +72,12 @@ :label="config.label" :icon="config.icon" /> + @@ -82,6 +88,7 @@ import VariableInput from "./VariableInput.vue"; import NumberInput from "./NumberInput.vue"; import ArrayEditor from "./ArrayEditor.vue"; import DictEditor from "./DictEditor.vue"; +import ButtonGroup from "./ButtonGroup.vue"; /** * 参数输入组件 @@ -101,6 +108,7 @@ export default defineComponent({ NumberInput, ArrayEditor, DictEditor, + ButtonGroup, }, props: { configs: { diff --git a/src/components/composer/data/BufferEditor.vue b/src/components/composer/data/BufferEditor.vue deleted file mode 100644 index cd3c9dd..0000000 --- a/src/components/composer/data/BufferEditor.vue +++ /dev/null @@ -1,695 +0,0 @@ - - - - - diff --git a/src/components/composer/network/UrlEditor.vue b/src/components/composer/network/UrlEditor.vue deleted file mode 100644 index 1422f34..0000000 --- a/src/components/composer/network/UrlEditor.vue +++ /dev/null @@ -1,455 +0,0 @@ - - - - - diff --git a/src/components/composer/system/OsEditor.vue b/src/components/composer/system/OsEditor.vue deleted file mode 100644 index 6ece904..0000000 --- a/src/components/composer/system/OsEditor.vue +++ /dev/null @@ -1,368 +0,0 @@ - - - - - diff --git a/src/components/composer/system/PathEditor.vue b/src/components/composer/system/PathEditor.vue deleted file mode 100644 index 649b07f..0000000 --- a/src/components/composer/system/PathEditor.vue +++ /dev/null @@ -1,438 +0,0 @@ - - - - - diff --git a/src/js/composer/cardComponents.js b/src/js/composer/cardComponents.js index f6fa48a..fc0da7c 100644 --- a/src/js/composer/cardComponents.js +++ b/src/js/composer/cardComponents.js @@ -60,19 +60,7 @@ export const SystemCommandEditor = defineAsyncComponent(() => import("components/composer/system/SystemCommandEditor.vue") ); -export const OsEditor = defineAsyncComponent(() => - import("components/composer/system/OsEditor.vue") -); -export const PathEditor = defineAsyncComponent(() => - import("components/composer/system/PathEditor.vue") -); export const ZlibEditor = defineAsyncComponent(() => import("src/components/composer/data/ZlibEditor.vue") ); -export const UrlEditor = defineAsyncComponent(() => - import("components/composer/network/UrlEditor.vue") -); -export const BufferEditor = defineAsyncComponent(() => - import("src/components/composer/data/BufferEditor.vue") -); diff --git a/src/js/composer/commands/dataCommands.js b/src/js/composer/commands/dataCommands.js index 10678d7..864b13d 100644 --- a/src/js/composer/commands/dataCommands.js +++ b/src/js/composer/commands/dataCommands.js @@ -312,11 +312,355 @@ export const dataCommands = { saveOutput: true, }, { - value: "quickcomposer.data.buffer", + value: "quickcomposer.data.buffer.from", label: "Buffer操作", desc: "Buffer创建、转换和操作", - component: "BufferEditor", + config: [], icon: "memory", + functionSelector: [ + { + value: "quickcomposer.data.buffer.from", + label: "创建Buffer", + icon: "add_box", + config: [ + { + label: "数据", + type: "varInput", + icon: "text_fields", + width: 9, + }, + { + label: "编码", + type: "select", + icon: "code", + options: [ + { label: "UTF-8", value: "utf8" }, + { label: "UTF-16LE", value: "utf16le" }, + { label: "Latin1", value: "latin1" }, + { label: "Base64", value: "base64" }, + { label: "Hex", value: "hex" }, + { label: "ASCII", value: "ascii" }, + { label: "Binary", value: "binary" }, + { label: "UCS-2", value: "ucs2" }, + ], + defaultValue: "utf8", + width: 3, + }, + ], + }, + { + value: "quickcomposer.data.buffer.toString", + label: "转换字符串", + icon: "text_fields", + config: [ + { + label: "Buffer", + type: "varInput", + icon: "memory", + width: 12, + }, + { + label: "编码", + type: "select", + icon: "code", + options: [ + { label: "UTF-8", value: "utf8" }, + { label: "UTF-16LE", value: "utf16le" }, + { label: "Latin1", value: "latin1" }, + { label: "Base64", value: "base64" }, + { label: "Hex", value: "hex" }, + { label: "ASCII", value: "ascii" }, + { label: "Binary", value: "binary" }, + { label: "UCS-2", value: "ucs2" }, + ], + defaultValue: "utf8", + width: 4, + }, + { + label: "起始位置", + type: "numInput", + icon: "first_page", + width: 4, + }, + { + label: "结束位置", + type: "numInput", + icon: "last_page", + width: 4, + }, + ], + }, + { + value: "quickcomposer.data.buffer.write", + label: "写入数据", + icon: "edit", + config: [ + { + label: "Buffer", + type: "varInput", + icon: "memory", + width: 6, + }, + { + label: "要写入的字符串", + type: "varInput", + icon: "edit", + width: 6, + }, + { + label: "偏移量", + type: "numInput", + icon: "first_page", + width: 4, + }, + { + label: "长度", + type: "numInput", + icon: "straighten", + width: 4, + }, + { + label: "编码", + type: "select", + icon: "code", + options: [ + { label: "UTF-8", value: "utf8" }, + { label: "UTF-16LE", value: "utf16le" }, + { label: "Latin1", value: "latin1" }, + { label: "Base64", value: "base64" }, + { label: "Hex", value: "hex" }, + { label: "ASCII", value: "ascii" }, + { label: "Binary", value: "binary" }, + { label: "UCS-2", value: "ucs2" }, + ], + defaultValue: "utf8", + width: 4, + }, + ], + }, + { + value: "quickcomposer.data.buffer.fill", + label: "填充数据", + icon: "format_color_fill", + config: [ + { + label: "Buffer", + type: "varInput", + icon: "memory", + width: 6, + }, + { + label: "填充值", + type: "varInput", + icon: "format_color_fill", + width: 6, + }, + { + label: "起始位置", + type: "numInput", + icon: "first_page", + width: 4, + }, + { + label: "结束位置", + type: "numInput", + icon: "last_page", + width: 4, + }, + { + label: "编码", + type: "select", + icon: "code", + options: [ + { label: "UTF-8", value: "utf8" }, + { label: "UTF-16LE", value: "utf16le" }, + { label: "Latin1", value: "latin1" }, + { label: "Base64", value: "base64" }, + { label: "Hex", value: "hex" }, + { label: "ASCII", value: "ascii" }, + { label: "Binary", value: "binary" }, + { label: "UCS-2", value: "ucs2" }, + ], + defaultValue: "utf8", + width: 4, + }, + ], + }, + { + value: "quickcomposer.data.buffer.copy", + label: "复制数据", + icon: "content_copy", + config: [ + { + label: "源Buffer", + type: "varInput", + icon: "content_copy", + width: 6, + }, + { + label: "目标Buffer", + type: "varInput", + icon: "save", + width: 6, + }, + { + label: "目标起始位置", + type: "numInput", + icon: "first_page", + width: 4, + }, + { + label: "源起始位置", + type: "numInput", + icon: "first_page", + width: 4, + }, + { + label: "源结束位置", + type: "numInput", + icon: "last_page", + width: 4, + }, + ], + }, + { + value: "quickcomposer.data.buffer.compare", + label: "比较数据", + icon: "compare", + config: [ + { + label: "Buffer 1", + type: "varInput", + icon: "memory", + width: 6, + }, + { + label: "Buffer 2", + type: "varInput", + icon: "memory", + width: 6, + }, + ], + }, + { + value: "quickcomposer.data.buffer.concat", + label: "连接Buffer", + icon: "merge", + config: [ + { + label: "Buffer列表", + type: "arrayEditor", + icon: "memory", + width: 12, + defaultValue: [ + { + value: "", + isString: false, + __varInputVal__: true, + }, + ], + }, + { + label: "总长度(可选)", + type: "numInput", + icon: "straighten", + width: 12, + }, + ], + }, + { + value: "quickcomposer.data.buffer.slice", + label: "切片数据", + icon: "content_cut", + config: [ + { + label: "Buffer", + type: "varInput", + icon: "memory", + width: 12, + }, + { + label: "起始位置", + type: "numInput", + icon: "first_page", + width: 6, + }, + { + label: "结束位置", + type: "numInput", + icon: "last_page", + width: 6, + }, + ], + }, + { + value: "quickcomposer.data.buffer.indexOf", + label: "查找数据", + icon: "search", + config: [ + { + label: "Buffer", + type: "varInput", + icon: "memory", + width: 12, + }, + { + label: "要查找的值", + type: "varInput", + icon: "search", + width: 4, + }, + { + label: "起始位置", + type: "numInput", + icon: "first_page", + width: 4, + }, + { + label: "编码", + type: "select", + icon: "code", + options: [ + { label: "UTF-8", value: "utf8" }, + { label: "UTF-16LE", value: "utf16le" }, + { label: "Latin1", value: "latin1" }, + { label: "Base64", value: "base64" }, + { label: "Hex", value: "hex" }, + { label: "ASCII", value: "ascii" }, + { label: "Binary", value: "binary" }, + { label: "UCS-2", value: "ucs2" }, + ], + defaultValue: "utf8", + width: 4, + }, + ], + }, + { + value: "quickcomposer.data.buffer.swap", + label: "交换字节序", + icon: "swap_horiz", + config: [ + { + label: "Buffer", + type: "varInput", + icon: "memory", + width: 9, + }, + { + label: "字节大小", + type: "select", + icon: "memory", + options: [ + { label: "16位", value: 16 }, + { label: "32位", value: 32 }, + { label: "64位", value: 64 }, + ], + defaultValue: 16, + width: 3, + }, + ], + }, + ], }, { value: "quickcomposer.data.zlib", diff --git a/src/js/composer/commands/networkCommands.js b/src/js/composer/commands/networkCommands.js index a9ac8ca..ab7dd50 100644 --- a/src/js/composer/commands/networkCommands.js +++ b/src/js/composer/commands/networkCommands.js @@ -47,11 +47,181 @@ export const networkCommands = { saveOutput: true, }, { - value: "quickcomposer.network.url", + value: "quickcomposer.network.url.parse", label: "URL操作", desc: "URL解析、格式化和参数处理", - component: "UrlEditor", icon: "link", + config: [ + { + label: "URL", + type: "varInput", + icon: "link", + width: "auto", + }, + ], + functionSelector: [ + { + value: "quickcomposer.network.url.parse", + label: "解析URL", + icon: "link_off", + }, + { + value: "quickcomposer.network.url.format", + label: "格式化URL", + icon: "link", + excludeConfig: [0], + config: [ + { + label: "协议", + type: "varInput", + icon: "security", + width: 6, + }, + { + label: "认证信息", + type: "varInput", + icon: "person", + width: 6, + }, + { + label: "主机名", + type: "varInput", + icon: "dns", + width: 6, + }, + { + label: "端口", + type: "varInput", + icon: "settings_ethernet", + width: 6, + }, + { + label: "路径", + type: "varInput", + icon: "folder", + }, + { + label: "查询字符串", + type: "varInput", + icon: "search", + width: 6, + }, + { + label: "锚点", + type: "varInput", + icon: "tag", + width: 6, + }, + ], + }, + { + value: "quickcomposer.network.url.parseQuery", + label: "解析查询字符串", + icon: "search", + excludeConfig: [0], + config: [ + { + label: "查询字符串", + type: "varInput", + icon: "search", + }, + ], + }, + { + value: "quickcomposer.network.url.formatQuery", + label: "格式化查询字符串", + icon: "edit", + excludeConfig: [0], + config: [ + { + label: "参数", + type: "dictEditor", + icon: "edit", + }, + ], + }, + { + value: "quickcomposer.network.url.parsePath", + label: "解析路径", + icon: "folder_open", + excludeConfig: [0], + config: [ + { + label: "路径", + type: "varInput", + icon: "folder", + }, + ], + }, + { + value: "quickcomposer.network.url.parseHost", + label: "解析主机名", + icon: "dns", + excludeConfig: [0], + config: [ + { + label: "主机名", + type: "varInput", + icon: "dns", + }, + ], + }, + { + value: "quickcomposer.network.url.getQueryParam", + label: "获取参数", + icon: "find_in_page", + config: [ + { + label: "参数名", + type: "varInput", + icon: "key", + width: "auto", + }, + ], + }, + { + value: "quickcomposer.network.url.addQueryParam", + label: "添加参数", + icon: "add_circle", + config: [ + { + label: "参数名", + type: "varInput", + icon: "key", + width: "auto", + }, + { + label: "参数值", + type: "varInput", + icon: "text_fields", + width: "auto", + }, + ], + }, + { + value: "quickcomposer.network.url.removeQueryParam", + label: "移除参数", + icon: "remove_circle", + config: [ + { + label: "参数名", + type: "varInput", + icon: "key", + width: "auto", + }, + ], + }, + { + value: "quickcomposer.network.url.isAbsolute", + label: "检查绝对URL", + icon: "check_circle", + }, + { + value: "quickcomposer.network.url.parseComponents", + label: "解析组成部分", + icon: "category", + }, + ], }, { value: "quickcomposer.network.dns.lookupHost", diff --git a/src/js/composer/commands/systemCommands.js b/src/js/composer/commands/systemCommands.js index cb6a625..9e4caf4 100644 --- a/src/js/composer/commands/systemCommands.js +++ b/src/js/composer/commands/systemCommands.js @@ -32,20 +32,252 @@ export const systemCommands = { isAsync: true, }, { - value: "quickcomposer.system.os", + value: "quickcomposer.system.os.arch", label: "系统信息", desc: "获取操作系统相关信息", - component: "OsEditor", icon: "computer", - isAsync: true, + config: [], + functionSelector: [ + { + value: "quickcomposer.system.os.arch", + label: "系统架构", + icon: "memory", + }, + { + value: "quickcomposer.system.os.cpus", + label: "CPU信息", + icon: "developer_board", + config: [ + { + label: "信息格式", + type: "buttonGroup", + options: [ + { label: "完整信息", value: "full" }, + { label: "仅型号和速度", value: "simple" }, + ], + defaultValue: "full", + width: 12, + }, + ], + }, + { + value: "quickcomposer.system.os.memory", + label: "内存信息", + icon: "storage", + config: [ + { + label: "内存类型", + type: "buttonGroup", + options: [ + { label: "总内存", value: "totalmem" }, + { label: "空闲内存", value: "freemem" }, + ], + defaultValue: "totalmem", + width: 12, + }, + ], + }, + { + value: "quickcomposer.system.os.network", + label: "网络信息", + icon: "wifi", + config: [ + { + label: "网络信息类型", + type: "buttonGroup", + options: [ + { label: "主机名", value: "hostname" }, + { label: "网络接口", value: "networkInterfaces" }, + ], + defaultValue: "hostname", + width: 12, + }, + { + label: "包含内部接口", + type: "checkbox", + defaultValue: false, + width: 12, + condition: "values[0] === 'networkInterfaces'", + }, + ], + }, + { + value: "quickcomposer.system.os.platform", + label: "平台信息", + icon: "computer", + config: [ + { + label: "平台信息类型", + type: "buttonGroup", + options: [ + { label: "操作系统名称", value: "platform" }, + { label: "操作系统类型", value: "type" }, + { label: "操作系统版本", value: "release" }, + { label: "操作系统架构", value: "arch" }, + { label: "CPU字节序", value: "endianness" }, + { label: "系统临时目录", value: "tmpdir" }, + { label: "主目录", value: "homedir" }, + { label: "系统正常运行时间", value: "uptime" }, + { label: "用户信息", value: "userInfo" }, + ], + defaultValue: "platform", + width: 12, + }, + ], + }, + ], }, { - value: "quickcomposer.system.path", + value: "quickcomposer.system.path.normalize", label: "路径操作", - desc: "路径操作", - component: "PathEditor", - icon: "folder_path", - isAsync: true, + desc: "路径解析和处理", + icon: "folder", + config: [ + { + label: "路径", + type: "varInput", + icon: "folder", + width: "auto", + }, + ], + functionSelector: [ + { + value: "quickcomposer.system.path.normalize", + label: "规范化路径", + icon: "straighten", + }, + { + value: "quickcomposer.system.path.parse", + label: "解析路径", + icon: "account_tree", + }, + { + value: "quickcomposer.system.path.dirname", + label: "获取目录名", + icon: "folder", + }, + { + value: "quickcomposer.system.path.basename", + label: "获取文件名", + icon: "description", + config: [ + { + label: "要移除的扩展名", + type: "varInput", + icon: "extension", + width: "auto", + }, + ], + }, + { + value: "quickcomposer.system.path.extname", + label: "获取扩展名", + icon: "extension", + }, + { + value: "quickcomposer.system.path.isAbsolute", + label: "判断绝对路径", + icon: "check_circle", + }, + { + value: "quickcomposer.system.path.join", + label: "连接路径", + icon: "add_link", + excludeConfig: [0], + config: [ + { + label: "路径片段", + type: "varInput", + icon: "folder", + width: "auto", + }, + { + label: "路径片段", + type: "varInput", + icon: "folder", + width: "auto", + }, + ], + }, + { + value: "quickcomposer.system.path.resolve", + label: "解析绝对路径", + icon: "assistant_direction", + excludeConfig: [0], + config: [ + { + label: "路径片段", + type: "varInput", + icon: "folder", + width: "auto", + }, + { + label: "路径片段", + type: "varInput", + icon: "folder", + width: "auto", + }, + ], + }, + { + value: "quickcomposer.system.path.relative", + label: "计算相对路径", + icon: "compare_arrows", + excludeConfig: [0], + config: [ + { + label: "起始路径", + type: "varInput", + icon: "folder", + width: 6, + }, + { + label: "目标路径", + type: "varInput", + icon: "folder", + width: 6, + }, + ], + }, + { + value: "quickcomposer.system.path.format", + label: "格式化路径", + icon: "format_shapes", + excludeConfig: [0], + config: [ + { + label: "根路径", + type: "varInput", + icon: "folder", + width: 6, + }, + { + label: "目录", + type: "varInput", + icon: "folder", + width: 6, + }, + { + label: "基本名称", + type: "varInput", + icon: "description", + width: 6, + }, + { + label: "文件名", + type: "varInput", + icon: "insert_drive_file", + width: 6, + }, + { + label: "扩展名", + type: "varInput", + icon: "extension", + width: 6, + }, + ], + }, + ], }, ], };