diff --git a/src/components/editor/composer/CommandComposer.vue b/src/components/editor/composer/CommandComposer.vue
index f27f632..45fc94b 100644
--- a/src/components/editor/composer/CommandComposer.vue
+++ b/src/components/editor/composer/CommandComposer.vue
@@ -217,7 +217,7 @@ export default defineComponent({
/* 输入框标签字体大小,占位时的位置 */
.command-composer :deep(.q-field--filled .q-field__label) {
font-size: 11px;
- top: 8px;
+ top: 10px;
}
/* 输入框标签悬浮的位置 */
diff --git a/src/components/editor/composer/ComposerCard.vue b/src/components/editor/composer/ComposerCard.vue
index 1b05ac7..b099f3f 100644
--- a/src/components/editor/composer/ComposerCard.vue
+++ b/src/components/editor/composer/ComposerCard.vue
@@ -76,27 +76,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/components/editor/composer/KeyEditor.vue b/src/components/editor/composer/KeyEditor.vue
index cfee92e..78080d8 100644
--- a/src/components/editor/composer/KeyEditor.vue
+++ b/src/components/editor/composer/KeyEditor.vue
@@ -272,12 +272,12 @@ export default defineComponent({
const args = [this.mainKey, ...activeModifiers];
// 为每个参数添加引号
- this.$emit("update:modelValue", `"${args.join('","')}"`);
+ this.$emit("update:modelValue", `keyTap("${args.join('","')}")`);
},
parseKeyString(val) {
try {
- // 移除开头和结尾的引号
- const cleanVal = val.replace(/^"|"$/g, "");
+ // 移除 keyTap 和引号
+ const cleanVal = val.replace(/^keyTap\("/, "").replace(/"\)$/, "");
// 分割并移除每个参数的引号
const args = cleanVal
.split('","')
diff --git a/src/js/composer/commands/encodeCommands.js b/src/js/composer/commands/encodeCommands.js
new file mode 100644
index 0000000..16f3f3a
--- /dev/null
+++ b/src/js/composer/commands/encodeCommands.js
@@ -0,0 +1,84 @@
+export const encodeCommands = {
+ label: "编码解码",
+ icon: "code",
+ commands: [
+ {
+ value: "(text=>Buffer.from(text).toString('base64'))",
+ label: "Base64编码",
+ config: [
+ {
+ key: "text",
+ label: "要编码的文本",
+ type: "input",
+ defaultValue: "",
+ icon: "lock",
+ },
+ ],
+ },
+ {
+ value: "(text=>Buffer.from(text,'base64').toString())",
+ label: "Base64解码",
+ config: [
+ {
+ key: "text",
+ label: "要解码的Base64文本",
+ type: "input",
+ defaultValue: "",
+ icon: "lock_open",
+ },
+ ],
+ },
+ {
+ value: "(text=>Buffer.from(text).toString('hex'))",
+ label: "十六进制编码",
+ config: [
+ {
+ key: "text",
+ label: "要编码的文本",
+ type: "input",
+ defaultValue: "",
+ icon: "lock",
+ },
+ ],
+ },
+ {
+ value: "(text=>Buffer.from(text,'hex').toString())",
+ label: "十六进制解码",
+ config: [
+ {
+ key: "text",
+ label: "要解码的十六进制文本",
+ type: "input",
+ defaultValue: "",
+ icon: "lock_open",
+ },
+ ],
+ },
+ {
+ value: "encodeURIComponent",
+ label: "URL编码",
+ config: [
+ {
+ key: "text",
+ label: "要编码的文本",
+ type: "input",
+ defaultValue: "",
+ icon: "link",
+ },
+ ],
+ },
+ {
+ value: "decodeURIComponent",
+ label: "URL解码",
+ config: [
+ {
+ key: "text",
+ label: "要解码的URL编码文本",
+ type: "input",
+ defaultValue: "",
+ icon: "link_off",
+ },
+ ],
+ },
+ ],
+};
diff --git a/src/js/composer/commands/fileCommands.js b/src/js/composer/commands/fileCommands.js
new file mode 100644
index 0000000..7a640c3
--- /dev/null
+++ b/src/js/composer/commands/fileCommands.js
@@ -0,0 +1,32 @@
+export const fileCommands = {
+ label: "文件操作",
+ icon: "folder",
+ commands: [
+ {
+ value: "open",
+ label: "打开文件/文件夹/软件",
+ config: [
+ {
+ key: "path",
+ label: "文件、文件夹或软件的绝对路径",
+ type: "input",
+ defaultValue: "",
+ icon: "folder_open",
+ },
+ ],
+ },
+ {
+ value: "locate",
+ label: "在文件管理器中定位文件",
+ config: [
+ {
+ key: "path",
+ label: "文件、文件夹或软件的绝对路径",
+ type: "input",
+ defaultValue: "",
+ icon: "location_on",
+ },
+ ],
+ },
+ ],
+};
diff --git a/src/js/composer/commands/index.js b/src/js/composer/commands/index.js
new file mode 100644
index 0000000..ea22846
--- /dev/null
+++ b/src/js/composer/commands/index.js
@@ -0,0 +1,17 @@
+import { fileCommands } from "./fileCommands";
+import { networkCommands } from "./networkCommands";
+import { systemCommands } from "./systemCommands";
+import { notifyCommands } from "./notifyCommands";
+import { encodeCommands } from "./encodeCommands";
+import { otherCommands } from "./otherCommands";
+import { keyCommands } from "./keyCommands";
+
+export const commandCategories = [
+ fileCommands,
+ networkCommands,
+ systemCommands,
+ notifyCommands,
+ encodeCommands,
+ otherCommands,
+ keyCommands,
+];
diff --git a/src/js/composer/commands/keyCommands.js b/src/js/composer/commands/keyCommands.js
new file mode 100644
index 0000000..c03d7a3
--- /dev/null
+++ b/src/js/composer/commands/keyCommands.js
@@ -0,0 +1,12 @@
+export const keyCommands = {
+ label: "按键操作",
+ icon: "keyboard",
+ commands: [
+ {
+ value: "keyTap",
+ label: "模拟按键",
+ config: [],
+ component: "KeyEditor",
+ },
+ ],
+};
diff --git a/src/js/composer/commands/networkCommands.js b/src/js/composer/commands/networkCommands.js
new file mode 100644
index 0000000..2de503e
--- /dev/null
+++ b/src/js/composer/commands/networkCommands.js
@@ -0,0 +1,49 @@
+export const networkCommands = {
+ label: "网络操作",
+ icon: "language",
+ commands: [
+ {
+ value: "visit",
+ label: "用默认浏览器打开网址",
+ config: [
+ {
+ key: "url",
+ label: "要访问的网址链接",
+ type: "input",
+ defaultValue: "",
+ icon: "language",
+ },
+ ],
+ },
+ {
+ value: "utools.ubrowser.goto",
+ label: "用ubrowser打开网址",
+ config: [
+ {
+ key: "url",
+ label: "要访问的网址链接",
+ type: "input",
+ defaultValue: "",
+ icon: "public",
+ },
+ ],
+ isAsync: true,
+ },
+ {
+ value: "ubrowser",
+ label: "ubrowser浏览器操作",
+ config: [],
+ component: "UBrowserEditor",
+ isAsync: true,
+ icon: "public",
+ },
+ {
+ value: "axios",
+ label: "HTTP请求(Axios)",
+ config: [],
+ component: "AxiosConfigEditor",
+ isAsync: true,
+ icon: "http",
+ },
+ ],
+};
diff --git a/src/js/composer/commands/notifyCommands.js b/src/js/composer/commands/notifyCommands.js
new file mode 100644
index 0000000..f6f91b2
--- /dev/null
+++ b/src/js/composer/commands/notifyCommands.js
@@ -0,0 +1,45 @@
+export const notifyCommands = {
+ label: "消息通知",
+ icon: "notifications",
+ commands: [
+ {
+ value: "console.log",
+ label: "打印消息",
+ config: [
+ {
+ key: "message",
+ label: "要打印的消息文本",
+ type: "input",
+ defaultValue: "",
+ icon: "info",
+ },
+ ],
+ },
+ {
+ value: "message",
+ label: "发送系统消息",
+ config: [
+ {
+ key: "message",
+ label: "要发送的系统消息文本",
+ type: "input",
+ defaultValue: "",
+ icon: "message",
+ },
+ ],
+ },
+ {
+ value: "send",
+ label: "发送文本到活动窗口",
+ config: [
+ {
+ key: "text",
+ label: "要发送到窗口的文本内容",
+ type: "input",
+ defaultValue: "",
+ icon: "send",
+ },
+ ],
+ },
+ ],
+};
diff --git a/src/js/composer/commands/otherCommands.js b/src/js/composer/commands/otherCommands.js
new file mode 100644
index 0000000..3c07cea
--- /dev/null
+++ b/src/js/composer/commands/otherCommands.js
@@ -0,0 +1,33 @@
+export const otherCommands = {
+ label: "其他功能",
+ icon: "more_horiz",
+ commands: [
+ {
+ value: "utools.redirect",
+ label: "转至指定插件",
+ config: [
+ {
+ key: "pluginName",
+ label: "要跳转至的插件名称",
+ type: "input",
+ defaultValue: "",
+ icon: "alt_route",
+ },
+ ],
+ },
+ {
+ value: "quickcommand.sleep",
+ label: "添加延时",
+ config: [
+ {
+ key: "ms",
+ label: "延迟的毫秒数",
+ type: "input",
+ inputType: "number",
+ defaultValue: "",
+ icon: "schedule",
+ },
+ ],
+ },
+ ],
+};
diff --git a/src/js/composer/commands/systemCommands.js b/src/js/composer/commands/systemCommands.js
new file mode 100644
index 0000000..c1a2f87
--- /dev/null
+++ b/src/js/composer/commands/systemCommands.js
@@ -0,0 +1,38 @@
+export const systemCommands = {
+ label: "系统操作",
+ icon: "computer",
+ commands: [
+ {
+ value: "system",
+ label: "执行系统命令",
+ config: [
+ {
+ key: "command",
+ label: "要执行的命令行",
+ type: "input",
+ defaultValue: "",
+ icon: "terminal",
+ },
+ ],
+ },
+ {
+ value: "copyTo",
+ label: "将内容写入剪贴板",
+ config: [
+ {
+ key: "content",
+ label: "要写入剪切板的内容",
+ type: "input",
+ defaultValue: "",
+ icon: "content_copy",
+ },
+ ],
+ },
+ {
+ value: "electron.clipboard.readText",
+ label: "获取剪贴板内容",
+ config: [],
+ icon: "content_copy",
+ },
+ ],
+};
diff --git a/src/js/composer/composerConfig.js b/src/js/composer/composerConfig.js
index 9a90bd7..f8ce711 100644
--- a/src/js/composer/composerConfig.js
+++ b/src/js/composer/composerConfig.js
@@ -3,182 +3,4 @@ export {
defaultUBrowserConfigs,
} from "./ubrowserConfig";
-// 定义命令分类
-export const commandCategories = [
- {
- label: "文件操作",
- icon: "folder",
- commands: [
- {
- value: "open",
- label: "打开文件/文件夹/软件",
- desc: "文件、文件夹或软件的绝对路径",
- icon: "folder_open",
- },
- {
- value: "locate",
- label: "在文件管理器中定位文件",
- desc: "要在文件管理器里显示的文件路径",
- icon: "location_on",
- },
- ],
- },
- {
- label: "网络操作",
- icon: "language",
- commands: [
- {
- value: "visit",
- label: "用默认浏览器打开网址",
- desc: "要访问的网址链接",
- icon: "language",
- },
- {
- value: "utools.ubrowser.goto",
- label: "用ubrowser打开网址",
- desc: "要访问的网址链接",
- isAsync: true,
- icon: "public",
- },
- {
- value: "ubrowser",
- label: "ubrowser浏览器操作",
- desc: "配置ubrowser浏览器操作",
- hasUBrowserEditor: true,
- isAsync: true,
- icon: "public",
- },
- {
- value: "axios",
- label: "HTTP请求(Axios)",
- desc: "使用Axios发送HTTP请求",
- hasAxiosEditor: true,
- isAsync: true,
- icon: "http",
- },
- ],
- },
- {
- label: "系统操作",
- icon: "computer",
- commands: [
- {
- value: "system",
- label: "执行系统命令",
- desc: "要执行的命令行",
- icon: "terminal",
- },
- {
- value: "copyTo",
- label: "将内容写入剪贴板",
- desc: "要写入剪切板的内容",
- icon: "content_copy",
- },
- {
- value: "electron.clipboard.readText",
- label: "获取剪贴板内容",
- desc: "获取剪贴板内容",
- icon: "content_copy",
- hasNoArgs: true,
- },
- ],
- },
- {
- label: "消息通知",
- icon: "notifications",
- commands: [
- {
- value: "console.log",
- label: "打印消息",
- desc: "要打印的消息文本",
- icon: "info",
- },
- {
- value: "message",
- label: "发送系统消息",
- desc: "要发送的系统消息文本",
- icon: "message",
- },
- {
- value: "send",
- label: "发送文本到活动窗口",
- desc: "要发送到窗口的文本内容",
- icon: "send",
- },
- ],
- },
- {
- label: "编码解码",
- icon: "code",
- commands: [
- {
- value: "(text=>Buffer.from(text).toString('base64'))",
- label: "Base64编码",
- desc: "将文本编码为Base64",
- icon: "lock",
- },
- {
- value: "(text=>Buffer.from(text,'base64').toString())",
- label: "Base64解码",
- desc: "将Base64解码为文本",
- icon: "lock_open",
- },
- {
- value: "(text=>Buffer.from(text).toString('hex'))",
- label: "十六进制编码",
- desc: "将文本编码为十六进制",
- icon: "lock",
- },
- {
- value: "(text=>Buffer.from(text,'hex').toString())",
- label: "十六进制解码",
- desc: "将十六进制解码为文本",
- icon: "lock_open",
- },
- {
- value: "encodeURIComponent",
- label: "URL编码",
- desc: "将文本进行URL编码",
- icon: "link",
- },
- {
- value: "decodeURIComponent",
- label: "URL解码",
- desc: "将URL编码解码为文本",
- icon: "link_off",
- },
- ],
- },
- {
- label: "其他功能",
- icon: "more_horiz",
- commands: [
- {
- value: "utools.redirect",
- label: "转至指定插件",
- desc: "要跳转至的插件名称",
- icon: "alt_route",
- },
- {
- value: "quickcommand.sleep",
- label: "添加延时",
- desc: "延迟的毫秒数",
- inputType: "number",
- icon: "schedule",
- },
- ],
- },
- {
- label: "按键操作",
- icon: "keyboard",
- commands: [
- {
- value: "keyTap",
- label: "模拟按键",
- desc: "模拟键盘按键",
- hasKeyRecorder: true,
- icon: "keyboard",
- },
- ],
- },
-];
+export { commandCategories } from "./commands";
diff --git a/src/js/composer/generateCode.js b/src/js/composer/generateCode.js
index b2cfb8a..986e2b9 100644
--- a/src/js/composer/generateCode.js
+++ b/src/js/composer/generateCode.js
@@ -12,12 +12,12 @@ export function generateCode(commandFlow) {
line += `let ${cmd.outputVariable} = `;
}
- if (cmd.value === "ubrowser") {
- line += `await ${cmd.argv}`;
- } else if (cmd.value === "axios" || cmd.value === "fetch") {
- line += `await ${cmd.argv}`;
+ let awaitCmd = cmd.isAsync ? "await " : "";
+
+ if (!!cmd.component) {
+ line += `${awaitCmd}${cmd.argv}`;
} else {
- line += `${cmd.isAsync ? "await " : ""}${cmd.value}(${cmd.argv})`;
+ line += `${awaitCmd}${cmd.value}(${cmd.argv})`;
}
code.push(line);