编排新增url/dns/buffer/zlib,新增arrayEditor组件,优化parseFunction

This commit is contained in:
fofolee
2025-01-05 22:50:21 +08:00
parent 54bb43dcc8
commit a6cc1c8737
30 changed files with 3214 additions and 243 deletions

View File

@@ -65,5 +65,17 @@ export const OsEditor = defineAsyncComponent(() =>
);
export const PathEditor = defineAsyncComponent(() =>
import("src/components/composer/system/PathEditor.vue")
import("components/composer/system/PathEditor.vue")
);
export const ZlibEditor = defineAsyncComponent(() =>
import("components/composer/file/ZlibEditor.vue")
);
export const UrlEditor = defineAsyncComponent(() =>
import("components/composer/network/UrlEditor.vue")
);
export const DnsEditor = defineAsyncComponent(() =>
import("components/composer/network/DnsEditor.vue")
);
export const BufferEditor = defineAsyncComponent(() =>
import("components/composer/developer/BufferEditor.vue")
);

View File

@@ -0,0 +1,14 @@
export const developerCommands = {
label: "开发相关",
icon: "code",
defaultOpened: true,
commands: [
{
value: "quickcomposer.developer.buffer",
label: "Buffer操作",
desc: "Buffer创建、转换和操作",
component: "BufferEditor",
icon: "memory",
},
],
};

View File

@@ -46,5 +46,13 @@ export const fileCommands = {
},
],
},
{
value: "quickcomposer.file.zlib",
label: "压缩解压",
desc: "使用 zlib 进行数据压缩和解压",
component: "ZlibEditor",
icon: "compress",
isAsync: true,
},
],
};

View File

@@ -6,6 +6,7 @@ import { textCommands } from "./textCommands";
import { otherCommands } from "./otherCommands";
import { simulateCommands } from "./simulateCommands";
import { controlCommands } from "./controlCommands";
import { developerCommands } from "./developerCommands";
export const commandCategories = [
fileCommands,
@@ -16,4 +17,5 @@ export const commandCategories = [
controlCommands,
otherCommands,
simulateCommands,
developerCommands,
];

View File

@@ -44,5 +44,20 @@ export const networkCommands = {
isAsync: true,
icon: "http",
},
{
value: "quickcomposer.network.url",
label: "URL操作",
desc: "URL解析、格式化和参数处理",
component: "UrlEditor",
icon: "link",
},
{
value: "quickcomposer.network.dns",
label: "DNS操作",
desc: "DNS解析和查询",
component: "DnsEditor",
icon: "dns",
isAsync: true,
},
],
};

View File

@@ -22,28 +22,42 @@ export const textCommands = {
{
label: "Base64编码",
value: "quickcomposer.text.base64Encode",
icon: "title",
},
{
label: "Base64解码",
value: "quickcomposer.text.base64Decode",
icon: "title",
},
{
label: "十六进制编码",
value: "quickcomposer.text.hexEncode",
icon: "code",
},
{
label: "十六进制解码",
value: "quickcomposer.text.hexDecode",
icon: "code",
},
{
label: "URL编码",
value: "quickcomposer.text.urlEncode",
icon: "link",
},
{
label: "URL解码",
value: "quickcomposer.text.urlDecode",
icon: "link",
},
{ label: "URL编码", value: "quickcomposer.text.urlEncode" },
{ label: "URL解码", value: "quickcomposer.text.urlDecode" },
{
label: "HTML编码",
value: "quickcomposer.text.htmlEncode",
icon: "html",
},
{
label: "HTML解码",
value: "quickcomposer.text.htmlDecode",
icon: "html",
},
],
width: 3,
@@ -75,11 +89,31 @@ export const textCommands = {
functionSelector: {
selectLabel: "哈希算法",
options: [
{ label: "MD5", value: "quickcomposer.text.md5Hash" },
{ label: "SHA1", value: "quickcomposer.text.sha1Hash" },
{ label: "SHA256", value: "quickcomposer.text.sha256Hash" },
{ label: "SHA512", value: "quickcomposer.text.sha512Hash" },
{ label: "SM3", value: "quickcomposer.text.sm3Hash" },
{
label: "MD5",
value: "quickcomposer.text.md5Hash",
icon: "functions",
},
{
label: "SHA1",
value: "quickcomposer.text.sha1Hash",
icon: "functions",
},
{
label: "SHA256",
value: "quickcomposer.text.sha256Hash",
icon: "functions",
},
{
label: "SHA512",
value: "quickcomposer.text.sha512Hash",
icon: "functions",
},
{
label: "SM3",
value: "quickcomposer.text.sm3Hash",
icon: "functions",
},
],
},
width: 3,

View File

@@ -150,12 +150,16 @@ const isPathMatched = (path, patterns) => {
const regexPattern = pattern
// 先处理 **,将其转换为特殊标记
.replace(/\*\*/g, "###DOUBLEWILDCARD###")
// 处理数组索引通配符 [*]
.replace(/\[\*\]/g, "###ARRAYINDEX###")
// 处理普通的 *
.replace(/\*/g, "[^/.]+")
.replace(/\*/g, "[^/.\\[\\]]+")
// 转义特殊字符
.replace(/[.]/g, "\\$&")
.replace(/[.[\]]/g, "\\$&")
// 还原 ** 为正则表达式
.replace(/###DOUBLEWILDCARD###/g, ".*");
.replace(/###DOUBLEWILDCARD###/g, ".*")
// 还原数组索引通配符
.replace(/###ARRAYINDEX###/g, "\\[\\d+\\]");
const regex = new RegExp(`^${regexPattern}$`);
return regex.test(path);
@@ -188,25 +192,28 @@ const isPathMatched = (path, patterns) => {
* - arg1.data.* - 匹配data下的所有直接子属性
* - arg2.params.** - 匹配params下的所有属性包括嵌套
*
* 3. 通配符
* - * - 匹配单个层级的任意字符(不包含点号)
* - ** - 匹配任意层级(包含点号)
* 3. 数组索引
* - arg0[0] - 匹配数组的第一个元素
* - arg0[*] - 匹配数组的任意元素
* - arg0[*].name - 匹配数组任意元素的name属性
* - arg0[*].** - 匹配数组任意元素的所有属性(包括嵌套)
*
* 4. 排除规则
* 4. 通配符
* - * - 匹配单个层级的任意字符(不包含点号和方括号)
* - ** - 匹配任意层级(包含点号)
* - [*] - 匹配任意数组索引
*
* 5. 排除规则:
* - !pattern - 排除匹配的路径
* - 排除优先级高于包含
*
* 5. 示例:
* 6. 示例:
* - arg0 - 匹配第一个参数
* - arg*.headers.** - 匹配任意参数中headers下的所有属性
* - arg*.data.* - 匹配任意参数中data下的直接子属性
* - arg0[*] - 匹配第一个参数的所有数组元素
* - arg0[*].name - 匹配第一个参数数组中所有元素的name属性
* - !arg*.headers.Content-Type - 排除所有参数中的Content-Type头
* - arg*.headers.Accept* - 匹配所有以Accept开头的头部
*
* 6. 使用建议:
* - 优先使用精确匹配arg0, arg1.data
* - 使用通配符时注意层级(* vs **
* - 合理使用排除规则避免过度匹配
*
* @returns {Object} 解析结果,包含函数名和参数数组
*/