mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 15:04:06 +08:00
完善匹配类型部分
This commit is contained in:
parent
d28629775d
commit
cf2dcd1c21
@ -79,7 +79,7 @@
|
|||||||
v-ripple
|
v-ripple
|
||||||
:style="{
|
:style="{
|
||||||
color: isCommandActivated ? 'unset' : 'grey',
|
color: isCommandActivated ? 'unset' : 'grey',
|
||||||
background: $q.dark.isActive ? '#ffffff08' : '#00000008'
|
background: $q.dark.isActive ? '#ffffff08' : '#00000008',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
@ -108,9 +108,10 @@
|
|||||||
<span v-for="cmd in commandInfo.features.cmds" :key="cmd">
|
<span v-for="cmd in commandInfo.features.cmds" :key="cmd">
|
||||||
<span v-if="typeof cmd === 'string'">
|
<span v-if="typeof cmd === 'string'">
|
||||||
<q-badge rounded :color="cmdBadgeColor()"
|
<q-badge rounded :color="cmdBadgeColor()"
|
||||||
><q-icon class="q-mr-xs" name="font_download" />{{
|
><q-icon
|
||||||
getShortStrByByte(cmd)
|
class="q-mr-xs"
|
||||||
}}</q-badge
|
:name="commandTypes.keyword.icon"
|
||||||
|
/>{{ getShortStrByByte(cmd) }}</q-badge
|
||||||
>
|
>
|
||||||
<q-tooltip>
|
<q-tooltip>
|
||||||
<div class="text-subtitle2">
|
<div class="text-subtitle2">
|
||||||
@ -120,9 +121,10 @@
|
|||||||
</span>
|
</span>
|
||||||
<span v-else-if="cmd.type === 'window' && cmd.match">
|
<span v-else-if="cmd.type === 'window' && cmd.match">
|
||||||
<q-badge rounded :color="cmdBadgeColor(cmd.type)"
|
<q-badge rounded :color="cmdBadgeColor(cmd.type)"
|
||||||
><q-icon class="q-mr-xs" name="widgets" />{{
|
><q-icon
|
||||||
getShortStrByByte(cmd.match.app[0])
|
class="q-mr-xs"
|
||||||
}}
|
:name="commandTypes.window.icon"
|
||||||
|
/>{{ getShortStrByByte(cmd.match.app[0]) }}
|
||||||
</q-badge>
|
</q-badge>
|
||||||
<q-tooltip>
|
<q-tooltip>
|
||||||
<div
|
<div
|
||||||
@ -136,7 +138,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<span v-else-if="cmd.type === 'files'">
|
<span v-else-if="cmd.type === 'files'">
|
||||||
<q-badge rounded :color="cmdBadgeColor(cmd.type)"
|
<q-badge rounded :color="cmdBadgeColor(cmd.type)"
|
||||||
><q-icon class="q-mr-xs" name="description" />
|
><q-icon class="q-mr-xs" :name="commandTypes.files.icon" />
|
||||||
{{
|
{{
|
||||||
(cmd.match && getShortStrByByte(cmd.match)) || "所有文件"
|
(cmd.match && getShortStrByByte(cmd.match)) || "所有文件"
|
||||||
}}</q-badge
|
}}</q-badge
|
||||||
@ -149,9 +151,10 @@
|
|||||||
</span>
|
</span>
|
||||||
<span v-else-if="cmd.type === 'regex'">
|
<span v-else-if="cmd.type === 'regex'">
|
||||||
<q-badge rounded :color="cmdBadgeColor(cmd.type)"
|
<q-badge rounded :color="cmdBadgeColor(cmd.type)"
|
||||||
><q-icon class="q-mr-xs" name="playlist_add_check" />{{
|
><q-icon
|
||||||
getShortStrByByte(cmd.match)
|
class="q-mr-xs"
|
||||||
}}
|
:name="commandTypes.regex.icon"
|
||||||
|
/>{{ getShortStrByByte(cmd.match) }}
|
||||||
</q-badge>
|
</q-badge>
|
||||||
<q-tooltip>
|
<q-tooltip>
|
||||||
<div class="text-subtitle2">
|
<div class="text-subtitle2">
|
||||||
@ -161,12 +164,15 @@
|
|||||||
</span>
|
</span>
|
||||||
<span v-else-if="cmd.type === 'over'">
|
<span v-else-if="cmd.type === 'over'">
|
||||||
<q-badge rounded :color="cmdBadgeColor(cmd.type)"
|
<q-badge rounded :color="cmdBadgeColor(cmd.type)"
|
||||||
><q-icon class="q-mr-xs" name="clear_all" />所有文本
|
><q-icon
|
||||||
|
class="q-mr-xs"
|
||||||
|
:name="commandTypes.over.icon"
|
||||||
|
/>所有文本
|
||||||
</q-badge>
|
</q-badge>
|
||||||
</span>
|
</span>
|
||||||
<span v-else-if="cmd.type === 'img'">
|
<span v-else-if="cmd.type === 'img'">
|
||||||
<q-badge rounded :color="cmdBadgeColor(cmd.type)" label="">
|
<q-badge rounded :color="cmdBadgeColor(cmd.type)" label="">
|
||||||
<q-icon class="q-mr-xs" name="panorama" />图片
|
<q-icon class="q-mr-xs" :name="commandTypes.img.icon" />图片
|
||||||
</q-badge>
|
</q-badge>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
@ -201,12 +207,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import commandTypes from "../js/commandTypes.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
allProgrammings: this.$programmings,
|
allProgrammings: this.$programmings,
|
||||||
isCommandActivated: this.activated,
|
isCommandActivated: this.activated,
|
||||||
maxCmdStingLen: 8,
|
maxCmdStingLen: 8,
|
||||||
|
commandTypes: commandTypes,
|
||||||
cmdBadgeSheet: {
|
cmdBadgeSheet: {
|
||||||
keyword: "primary",
|
keyword: "primary",
|
||||||
files: "light-blue",
|
files: "light-blue",
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<!-- 命令设置栏 -->
|
<!-- 命令设置栏 -->
|
||||||
<div
|
<q-scroll-area
|
||||||
|
:thumb-style="{
|
||||||
|
width: '3px',
|
||||||
|
}"
|
||||||
class="absolute-left shadow-10"
|
class="absolute-left shadow-10"
|
||||||
:style="{
|
:style="{
|
||||||
width: sideBarWidth,
|
width: sideBarWidth,
|
||||||
@ -11,47 +14,91 @@
|
|||||||
v-if="showSidebar"
|
v-if="showSidebar"
|
||||||
>
|
>
|
||||||
<div class="row q-pa-md q-gutter-md">
|
<div class="row q-pa-md q-gutter-md">
|
||||||
<div class="row">
|
<q-btn
|
||||||
<q-btn
|
dense
|
||||||
dense
|
flat
|
||||||
flat
|
color="grey"
|
||||||
color="grey"
|
icon="arrow_back_ios_new"
|
||||||
icon="arrow_back_ios_new"
|
@click="closeEditor"
|
||||||
@click="closeEditor"
|
/>
|
||||||
/>
|
<q-img class="commandLogo" width="64px" :src="commandIcon" />
|
||||||
<div class="q-pa-md">
|
|
||||||
<q-img class="commandLogo" width="80px" :src="commandIcon" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div>
|
<div>
|
||||||
|
<!-- 说明 -->
|
||||||
<q-input
|
<q-input
|
||||||
standout="bg-primary text-white"
|
standout="bg-primary text-white"
|
||||||
dense
|
|
||||||
square
|
square
|
||||||
v-model="quickcommandInfo.features.explain"
|
v-model="quickcommandInfo.features.explain"
|
||||||
type="text"
|
type="text"
|
||||||
label="说明"
|
label="说明"
|
||||||
/>
|
>
|
||||||
<q-input
|
<template v-slot:prepend>
|
||||||
|
<q-icon name="drive_file_rename_outline" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
<!-- 匹配类型 -->
|
||||||
|
<q-select
|
||||||
standout="bg-primary text-white"
|
standout="bg-primary text-white"
|
||||||
dense
|
|
||||||
square
|
square
|
||||||
v-model="commandType"
|
options-dense
|
||||||
|
@update:model-value="cmdMatch = null"
|
||||||
|
:options="commandTypesOptions"
|
||||||
|
v-model="cmdType"
|
||||||
type="text"
|
type="text"
|
||||||
label="匹配类型"
|
label="匹配类型"
|
||||||
/>
|
>
|
||||||
<q-input
|
<template v-slot:prepend>
|
||||||
|
<q-icon :name="cmdType.icon" />
|
||||||
|
</template>
|
||||||
|
<template v-slot:option="scope">
|
||||||
|
<q-item v-bind="scope.itemProps" v-on="scope.itemEvents">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-icon :name="scope.opt.icon" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label v-html="scope.opt.name" />
|
||||||
|
<q-item-label caption>{{ scope.opt.desc }}</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template></q-select
|
||||||
|
>
|
||||||
|
<!-- 匹配规则 -->
|
||||||
|
<q-select
|
||||||
|
v-if="cmdType.valueType === 'array'"
|
||||||
standout="bg-primary text-white"
|
standout="bg-primary text-white"
|
||||||
dense
|
|
||||||
square
|
square
|
||||||
v-model="quickcommandInfo.features.cmds[0]"
|
v-model="cmdMatch"
|
||||||
|
use-input
|
||||||
|
use-chips
|
||||||
|
multiple
|
||||||
|
hide-dropdown-icon
|
||||||
|
input-debounce="0"
|
||||||
|
new-value-mode="add-unique"
|
||||||
type="text"
|
type="text"
|
||||||
label="关键字"
|
placeholder="回车添加"
|
||||||
/>
|
:label="cmdType.matchLabel"
|
||||||
|
>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<q-icon name="square_foot" />
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
<q-input
|
||||||
|
v-else
|
||||||
|
autogrow
|
||||||
|
standout="bg-primary text-white"
|
||||||
|
square
|
||||||
|
v-model="cmdMatch"
|
||||||
|
:readonly="cmdType.inputType === 'null'"
|
||||||
|
type="text"
|
||||||
|
:label="cmdType.matchLabel"
|
||||||
|
>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<q-icon name="square_foot" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
<!-- 标签 -->
|
||||||
<q-input
|
<q-input
|
||||||
standout="bg-primary text-white"
|
standout="bg-primary text-white"
|
||||||
dense
|
|
||||||
square
|
square
|
||||||
v-model="quickcommandInfo.tags"
|
v-model="quickcommandInfo.tags"
|
||||||
type="text"
|
type="text"
|
||||||
@ -59,21 +106,18 @@
|
|||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
standout="bg-primary text-white"
|
standout="bg-primary text-white"
|
||||||
dense
|
|
||||||
square
|
square
|
||||||
type="text"
|
type="text"
|
||||||
label="变量"
|
label="变量"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
standout="bg-primary text-white"
|
standout="bg-primary text-white"
|
||||||
dense
|
|
||||||
square
|
square
|
||||||
type="text"
|
type="text"
|
||||||
label="输出"
|
label="输出"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
standout="bg-primary text-white"
|
standout="bg-primary text-white"
|
||||||
dense
|
|
||||||
square
|
square
|
||||||
v-model="quickcommandInfo.features.platform"
|
v-model="quickcommandInfo.features.platform"
|
||||||
type="text"
|
type="text"
|
||||||
@ -83,7 +127,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div></div>
|
<div></div>
|
||||||
</div>
|
</q-scroll-area>
|
||||||
<!-- 编程语言栏 -->
|
<!-- 编程语言栏 -->
|
||||||
<div
|
<div
|
||||||
class="absolute-top"
|
class="absolute-top"
|
||||||
@ -131,6 +175,7 @@
|
|||||||
dense
|
dense
|
||||||
standout="bg-primary text-white"
|
standout="bg-primary text-white"
|
||||||
square
|
square
|
||||||
|
stack-label
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
color="primary"
|
color="primary"
|
||||||
input-style="width: 120px;"
|
input-style="width: 120px;"
|
||||||
@ -222,20 +267,25 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MonocaEditor from "components/MonocaEditor";
|
import MonocaEditor from "components/MonocaEditor";
|
||||||
|
import commandTypes from "../js/commandTypes.js";
|
||||||
|
let commandTypesOptions = Object.values(commandTypes);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { MonocaEditor },
|
components: { MonocaEditor },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
reg: "i",
|
||||||
programLanguages: Object.keys(this.$programmings),
|
programLanguages: Object.keys(this.$programmings),
|
||||||
matchTypes: ["关键字", "正则", "窗口", "文件", "专业模式"],
|
|
||||||
currentMatchType: "关键字",
|
currentMatchType: "关键字",
|
||||||
sideBarWidth: "200px",
|
sideBarWidth: "240px",
|
||||||
languageBarHeight: "40px",
|
languageBarHeight: "40px",
|
||||||
|
commandTypes: commandTypes,
|
||||||
|
commandTypesOptions: commandTypesOptions,
|
||||||
|
cmdType: commandTypesOptions[0],
|
||||||
|
cmdMatch: "",
|
||||||
quickcommandInfo: {
|
quickcommandInfo: {
|
||||||
features: {
|
features: {
|
||||||
explain: "",
|
explain: "",
|
||||||
cmds: [],
|
|
||||||
platform: [],
|
platform: [],
|
||||||
},
|
},
|
||||||
program: "quickcommand",
|
program: "quickcommand",
|
||||||
@ -276,10 +326,6 @@ export default {
|
|||||||
currentProgramLogo() {
|
currentProgramLogo() {
|
||||||
return "/logo/" + this.quickcommandInfo.program + ".png";
|
return "/logo/" + this.quickcommandInfo.program + ".png";
|
||||||
},
|
},
|
||||||
commandType() {
|
|
||||||
let cmd = this.quickcommandInfo.features.cmds[0];
|
|
||||||
return typeof cmd === "string" ? "关键字" : cmd?.type;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
methods: {
|
methods: {
|
||||||
@ -291,6 +337,12 @@ export default {
|
|||||||
? this.action.data
|
? this.action.data
|
||||||
: this.$utools.getDB(this.$utools.DBPRE.CFG + "codeHistory");
|
: this.$utools.getDB(this.$utools.DBPRE.CFG + "codeHistory");
|
||||||
Object.assign(this.quickcommandInfo, quickCommandInfo);
|
Object.assign(this.quickcommandInfo, quickCommandInfo);
|
||||||
|
// 获取当前命令的匹配类型及匹配规则
|
||||||
|
let currentQuickCommandCmds = this.getCommandType();
|
||||||
|
// 设置匹配类型下拉框的值(Object)及匹配规则的值
|
||||||
|
this.cmdType = this.commandTypes[currentQuickCommandCmds.type];
|
||||||
|
this.cmdMatch = currentQuickCommandCmds.match;
|
||||||
|
// monoca 相关
|
||||||
this.setLanguage(this.quickcommandInfo.program);
|
this.setLanguage(this.quickcommandInfo.program);
|
||||||
this.$refs.editor.setEditorValue(quickCommandInfo.cmd);
|
this.$refs.editor.setEditorValue(quickCommandInfo.cmd);
|
||||||
// 只有新建或运行时才保存记录
|
// 只有新建或运行时才保存记录
|
||||||
@ -471,6 +523,24 @@ export default {
|
|||||||
},
|
},
|
||||||
// 保存
|
// 保存
|
||||||
saveCurrentCommand() {},
|
saveCurrentCommand() {},
|
||||||
|
// 判断命令类型
|
||||||
|
getCommandType() {
|
||||||
|
let data = {};
|
||||||
|
let cmds = this.quickcommandInfo.features.cmds;
|
||||||
|
if (cmds.length === 1) {
|
||||||
|
let { type, match } = cmds[0];
|
||||||
|
data.type = type ? type : "keyword";
|
||||||
|
data.match =
|
||||||
|
data.type === "keyword" ? cmds[0] : match?.app ? match.app : match;
|
||||||
|
} else {
|
||||||
|
data.type = cmds.filter((x) => !x.length).length
|
||||||
|
? "professional"
|
||||||
|
: "keyword";
|
||||||
|
data.match =
|
||||||
|
data.type === "keyword" ? cmds : JSON.stringify(cmds, null, 4);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
61
src/js/commandTypes.js
Normal file
61
src/js/commandTypes.js
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
const commandTypes = {
|
||||||
|
keyword: {
|
||||||
|
name: "keyword",
|
||||||
|
label: "关键词",
|
||||||
|
icon: "font_download",
|
||||||
|
matchLabel: "关键词",
|
||||||
|
desc: "在主输入框输入对应关键字进入插件,最通用的一种模式,关键字可以设置多个",
|
||||||
|
valueType: "array"
|
||||||
|
},
|
||||||
|
regex: {
|
||||||
|
name: "regex",
|
||||||
|
label: "正则/划词",
|
||||||
|
matchLabel: "正则",
|
||||||
|
icon: "rule",
|
||||||
|
desc: "匹配主输入框或超级面板选中的文本,可以获取输入框文本或选中文本作为变量",
|
||||||
|
valueType: "regex"
|
||||||
|
},
|
||||||
|
over: {
|
||||||
|
name: "over",
|
||||||
|
label: "所有文本",
|
||||||
|
matchLabel: "无需设置",
|
||||||
|
icon: "emergency",
|
||||||
|
desc: "匹配主输入框的所有文本,但只有在该文本未设置对应的插件或功能时才生效",
|
||||||
|
valueType: "null"
|
||||||
|
},
|
||||||
|
window: {
|
||||||
|
name: "window",
|
||||||
|
label: "窗口/进程",
|
||||||
|
matchLabel: "进程名",
|
||||||
|
icon: "widgets",
|
||||||
|
desc: "匹配呼出uTools前或唤出超级面板时的活动窗口,可以获取窗口的信息或文件夹路径作为变量",
|
||||||
|
valueType: "array"
|
||||||
|
},
|
||||||
|
img: {
|
||||||
|
name: "img",
|
||||||
|
label: "图片",
|
||||||
|
matchLabel: "无需配置",
|
||||||
|
icon: "panorama",
|
||||||
|
desc: "匹配主输入框或超级面板选中的图片,并返回图片的 base64",
|
||||||
|
valueType: "null"
|
||||||
|
},
|
||||||
|
files: {
|
||||||
|
name: "files",
|
||||||
|
label: "复制/选中文件",
|
||||||
|
matchLabel: "正则",
|
||||||
|
icon: "description",
|
||||||
|
desc: "匹配主输入框或超级面板选中的文件,可以获取复制及选中的文件信息作为变量",
|
||||||
|
valueType: "regex"
|
||||||
|
|
||||||
|
},
|
||||||
|
professional: {
|
||||||
|
name: "professional",
|
||||||
|
label: "专业模式",
|
||||||
|
matchLabel: "json配置",
|
||||||
|
icon: "construction",
|
||||||
|
desc: "通过json格式的配置实现同时匹配关键字、窗口、文件甚至图片,或者指定文件数量、窗口类等",
|
||||||
|
valueType: "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default commandTypes
|
Loading…
x
Reference in New Issue
Block a user