mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 14:34:13 +08:00
读剪贴板支持图片、html、rtf,新增用户数据分类
This commit is contained in:
parent
cdd7b89e72
commit
d2c3b7999c
@ -57,7 +57,7 @@
|
||||
v-model="localCommand"
|
||||
:class="
|
||||
localCommand.config?.length || localCommand.functionSelector
|
||||
? 'col q-mt-sm'
|
||||
? 'col q-mt-md'
|
||||
: 'col'
|
||||
"
|
||||
/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<component
|
||||
:is="!!label ? 'BorderLabel' : 'div'"
|
||||
:label="label"
|
||||
:is="!!topLabel ? 'BorderLabel' : 'div'"
|
||||
:label="topLabel"
|
||||
:icon="icon"
|
||||
:model-value="isCollapse"
|
||||
>
|
||||
@ -143,6 +143,10 @@ export default defineComponent({
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
topLabel: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: "",
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="key-editor">
|
||||
<div class="row items-center q-gutter-x-sm full-width">
|
||||
<div class="row items-center q-gutter-x-sm full-width q-mb-sm">
|
||||
<!-- 按键选择/输入区域 -->
|
||||
<q-select
|
||||
ref="mainKeyInput"
|
||||
@ -16,20 +16,21 @@
|
||||
map-options
|
||||
options-dense
|
||||
behavior="menu"
|
||||
class="col q-px-sm"
|
||||
class="col"
|
||||
:input-style="{
|
||||
textAlign: 'center',
|
||||
}"
|
||||
placeholder="选择或输入按键"
|
||||
@update:model-value="handleKeyInput"
|
||||
@input="handleInput"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<!-- 修饰键 -->
|
||||
<div class="row items-center q-gutter-x-xs no-wrap">
|
||||
<div class="row items-center q-gutter-x-xs no-wrap q-pa-sm">
|
||||
<q-chip
|
||||
v-for="(active, key) in argvs.modifiers"
|
||||
:key="key"
|
||||
:color="active ? 'primary' : 'grey-4'"
|
||||
:text-color="active ? 'white' : 'grey-7'"
|
||||
dense
|
||||
:class="{ 'modifier-chip-active': active }"
|
||||
clickable
|
||||
class="modifier-chip"
|
||||
@click="toggleModifier(key)"
|
||||
@ -49,6 +50,9 @@
|
||||
{{ mainKeyDisplay }}
|
||||
</q-badge>
|
||||
</template>
|
||||
<template v-slot:append>
|
||||
|
||||
</template>
|
||||
</q-select>
|
||||
<!-- 录制按钮 -->
|
||||
<q-btn
|
||||
@ -62,17 +66,54 @@
|
||||
<q-tooltip>{{ isRecording ? "停止录制" : "开始录制" }}</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
<!-- 按键控制区 -->
|
||||
<div class="row q-gutter-x-sm full-width">
|
||||
<!-- 重复次数 -->
|
||||
<div class="col">
|
||||
<number-input
|
||||
v-model="argvs.repeatCount"
|
||||
label="重复次数"
|
||||
icon="repeat"
|
||||
@update:model-value="(val) => updateValue({ repeatCount: val })"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 重复间隔 -->
|
||||
<div class="col">
|
||||
<number-input
|
||||
v-model="argvs.repeatInterval"
|
||||
label="重复间隔(ms)"
|
||||
icon="timer"
|
||||
:disable="argvs.repeatCount <= 1"
|
||||
@update:model-value="(val) => updateValue({ repeatInterval: val })"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 按键后延迟 -->
|
||||
<div class="col">
|
||||
<number-input
|
||||
v-model="argvs.keyDelay"
|
||||
label="按键后延迟(ms)"
|
||||
icon="hourglass_empty"
|
||||
@update:model-value="(val) => updateValue({ keyDelay: val })"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from "vue";
|
||||
import NumberInput from "../common/NumberInput.vue";
|
||||
|
||||
// 检测操作系统
|
||||
const isMac = window.utools.isMacOs();
|
||||
|
||||
export default defineComponent({
|
||||
name: "KeyEditor",
|
||||
components: {
|
||||
NumberInput,
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object,
|
||||
@ -91,6 +132,9 @@ export default defineComponent({
|
||||
shift: false,
|
||||
command: false,
|
||||
},
|
||||
repeatCount: 1,
|
||||
repeatInterval: 0,
|
||||
keyDelay: 0,
|
||||
},
|
||||
modifierLabels: isMac
|
||||
? {
|
||||
@ -284,6 +328,19 @@ export default defineComponent({
|
||||
.map((key) => (!isMac && key === "command" ? "meta" : key));
|
||||
|
||||
const args = [argvs.mainKey, ...activeModifiers];
|
||||
|
||||
// 添加重复次数、间隔和延迟参数
|
||||
const options = {};
|
||||
if (argvs.repeatCount > 1) options.repeatCount = argvs.repeatCount;
|
||||
if (argvs.repeatInterval > 0)
|
||||
options.repeatInterval = argvs.repeatInterval;
|
||||
if (argvs.keyDelay > 0) options.keyDelay = argvs.keyDelay;
|
||||
|
||||
if (Object.keys(options).length > 0) {
|
||||
return `${this.modelValue.value}("${args.join(
|
||||
'","'
|
||||
)}", ${JSON.stringify(options)})`;
|
||||
}
|
||||
return `${this.modelValue.value}("${args.join('","')}")`;
|
||||
},
|
||||
updateValue(argv) {
|
||||
@ -302,22 +359,40 @@ export default defineComponent({
|
||||
if (!code) return argvs;
|
||||
try {
|
||||
// 移除 keyTap 和引号
|
||||
const cleanVal = val.replace(/^keyTap\("/, "").replace(/"\)$/, "");
|
||||
const cleanVal = code.replace(/^keyTap\("/, "").replace(/"\)$/, "");
|
||||
// 分割并移除每个参数的引号
|
||||
const args = cleanVal
|
||||
const parts = cleanVal.split(/,\s*/);
|
||||
const keyParts = parts[0]
|
||||
.split('","')
|
||||
.map((arg) => arg.replace(/^"|"$/g, ""));
|
||||
if (args.length > 0) {
|
||||
argvs.mainKey = args[0];
|
||||
|
||||
if (keyParts.length > 0) {
|
||||
argvs.mainKey = keyParts[0];
|
||||
Object.keys(argvs.modifiers).forEach((key) => {
|
||||
// 在非 Mac 系统上,将 meta 转换为 command
|
||||
const modKey = !isMac && args.includes("meta") ? "command" : key;
|
||||
argvs.modifiers[key] = args.includes(modKey);
|
||||
const modKey =
|
||||
!isMac && keyParts.includes("meta") ? "command" : key;
|
||||
argvs.modifiers[key] = keyParts.includes(modKey);
|
||||
});
|
||||
return argvs;
|
||||
}
|
||||
|
||||
// 解析选项对象
|
||||
if (parts.length > 1) {
|
||||
try {
|
||||
const options = JSON.parse(parts[1]);
|
||||
if (options.repeatCount) argvs.repeatCount = options.repeatCount;
|
||||
if (options.repeatInterval)
|
||||
argvs.repeatInterval = options.repeatInterval;
|
||||
if (options.keyDelay) argvs.keyDelay = options.keyDelay;
|
||||
} catch (e) {
|
||||
console.warn("Failed to parse key options:", e);
|
||||
}
|
||||
}
|
||||
|
||||
return argvs;
|
||||
} catch (e) {
|
||||
console.error("Failed to parse key string:", e);
|
||||
return argvs;
|
||||
}
|
||||
},
|
||||
handleKeyInput(val) {
|
||||
@ -360,14 +435,21 @@ export default defineComponent({
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.key-editor {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.modifier-chip {
|
||||
height: 24px;
|
||||
font-size: 13px;
|
||||
margin: 0 2px;
|
||||
border-radius: 8px;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.modifier-chip-active {
|
||||
background-color: var(--q-primary) !important;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.body--dark .modifier-chip {
|
||||
background-color: rgba(44, 44, 44, 0.5);
|
||||
}
|
||||
|
||||
.main-key {
|
||||
|
@ -1,8 +1,13 @@
|
||||
<template>
|
||||
<q-btn-group :stretch="stretch" class="text-primary">
|
||||
<q-btn icon="image" @click="dataUrlToImg" v-show="imagebtn" dense size="sm"
|
||||
><q-tooltip v-if="!dense">将 DataUrl 转为图片</q-tooltip></q-btn
|
||||
>
|
||||
<q-btn
|
||||
icon="image"
|
||||
label="转为图片"
|
||||
@click="dataUrlToImg"
|
||||
v-show="imagebtn"
|
||||
dense
|
||||
size="sm"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
icon="content_paste"
|
||||
@click="copyResult"
|
||||
@ -14,13 +19,7 @@
|
||||
<q-btn icon="send" size="sm" @click="sendResult" v-show="textbtn" dense
|
||||
><q-tooltip v-if="!dense">发送到活动窗口</q-tooltip></q-btn
|
||||
>
|
||||
<q-btn
|
||||
icon="close"
|
||||
v-close-popup
|
||||
v-show="closebtn"
|
||||
dense
|
||||
size="sm"
|
||||
/>
|
||||
<q-btn icon="close" v-close-popup v-show="closebtn" dense size="sm" />
|
||||
</q-btn-group>
|
||||
</template>
|
||||
|
||||
|
@ -9,6 +9,7 @@ import { controlCommands } from "./controlCommands";
|
||||
import { uiCommands } from "./uiCommands";
|
||||
import { codingCommands } from "./codingCommand";
|
||||
import { mathCommands } from "./mathCommands";
|
||||
import { userdataCommands } from "./userdataCommands";
|
||||
|
||||
export const commandCategories = [
|
||||
fileCommands,
|
||||
@ -21,5 +22,6 @@ export const commandCategories = [
|
||||
uiCommands,
|
||||
simulateCommands,
|
||||
mathCommands,
|
||||
userdataCommands,
|
||||
otherCommands,
|
||||
];
|
||||
|
@ -18,10 +18,30 @@ export const systemCommands = {
|
||||
{
|
||||
value: "electron.clipboard.readText",
|
||||
label: "获取剪贴板内容",
|
||||
config: [],
|
||||
outputVariable: "clipboardText",
|
||||
outputVariable: "clipboardContent",
|
||||
saveOutput: true,
|
||||
allowEmptyArgv: true,
|
||||
functionSelector: [
|
||||
{
|
||||
value: "electron.clipboard.readText",
|
||||
label: "剪贴板文本",
|
||||
icon: "content_copy",
|
||||
},
|
||||
{
|
||||
value: "quickcommand.readClipboardImage",
|
||||
label: "剪贴板图片",
|
||||
icon: "image",
|
||||
},
|
||||
{
|
||||
value: "electron.clipboard.readRTF",
|
||||
label: "剪贴板RTF",
|
||||
icon: "text_snippet",
|
||||
},
|
||||
{
|
||||
value: "electron.clipboard.readHTML",
|
||||
label: "剪贴板HTML",
|
||||
icon: "web",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "quickcomposer.system.exec",
|
||||
|
@ -13,7 +13,7 @@ export const uiCommands = {
|
||||
saveOutput: true,
|
||||
config: [
|
||||
{
|
||||
label: "按钮组",
|
||||
label: "按钮",
|
||||
type: "arrayEditor",
|
||||
defaultValue: [
|
||||
newVarInputVal("str", "是"),
|
||||
@ -55,7 +55,7 @@ export const uiCommands = {
|
||||
{
|
||||
label: "标题",
|
||||
type: "varInput",
|
||||
defaultValue: newVarInputVal("str", "请选择"),
|
||||
defaultValue: newVarInputVal("str"),
|
||||
width: 12,
|
||||
},
|
||||
],
|
||||
|
61
src/js/composer/commands/userdataCommands.js
Normal file
61
src/js/composer/commands/userdataCommands.js
Normal file
@ -0,0 +1,61 @@
|
||||
export const userdataCommands = {
|
||||
label: "用户数据",
|
||||
icon: "folder_shared",
|
||||
defaultOpened: false,
|
||||
commands: [
|
||||
{
|
||||
value: "quickcommand.userData.get",
|
||||
label: "获取用户数据",
|
||||
icon: "database",
|
||||
config: [
|
||||
{
|
||||
label: "数据标识",
|
||||
type: "input",
|
||||
},
|
||||
],
|
||||
outputVariable: "userData",
|
||||
saveOutput: true,
|
||||
},
|
||||
{
|
||||
value: "quickcommand.userData.all",
|
||||
label: "获取所有用户数据",
|
||||
icon: "database",
|
||||
outputVariable: "userDatas",
|
||||
saveOutput: true,
|
||||
},
|
||||
{
|
||||
value: "quickcommand.userData.put",
|
||||
label: "设置用户数据",
|
||||
icon: "database",
|
||||
config: [
|
||||
{
|
||||
label: "数据",
|
||||
type: "varInput",
|
||||
width: 7,
|
||||
},
|
||||
{
|
||||
label: "数据标识",
|
||||
type: "input",
|
||||
width: 3,
|
||||
},
|
||||
{
|
||||
label: "不同步",
|
||||
type: "checkbox",
|
||||
defaultValue: true,
|
||||
width: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "quickcommand.userData.del",
|
||||
label: "删除用户数据",
|
||||
icon: "database",
|
||||
config: [
|
||||
{
|
||||
label: "数据标识",
|
||||
type: "input",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user