mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-17 08:54:19 +08:00
使用通用组件构造控制流程命令,规范配置文件字段命名
This commit is contained in:
@@ -11,29 +11,6 @@ export const KeySequenceEditor = defineAsyncComponent(() =>
|
||||
import("src/components/composer/simulate/KeySequenceEditor.vue")
|
||||
);
|
||||
|
||||
// 控制流组件
|
||||
export const ConditionalJudgment = defineAsyncComponent(() =>
|
||||
import("components/composer/control/ConditionalJudgment.vue")
|
||||
);
|
||||
export const LoopControl = defineAsyncComponent(() =>
|
||||
import("components/composer/control/LoopControl.vue")
|
||||
);
|
||||
export const ForEachControl = defineAsyncComponent(() =>
|
||||
import("components/composer/control/ForEachControl.vue")
|
||||
);
|
||||
export const ForInControl = defineAsyncComponent(() =>
|
||||
import("components/composer/control/ForInControl.vue")
|
||||
);
|
||||
export const WhileControl = defineAsyncComponent(() =>
|
||||
import("components/composer/control/WhileControl.vue")
|
||||
);
|
||||
export const SwitchControl = defineAsyncComponent(() =>
|
||||
import("components/composer/control/SwitchControl.vue")
|
||||
);
|
||||
export const TryCatchControl = defineAsyncComponent(() =>
|
||||
import("components/composer/control/TryCatchControl.vue")
|
||||
);
|
||||
|
||||
// 网络组件
|
||||
export const UBrowserEditor = defineAsyncComponent(() =>
|
||||
import("components/composer/ubrowser/UBrowserEditor.vue")
|
||||
|
||||
@@ -17,7 +17,7 @@ export const codingCommands = {
|
||||
type: "varInput",
|
||||
},
|
||||
],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
label: "Base64编码",
|
||||
value: "quickcomposer.coding.base64Encode",
|
||||
@@ -88,7 +88,7 @@ export const codingCommands = {
|
||||
type: "varInput",
|
||||
},
|
||||
],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
label: "MD5",
|
||||
value: "quickcomposer.coding.md5Hash",
|
||||
|
||||
@@ -5,51 +5,358 @@ export const controlCommands = {
|
||||
{
|
||||
value: "condition",
|
||||
label: "条件判断",
|
||||
component: "ConditionalJudgment",
|
||||
component: "ControlCommand",
|
||||
isControlFlow: true,
|
||||
commandChain: ["if", "end"],
|
||||
subCommands: [
|
||||
{
|
||||
label: "如果满足",
|
||||
value: "if",
|
||||
codeTemplate: "if (${condition}) {",
|
||||
config: [
|
||||
{
|
||||
key: "condition",
|
||||
label: "条件",
|
||||
type: "controlInput",
|
||||
placeholder: "表达式",
|
||||
defaultValue: "true",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "否则",
|
||||
value: "else",
|
||||
icon: "fork_left",
|
||||
codeTemplate: "} else {",
|
||||
},
|
||||
{
|
||||
label: "否则满足",
|
||||
value: "else if",
|
||||
icon: "fork_left",
|
||||
codeTemplate: "} else if (${condition}) {",
|
||||
config: [
|
||||
{
|
||||
key: "condition",
|
||||
label: "条件",
|
||||
type: "controlInput",
|
||||
placeholder: "表达式",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "结束",
|
||||
value: "end",
|
||||
codeTemplate: "}",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "loop",
|
||||
label: "循环执行",
|
||||
component: "LoopControl",
|
||||
component: "ControlCommand",
|
||||
isControlFlow: true,
|
||||
commandChain: ["loop", "end"],
|
||||
subCommands: [
|
||||
{
|
||||
label: "循环执行",
|
||||
value: "loop",
|
||||
icon: "loop",
|
||||
codeTemplate:
|
||||
"for (let ${indexVar} = ${startValue}; ${indexVar} <= ${endValue}; ${indexVar} += ${stepValue}) {",
|
||||
config: [
|
||||
{
|
||||
key: "indexVar",
|
||||
label: "变量",
|
||||
type: "controlInput",
|
||||
defaultValue: "i",
|
||||
width: 3,
|
||||
},
|
||||
{
|
||||
key: "startValue",
|
||||
label: "从",
|
||||
type: "controlInput",
|
||||
icon: "first_page",
|
||||
defaultValue: "0",
|
||||
width: 3,
|
||||
},
|
||||
{
|
||||
key: "endValue",
|
||||
label: "到",
|
||||
type: "controlInput",
|
||||
icon: "last_page",
|
||||
defaultValue: "10",
|
||||
width: 3,
|
||||
},
|
||||
{
|
||||
key: "stepValue",
|
||||
label: "步进",
|
||||
type: "controlInput",
|
||||
icon: "trending_up",
|
||||
defaultValue: "1",
|
||||
width: 3,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "继续循环",
|
||||
value: "continue",
|
||||
icon: "skip_next",
|
||||
codeTemplate: "continue;",
|
||||
},
|
||||
{
|
||||
label: "终止循环",
|
||||
value: "break",
|
||||
icon: "stop",
|
||||
codeTemplate: "break;",
|
||||
},
|
||||
{
|
||||
label: "结束",
|
||||
value: "end",
|
||||
codeTemplate: "}",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "forEach",
|
||||
label: "遍历数组",
|
||||
component: "ForEachControl",
|
||||
component: "ControlCommand",
|
||||
isControlFlow: true,
|
||||
commandChain: ["forEach", "end"],
|
||||
subCommands: [
|
||||
{
|
||||
label: "遍历数组",
|
||||
value: "forEach",
|
||||
icon: "list",
|
||||
codeTemplate:
|
||||
"for (let [${indexVar}, ${itemVar}] of ${arrayVar}.entries()) {",
|
||||
config: [
|
||||
{
|
||||
key: "itemVar",
|
||||
label: "元素",
|
||||
type: "controlInput",
|
||||
defaultValue: "item",
|
||||
width: 4,
|
||||
},
|
||||
{
|
||||
key: "indexVar",
|
||||
label: "索引",
|
||||
type: "controlInput",
|
||||
defaultValue: "i",
|
||||
width: 4,
|
||||
},
|
||||
{
|
||||
key: "arrayVar",
|
||||
label: "数组",
|
||||
type: "controlInput",
|
||||
icon: "list",
|
||||
defaultValue: "array",
|
||||
width: 4,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "继续循环",
|
||||
value: "continue",
|
||||
icon: "skip_next",
|
||||
codeTemplate: "continue;",
|
||||
},
|
||||
{
|
||||
label: "终止循环",
|
||||
value: "break",
|
||||
icon: "stop",
|
||||
codeTemplate: "break;",
|
||||
},
|
||||
{
|
||||
label: "结束",
|
||||
value: "end",
|
||||
codeTemplate: "}",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "forIn",
|
||||
label: "遍历对象",
|
||||
component: "ForInControl",
|
||||
component: "ControlCommand",
|
||||
isControlFlow: true,
|
||||
commandChain: ["forIn", "end"],
|
||||
subCommands: [
|
||||
{
|
||||
label: "遍历对象",
|
||||
value: "forIn",
|
||||
icon: "data_object",
|
||||
codeTemplate:
|
||||
"for (const ${keyVar} in ${objectVar}) { const ${valueVar} = ${objectVar}[${keyVar}];",
|
||||
config: [
|
||||
{
|
||||
key: "keyVar",
|
||||
label: "键名",
|
||||
type: "controlInput",
|
||||
defaultValue: "key",
|
||||
width: 4,
|
||||
},
|
||||
{
|
||||
key: "valueVar",
|
||||
label: "值",
|
||||
type: "controlInput",
|
||||
defaultValue: "value",
|
||||
width: 4,
|
||||
},
|
||||
{
|
||||
key: "objectVar",
|
||||
label: "对象",
|
||||
type: "controlInput",
|
||||
defaultValue: "object",
|
||||
width: 4,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "继续循环",
|
||||
value: "continue",
|
||||
icon: "skip_next",
|
||||
codeTemplate: "continue;",
|
||||
},
|
||||
{
|
||||
label: "终止循环",
|
||||
value: "break",
|
||||
icon: "stop",
|
||||
codeTemplate: "break;",
|
||||
},
|
||||
{
|
||||
label: "结束",
|
||||
value: "end",
|
||||
codeTemplate: "}",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "while",
|
||||
label: "条件循环",
|
||||
component: "WhileControl",
|
||||
component: "ControlCommand",
|
||||
isControlFlow: true,
|
||||
commandChain: ["while", "end"],
|
||||
subCommands: [
|
||||
{
|
||||
label: "条件循环",
|
||||
value: "while",
|
||||
icon: "loop",
|
||||
codeTemplate: "while (${condition}) {",
|
||||
config: [
|
||||
{
|
||||
key: "condition",
|
||||
label: "条件",
|
||||
type: "controlInput",
|
||||
placeholder: "表达式",
|
||||
defaultValue: "true",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "继续循环",
|
||||
value: "continue",
|
||||
icon: "skip_next",
|
||||
codeTemplate: "continue;",
|
||||
},
|
||||
{
|
||||
label: "终止循环",
|
||||
value: "break",
|
||||
icon: "stop",
|
||||
codeTemplate: "break;",
|
||||
},
|
||||
{
|
||||
label: "结束",
|
||||
value: "end",
|
||||
codeTemplate: "}",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "switch",
|
||||
label: "条件分支",
|
||||
component: "SwitchControl",
|
||||
component: "ControlCommand",
|
||||
isControlFlow: true,
|
||||
commandChain: ["switch", "case", "end"],
|
||||
subCommands: [
|
||||
{
|
||||
label: "条件分支",
|
||||
value: "switch",
|
||||
icon: "call_split",
|
||||
codeTemplate: "switch (${expression}) {",
|
||||
config: [
|
||||
{
|
||||
key: "expression",
|
||||
label: "变量",
|
||||
type: "controlInput",
|
||||
placeholder: "变量或表达式",
|
||||
defaultValue: "expression",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "匹配分支",
|
||||
value: "case",
|
||||
icon: "check",
|
||||
codeTemplate: "case ${value}:",
|
||||
config: [
|
||||
{
|
||||
key: "value",
|
||||
label: "值",
|
||||
type: "controlInput",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "默认分支",
|
||||
value: "default",
|
||||
icon: "last_page",
|
||||
codeTemplate: "default:",
|
||||
},
|
||||
{
|
||||
label: "结束",
|
||||
value: "end",
|
||||
codeTemplate: "}",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "tryCatch",
|
||||
label: "异常处理",
|
||||
component: "TryCatchControl",
|
||||
component: "ControlCommand",
|
||||
isControlFlow: true,
|
||||
commandChain: ["try", "catch", "end"],
|
||||
subCommands: [
|
||||
{
|
||||
label: "尝试执行",
|
||||
value: "try",
|
||||
icon: "play_circle",
|
||||
codeTemplate: "try {",
|
||||
},
|
||||
{
|
||||
label: "捕获异常",
|
||||
value: "catch",
|
||||
icon: "error",
|
||||
codeTemplate: "} catch (${errorVar}) {",
|
||||
config: [
|
||||
{
|
||||
key: "errorVar",
|
||||
label: "错误",
|
||||
type: "controlInput",
|
||||
defaultValue: "error",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "最后执行",
|
||||
value: "finally",
|
||||
icon: "done_all",
|
||||
codeTemplate: "} finally {",
|
||||
},
|
||||
{
|
||||
label: "结束",
|
||||
value: "end",
|
||||
codeTemplate: "}",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -93,7 +93,7 @@ export const dataCommands = {
|
||||
desc: "Buffer创建、转换和操作",
|
||||
config: [],
|
||||
icon: "memory",
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
value: "quickcomposer.data.buffer.from",
|
||||
label: "创建Buffer",
|
||||
|
||||
@@ -17,7 +17,7 @@ export const mathCommands = {
|
||||
type: "numInput",
|
||||
},
|
||||
],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
label: "正弦(sin)",
|
||||
value: "Math.sin",
|
||||
|
||||
@@ -61,7 +61,7 @@ export const networkCommands = {
|
||||
width: "auto",
|
||||
},
|
||||
],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
value: "quickcomposer.network.url.parse",
|
||||
label: "解析URL",
|
||||
@@ -239,7 +239,7 @@ export const networkCommands = {
|
||||
width: "auto",
|
||||
},
|
||||
],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
label: "DNS查询",
|
||||
value: "quickcomposer.network.dns.lookupHost",
|
||||
|
||||
@@ -19,7 +19,7 @@ export const simulateCommands = {
|
||||
value: "quickcommand.simulateCopy",
|
||||
label: "模拟复制粘贴",
|
||||
config: [],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
value: "quickcommand.simulateCopy",
|
||||
label: "复制",
|
||||
@@ -73,7 +73,7 @@ export const simulateCommands = {
|
||||
width: 6,
|
||||
},
|
||||
],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
label: "单击",
|
||||
value: "utools.simulateMouseClick",
|
||||
@@ -94,7 +94,7 @@ export const simulateCommands = {
|
||||
{
|
||||
value: "utools.simulateMouseMove",
|
||||
label: "鼠标位置",
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
label: "移动到坐标",
|
||||
value: "utools.simulateMouseMove",
|
||||
|
||||
@@ -22,7 +22,7 @@ export const systemCommands = {
|
||||
label: "获取剪贴板内容",
|
||||
outputVariable: "clipboardContent",
|
||||
saveOutput: true,
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
value: "electron.clipboard.readText",
|
||||
label: "剪贴板文本",
|
||||
@@ -59,7 +59,7 @@ export const systemCommands = {
|
||||
desc: "获取操作系统相关信息",
|
||||
icon: "computer",
|
||||
config: [],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
value: "quickcomposer.system.os.arch",
|
||||
label: "系统架构",
|
||||
@@ -162,7 +162,7 @@ export const systemCommands = {
|
||||
width: "auto",
|
||||
},
|
||||
],
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
value: "quickcomposer.system.path.normalize",
|
||||
label: "规范化路径",
|
||||
|
||||
@@ -56,7 +56,7 @@ const commonComponentGuide = {
|
||||
]
|
||||
`,
|
||||
},
|
||||
functionSelector: {
|
||||
subCommands: {
|
||||
description:
|
||||
"可选,函数选择器配置,用于一个命令包含多个相关函数的情况",
|
||||
properties: {
|
||||
@@ -67,7 +67,7 @@ const commonComponentGuide = {
|
||||
excludeConfig: "可选,要排除的通用参数索引数组",
|
||||
},
|
||||
example: `
|
||||
functionSelector: [
|
||||
subCommands: [
|
||||
{
|
||||
label: "DNS查询",
|
||||
value: "quickcomposer.network.dns.lookupHost",
|
||||
|
||||
Reference in New Issue
Block a user