diff --git a/src/components/editor/composer/composerConfig.js b/src/components/editor/composer/composerConfig.js index 41c6f4d..e89eda6 100644 --- a/src/components/editor/composer/composerConfig.js +++ b/src/components/editor/composer/composerConfig.js @@ -1,24 +1,24 @@ // 定义命令图标映射 export const commandIcons = { - 'open': 'folder_open', - 'locate': 'location_on', - 'visit': 'language', - 'utools.ubrowser.goto': 'public', - 'system': 'terminal', - 'copyTo': 'content_copy', - 'message': 'message', - 'alert': 'warning', - 'send': 'send', - 'utools.redirect': 'alt_route', - 'quickcommand.sleep': 'schedule', - 'keyTap': 'keyboard' -} + open: "folder_open", + locate: "location_on", + visit: "language", + "utools.ubrowser.goto": "public", + system: "terminal", + copyTo: "content_copy", + message: "message", + alert: "warning", + send: "send", + "utools.redirect": "alt_route", + "quickcommand.sleep": "schedule", + keyTap: "keyboard", +}; // 定义命令分类 export const commandCategories = [ { - label: '文件操作', - icon: 'folder', + label: "文件操作", + icon: "folder", commands: [ { value: "open", @@ -29,12 +29,12 @@ export const commandCategories = [ value: "locate", label: "在文件管理器中定位文件", desc: "要在文件管理器里显示的文件路径", - } - ] + }, + ], }, { - label: '网络操作', - icon: 'language', + label: "网络操作", + icon: "language", commands: [ { value: "visit", @@ -50,13 +50,13 @@ export const commandCategories = [ value: "ubrowser", label: "UBrowser浏览器操作", desc: "配置UBrowser浏览器操作", - hasUBrowserEditor: true - } - ] + hasUBrowserEditor: true, + }, + ], }, { - label: '系统操作', - icon: 'computer', + label: "系统操作", + icon: "computer", commands: [ { value: "system", @@ -67,12 +67,12 @@ export const commandCategories = [ value: "copyTo", label: "将内容写入剪贴板", desc: "要写入剪切板的内容", - } - ] + }, + ], }, { - label: '消息通知', - icon: 'notifications', + label: "消息通知", + icon: "notifications", commands: [ { value: "message", @@ -88,12 +88,12 @@ export const commandCategories = [ value: "send", label: "发送文本到活动窗口", desc: "要发送到窗口的文本内容", - } - ] + }, + ], }, { - label: '其他功能', - icon: 'more_horiz', + label: "其他功能", + icon: "more_horiz", commands: [ { value: "utools.redirect", @@ -104,36 +104,91 @@ export const commandCategories = [ value: "quickcommand.sleep", label: "添加延时", desc: "延迟的毫秒数", - } - ] + }, + ], }, { - label: '按键操作', - icon: 'keyboard', + label: "按键操作", + icon: "keyboard", commands: [ { value: "keyTap", label: "模拟按键", desc: "模拟键盘按键", - hasKeyRecorder: true - } - ] - } -] + hasKeyRecorder: true, + }, + ], + }, +]; // 定义哪些命令可以产生输出 export const commandsWithOutput = { - 'system': true, - 'open': true, - 'locate': true, - 'copyTo': true, - 'ubrowser': true, -} + system: true, + open: true, + locate: true, + copyTo: true, + ubrowser: true, +}; // 定义哪些命令可以接收输出 export const commandsAcceptOutput = { - 'message': true, - 'alert': true, - 'send': true, - 'copyTo': true, -} + message: true, + alert: true, + send: true, + copyTo: true, +}; + +// 添加 ubrowser 操作图标映射 +export const ubrowserActionIcons = { + wait: "timer", + click: "mouse", + css: "style", + press: "keyboard", + paste: "content_paste", + screenshot: "photo_camera", + pdf: "picture_as_pdf", + device: "devices", + cookies: "cookie", + evaluate: "code", + when: "rule", + mousedown: "mouse", + mouseup: "mouse", + file: "upload_file", + value: "edit", + check: "check_box", + focus: "center_focus_strong", + scroll: "swap_vert", + download: "download", + hide: "visibility_off", + show: "visibility", + devTools: "developer_board", +}; + +// 添加 ubrowser 可用操作列表 +export const ubrowserAvailableActions = [ + { label: "等待", value: "wait" }, + { label: "点击", value: "click" }, + { label: "注入CSS", value: "css" }, + { label: "按键", value: "press" }, + { label: "粘贴", value: "paste" }, + { label: "截图", value: "screenshot" }, + { label: "导出PDF", value: "pdf" }, + { label: "模拟设备", value: "device" }, + { label: "获取Cookie", value: "cookies" }, + { label: "设置Cookie", value: "setCookies" }, + { label: "删除Cookie", value: "removeCookies" }, + { label: "清除Cookie", value: "clearCookies" }, + { label: "执行脚本", value: "evaluate" }, + { label: "条件判断", value: "when" }, + { label: "鼠标按下", value: "mousedown" }, + { label: "鼠标释放", value: "mouseup" }, + { label: "上传文件", value: "file" }, + { label: "设置值", value: "value" }, + { label: "选中状态", value: "check" }, + { label: "获取焦点", value: "focus" }, + { label: "滚动", value: "scroll" }, + { label: "下载", value: "download" }, + { label: "隐藏", value: "hide" }, + { label: "显示", value: "show" }, + { label: "开发工具", value: "devTools" }, +]; diff --git a/src/components/editor/composer/ubrowser/UBrowserBasic.vue b/src/components/editor/composer/ubrowser/UBrowserBasic.vue index a2099d2..86f9168 100644 --- a/src/components/editor/composer/ubrowser/UBrowserBasic.vue +++ b/src/components/editor/composer/ubrowser/UBrowserBasic.vue @@ -1,86 +1,115 @@ - + - + + + + + - + - - - - - - 请求头 - - - - - - - + dense + outlined + @update:model-value="updateConfigs" + > + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/editor/composer/ubrowser/UBrowserEditor.vue b/src/components/editor/composer/ubrowser/UBrowserEditor.vue index f61e028..a1fae37 100644 --- a/src/components/editor/composer/ubrowser/UBrowserEditor.vue +++ b/src/components/editor/composer/ubrowser/UBrowserEditor.vue @@ -11,46 +11,18 @@ class="ubrowser-stepper" > - - + + - - - - - - - - - + + @@ -60,35 +32,55 @@ icon="settings_applications" class="q-pb-md" > - + + + - - diff --git a/src/components/editor/composer/ubrowser/UBrowserOperations.vue b/src/components/editor/composer/ubrowser/UBrowserOperations.vue index 7a7bc78..60c5898 100644 --- a/src/components/editor/composer/ubrowser/UBrowserOperations.vue +++ b/src/components/editor/composer/ubrowser/UBrowserOperations.vue @@ -1,54 +1,76 @@ - + + + + + + {{ action.label }} + + + + + + + - - + + + + {{ action.label }} + + + + - {{ action.label }} - - - - - import { defineComponent } from "vue"; +import { + ubrowserActionIcons, + ubrowserAvailableActions, +} from "../composerConfig"; import UBrowserOperation from "./operations/UBrowserOperation.vue"; export default defineComponent({ @@ -83,7 +109,12 @@ export default defineComponent({ required: true, }, }, - emits: ["remove-action", "update:selectedActions"], + emits: ["remove-action", "update:selectedActions", "update:configs"], + computed: { + availableActions() { + return ubrowserAvailableActions; + }, + }, methods: { moveAction(index, direction) { const newIndex = index + direction; @@ -96,31 +127,7 @@ export default defineComponent({ } }, getActionIcon(action) { - const iconMap = { - wait: "timer", - click: "mouse", - css: "style", - press: "keyboard", - paste: "content_paste", - screenshot: "photo_camera", - pdf: "picture_as_pdf", - device: "devices", - cookies: "cookie", - evaluate: "code", - when: "rule", - mousedown: "mouse", - mouseup: "mouse", - file: "upload_file", - value: "edit", - check: "check_box", - focus: "center_focus_strong", - scroll: "swap_vert", - download: "download", - hide: "visibility_off", - show: "visibility", - devTools: "developer_board", - }; - return iconMap[action] || "touch_app"; + return ubrowserActionIcons[action] || "touch_app"; }, getOperationConfig(action) { const configs = { @@ -130,6 +137,7 @@ export default defineComponent({ label: "等待时间(ms)或CSS选择器", icon: "timer", type: "input", + width: 8, }, { key: "timeout", @@ -137,6 +145,7 @@ export default defineComponent({ icon: "timer_off", type: "input", inputType: "number", + width: 4, }, ], click: [ @@ -156,9 +165,16 @@ export default defineComponent({ }, ], press: [ - { key: "key", label: "按键", icon: "keyboard", type: "input" }, + { + key: "key", + label: "按键", + icon: "keyboard", + type: "input", + width: 5, + }, { key: "modifiers", + label: "修饰键", type: "checkbox-group", options: [ { label: "Ctrl", value: "ctrl" }, @@ -166,6 +182,8 @@ export default defineComponent({ { label: "Alt", value: "alt" }, { label: "Meta", value: "meta" }, ], + defaultValue: [], + width: 7, }, ], paste: [ @@ -202,7 +220,7 @@ export default defineComponent({ icon: "drag_handle", type: "input", inputType: "number", - width: 6, + width: 3, }, { key: "rect.y", @@ -210,7 +228,7 @@ export default defineComponent({ icon: "drag_handle", type: "input", inputType: "number", - width: 6, + width: 3, }, { key: "rect.width", @@ -218,7 +236,7 @@ export default defineComponent({ icon: "width", type: "input", inputType: "number", - width: 6, + width: 3, }, { key: "rect.height", @@ -226,7 +244,7 @@ export default defineComponent({ icon: "height", type: "input", inputType: "number", - width: 6, + width: 3, }, { key: "savePath", label: "保存路径", icon: "save", type: "input" }, ], @@ -240,12 +258,14 @@ export default defineComponent({ { label: "无边距", value: 1 }, { label: "最小边距", value: 2 }, ], + width: 6, }, { key: "options.pageSize", label: "页面大小", type: "select", options: ["A3", "A4", "A5", "Legal", "Letter", "Tabloid"], + width: 6, }, { key: "savePath", label: "保存路径", icon: "save", type: "input" }, ], @@ -325,7 +345,7 @@ export default defineComponent({ icon: "upload_file", type: "input", }, - { key: "files", label: "文件列表", type: "file-list" }, + { key: "files", label: "文件列表", type: "file-list", width: 12 }, ], value: [ { @@ -333,8 +353,15 @@ export default defineComponent({ label: "元素选择器", icon: "input", type: "input", + width: 6, + }, + { + key: "value", + label: "设置的值", + icon: "edit", + type: "input", + width: 6, }, - { key: "value", label: "设置的值", icon: "edit", type: "input" }, ], check: [ { @@ -342,8 +369,15 @@ export default defineComponent({ label: "复选框/选框选择器", icon: "check_box", type: "input", + width: 8, + }, + { + key: "checked", + label: "选中状态", + type: "checkbox", + defaultValue: false, + width: 4, }, - { key: "checked", label: "选中状态", type: "checkbox" }, ], focus: [ { @@ -355,10 +389,23 @@ export default defineComponent({ ], scroll: [ { - key: "target", - label: "目标元素选择器(可选)", + key: "type", + label: "滚动类型", + type: "button-toggle", + options: [ + { label: "滚动到元素", value: "element" }, + { label: "滚动到坐标", value: "position" }, + ], + defaultValue: "element", + }, + { + key: "selector", + label: "目标元素选择器", icon: "swap_vert", type: "input", + width: 12, + showWhen: "type", + showValue: "element", }, { key: "x", @@ -367,6 +414,8 @@ export default defineComponent({ type: "input", inputType: "number", width: 6, + showWhen: "type", + showValue: "position", }, { key: "y", @@ -375,15 +424,84 @@ export default defineComponent({ type: "input", inputType: "number", width: 6, + showWhen: "type", + showValue: "position", }, ], download: [ - { key: "url", label: "下载URL", icon: "link", type: "input" }, - { key: "savePath", label: "保存路径", icon: "save", type: "input" }, + { + key: "url", + label: "下载URL", + icon: "link", + type: "input", + width: 6, + }, + { + key: "savePath", + label: "保存路径", + icon: "save", + type: "input", + width: 6, + }, + ], + devTools: [ + { + key: "mode", + label: "开发工具位置", + type: "button-toggle", + options: [ + { label: "右侧", value: "right" }, + { label: "底部", value: "bottom" }, + { label: "独立", value: "undocked" }, + { label: "分离", value: "detach" }, + ], + defaultValue: "right", + }, ], }; return configs[action]; }, + toggleAction(action) { + const index = this.selectedActions.findIndex( + (a) => a.value === action.value + ); + if (index === -1) { + // 添加操作 + this.$emit("update:selectedActions", [ + ...this.selectedActions, + { + ...action, + id: Date.now(), + argv: "", + saveOutput: false, + useOutput: null, + cmd: action.value || action.cmd, + value: action.value || action.cmd, + }, + ]); + + // 初始化配置对象 + const config = this.getOperationConfig(action.value); + if (config) { + const newConfigs = { ...this.configs }; + if (!newConfigs[action.value]) { + newConfigs[action.value] = {}; + } + // 设置默认值 + config.forEach((field) => { + if (field.defaultValue !== undefined) { + newConfigs[action.value][field.key] = field.defaultValue; + } + }); + this.$emit("update:configs", newConfigs); + } + } else { + // 移除操作 + const newActions = [...this.selectedActions]; + newActions.splice(index, 1); + this.$emit("update:selectedActions", newActions); + } + }, }, }); @@ -410,12 +528,7 @@ export default defineComponent({ } .operation-item:hover { - background: rgba(0, 0, 0, 0.25); -} - -.body--dark .operation-item { - border: 1px solid rgba(255, 255, 255, 0.1); - background: rgba(0, 0, 0, 0.15); + background: rgba(0, 0, 0, 0.05); } .body--dark .operation-item:hover { @@ -452,4 +565,51 @@ export default defineComponent({ .operation-item:hover .q-item-section { opacity: 1; } + +.action-card { + transition: all 0.3s ease; + border: 1px solid rgba(0, 0, 0, 0.05); + /* min-height: 42px; */ +} + +.action-card:hover { + transform: translateY(-1px); + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); + background: var(--q-primary-opacity-5); +} + +.action-selected { + border-color: var(--q-primary); + background: var(--q-primary-opacity-10); +} + +.body--dark .action-selected { + background: var(--q-primary-opacity-40); +} + +.body--dark .action-card { + border-color: rgba(255, 255, 255, 0.1); +} + +.body--dark .action-card:hover { + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); + background: var(--q-primary-opacity-20); +} + +.text-caption { + font-size: 11px; + line-height: 1.1; +} + +.q-card__section { + padding: 4px !important; +} + +.row.q-col-gutter-xs { + margin: -2px; +} + +.row.q-col-gutter-xs > * { + padding: 2px; +} diff --git a/src/components/editor/composer/ubrowser/UBrowserRun.vue b/src/components/editor/composer/ubrowser/UBrowserRun.vue index 1bff1f0..11f7d66 100644 --- a/src/components/editor/composer/ubrowser/UBrowserRun.vue +++ b/src/components/editor/composer/ubrowser/UBrowserRun.vue @@ -1,201 +1,248 @@ - + - - - - - - 窗口大小 - - + - + + - + - 窗口位置 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + - 窗口限制 - - + - - - - + - 窗口行为 - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + 透明度 + + + {{ localConfigs.run.opacity.toFixed(1) }} + + diff --git a/src/components/editor/composer/ubrowser/operations/UBrowserOperation.vue b/src/components/editor/composer/ubrowser/operations/UBrowserOperation.vue index 5b7e988..cf6cbc5 100644 --- a/src/components/editor/composer/ubrowser/operations/UBrowserOperation.vue +++ b/src/components/editor/composer/ubrowser/operations/UBrowserOperation.vue @@ -1,189 +1,258 @@ - - {{ title }} - - - - - - - - - - + + + + + + + + + - - - + + {{ field.label }} + - - - + + + + + + + - - - + + + @update:model-value="updateValue(field.key, $event)" + > + + + + + + + + + + + + + - - + + - - - - + + + + + + + + + + - + - - - - + {{ field.label }} + + + - - - - {{ param }} - + + + - - - - - - - - - {{ file }} - + + + + + + + + + + + + - - + + + + + {{ field.label }} + + + + +