优化输入框推送功能

This commit is contained in:
fofolee 2023-08-07 20:24:44 +08:00
parent 7fb35e7c2f
commit 62a9bb01d1
4 changed files with 51 additions and 24 deletions

View File

@ -32,6 +32,8 @@ let isProcessExits = pid => {
} }
} }
window.isAppVersion4 = () => utools.getAppVersion() >= "4.0.0";
// 多开检测 // 多开检测
window.multiProcessDetection = () => { window.multiProcessDetection = () => {
let pids = JSON.parse(localStorage.getItem('processes')) || []; let pids = JSON.parse(localStorage.getItem('processes')) || [];

View File

@ -62,6 +62,7 @@ export default defineComponent({
this.utools.whole.onPluginEnter((enter) => { this.utools.whole.onPluginEnter((enter) => {
this.enterPlugin(enter); this.enterPlugin(enter);
}); });
window.isAppVersion4() &&
this.utools.whole.onMainPush( this.utools.whole.onMainPush(
async ({ code, type, payload }) => { async ({ code, type, payload }) => {
let result = await this.runCommand(code, payload, 5000); let result = await this.runCommand(code, payload, 5000);

View File

@ -23,13 +23,37 @@
/> />
</q-avatar> </q-avatar>
<div class="row"> <div class="row">
<div>
<!-- 搜索面板推送 --> <!-- 搜索面板推送 -->
<q-checkbox <q-field
:disable="!canCommandSave"
stack-label
label-color="primary"
borderless
square
type="text"
label="搜索面板推送"
>
<template v-slot:control>
<div class="self-center full-width no-outline" tabindex="0">
{{
currentCommand.features.mainPush
? "主搜索框直接执行"
: "进入插件后执行"
}}
</div>
</template>
<template v-slot:prepend>
<q-icon color="primary" name="troubleshoot" />
</template>
<template v-slot:append>
<q-toggle
v-model="currentCommand.features.mainPush" v-model="currentCommand.features.mainPush"
color="primary" color="primary"
label="搜索面板推送" size="xs"
/> />
<div> </template>
</q-field>
<!-- 说明 --> <!-- 说明 -->
<q-input <q-input
:disable="!canCommandSave" :disable="!canCommandSave"
@ -323,8 +347,8 @@ export default {
computed: { computed: {
commandTypesOptions() { commandTypesOptions() {
return this.currentCommand.features.mainPush return this.currentCommand.features.mainPush
? Object.values(commandTypes).filter( ? Object.values(commandTypes).filter((x) =>
(x) => x.name === "regex" || x.name === "over" ["regex", "over", "key"].includes(x.name)
) )
: Object.values(commandTypes); : Object.values(commandTypes);
}, },

View File

@ -55,7 +55,7 @@ const commandTypes = {
icon: "font_download", icon: "font_download",
color: "primary", color: "primary",
matchLabel: "关键词", matchLabel: "关键词",
desc: "在主输入框输入对应关键字进入插件,最通用的一种模式,关键字可以设置多个", desc: "直接在主输入框输入对应关键字,最通用的一种模式,关键字可以设置多个",
valueType: "array", valueType: "array",
disabledSpecialVars: /{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}|{{MatchedFiles.*?}}/g, disabledSpecialVars: /{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => rules, matchToCmds: (rules, desc) => rules,