编排配置文件优化

This commit is contained in:
fofolee 2024-12-30 09:16:12 +08:00
parent c94256c14d
commit dfc1c7e2e3
13 changed files with 342 additions and 209 deletions

View File

@ -217,7 +217,7 @@ export default defineComponent({
/* 输入框标签字体大小,占位时的位置 */
.command-composer :deep(.q-field--filled .q-field__label) {
font-size: 11px;
top: 8px;
top: 10px;
}
/* 输入框标签悬浮的位置 */

View File

@ -76,27 +76,28 @@
<!-- 参数输入 -->
<div class="row items-center">
<!-- 按键编辑器 -->
<template v-if="command.hasKeyRecorder">
<KeyEditor v-model="argvLocal" class="col" />
</template>
<!-- UBrowser编辑器 -->
<template v-else-if="command.hasUBrowserEditor">
<UBrowserEditor v-model="argvLocal" class="col" />
</template>
<!-- Axios编辑器 -->
<template v-else-if="command.hasAxiosEditor">
<AxiosConfigEditor v-model="argvLocal" class="col" />
</template>
<!-- 普通参数输入 -->
<template v-else-if="!command.hasNoArgs">
<!-- 单独写组件的参数 -->
<component
:is="command.component"
v-model="argvLocal"
class="col"
v-if="!!command.component"
/>
<!-- 通用组件参数 -->
<template v-else>
<div
v-for="item in command.config"
:key="item.key"
class="col-12 row q-col-gutter-xs"
>
<VariableInput
v-model="argvLocal"
:label="placeholder"
:label="item.label"
:command="command"
class="col"
ref="variableInput"
:class="`col-${item.width || 12}`"
v-if="item.type === 'input'"
/>
</div>
</template>
</div>
</div>

View File

@ -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('","')

View File

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

View File

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

View File

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

View File

@ -0,0 +1,12 @@
export const keyCommands = {
label: "按键操作",
icon: "keyboard",
commands: [
{
value: "keyTap",
label: "模拟按键",
config: [],
component: "KeyEditor",
},
],
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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