完善标签等功能

This commit is contained in:
fofolee 2022-04-06 01:19:11 +08:00
parent cf2dcd1c21
commit 5d630b5c1f
6 changed files with 120 additions and 20 deletions

View File

@ -2,7 +2,7 @@ import {
boot boot
} from 'quasar/wrappers' } from 'quasar/wrappers'
import UTOOLS from "../js/utools.js"; import UTOOLS from "../js/utools.js";
import programmings from '../js/programs.js'; import programmings from '../js/options/programs.js';
// 配置数据存取 // 配置数据存取
let defaultProfile = { let defaultProfile = {

View File

@ -207,7 +207,7 @@
</template> </template>
<script> <script>
import commandTypes from "../js/commandTypes.js"; import commandTypes from "../js/options/commandTypes.js";
export default { export default {
data() { data() {

View File

@ -88,7 +88,9 @@
standout="bg-primary text-white" standout="bg-primary text-white"
square square
v-model="cmdMatch" v-model="cmdMatch"
:readonly="cmdType.inputType === 'null'" hide-bottom-space
@blur="cmdMatchVerify"
:readonly="cmdType.valueType === 'null'"
type="text" type="text"
:label="cmdType.matchLabel" :label="cmdType.matchLabel"
> >
@ -97,32 +99,62 @@
</template> </template>
</q-input> </q-input>
<!-- 标签 --> <!-- 标签 -->
<q-input <q-select
standout="bg-primary text-white" standout="bg-primary text-white"
square square
v-model="quickcommandInfo.tags" v-model="quickcommandInfo.tags"
type="text" type="text"
label="标签" label="标签"
use-input
use-chips
multiple
new-value-mode="add-unique"
input-debounce="0"
:options="allQuickCommandTags"
/> />
<q-input <!-- 特殊变量 -->
<q-select
standout="bg-primary text-white" standout="bg-primary text-white"
square square
type="text" label="特殊变量"
label="变量"
/> />
<q-input <!-- 输出 -->
<q-select
standout="bg-primary text-white" standout="bg-primary text-white"
square square
type="text" options-dense
color="primary"
v-model="quickcommandInfo.output"
:display-value="outputTypes[quickcommandInfo.output].label"
:options="outputTypesOptions"
label="输出" label="输出"
/> >
<q-input <template v-slot:prepend>
<q-icon :name="outputTypes[quickcommandInfo.output].icon" />
</template>
<template v-slot:option="scope">
<q-item v-bind="scope.itemProps">
<q-item-section avatar>
<q-icon :name="outputTypes[scope.opt].icon" />
</q-item-section>
<q-item-section>
<q-item-label v-html="outputTypes[scope.opt].label" />
</q-item-section>
</q-item> </template
></q-select>
<!-- 平台 -->
<q-select
standout="bg-primary text-white" standout="bg-primary text-white"
square square
:options="['win32', 'darwin', 'linux']"
use-chips
@blur="platformVerify()"
v-model="quickcommandInfo.features.platform" v-model="quickcommandInfo.features.platform"
type="text" multiple
options-dense
label="平台" label="平台"
/> ><template v-slot:prepend> <q-icon name="window" /> </template
></q-select>
</div> </div>
</div> </div>
</div> </div>
@ -178,7 +210,7 @@
stack-label stack-label
hide-bottom-space hide-bottom-space
color="primary" color="primary"
input-style="width: 120px;" input-style="width: 60px;"
v-model="quickcommandInfo.scptarg" v-model="quickcommandInfo.scptarg"
label="脚本参数" label="脚本参数"
v-show="quickcommandInfo.program !== 'quickcommand'" v-show="quickcommandInfo.program !== 'quickcommand'"
@ -200,7 +232,7 @@
icon="code" icon="code"
@click="showCustomOptions" @click="showCustomOptions"
v-show="quickcommandInfo.program !== 'quickcommand'" v-show="quickcommandInfo.program !== 'quickcommand'"
><q-tooltip>其他编程语言或自定义解释器路径</q-tooltip></q-btn ><q-tooltip>自定义解释器路径</q-tooltip></q-btn
> >
<q-btn <q-btn
flat flat
@ -267,14 +299,15 @@
<script> <script>
import MonocaEditor from "components/MonocaEditor"; import MonocaEditor from "components/MonocaEditor";
import commandTypes from "../js/commandTypes.js"; import commandTypes from "../js/options/commandTypes.js";
import outputTypes from "../js/options/outputTypes.js";
let commandTypesOptions = Object.values(commandTypes); 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),
currentMatchType: "关键字", currentMatchType: "关键字",
sideBarWidth: "240px", sideBarWidth: "240px",
@ -283,6 +316,9 @@ export default {
commandTypesOptions: commandTypesOptions, commandTypesOptions: commandTypesOptions,
cmdType: commandTypesOptions[0], cmdType: commandTypesOptions[0],
cmdMatch: "", cmdMatch: "",
outputTypes: outputTypes,
outputTypesOptions: Object.keys(outputTypes),
specilaVar: "{{input}}",
quickcommandInfo: { quickcommandInfo: {
features: { features: {
explain: "", explain: "",
@ -290,7 +326,7 @@ export default {
}, },
program: "quickcommand", program: "quickcommand",
cmd: "", cmd: "",
output: "", output: "text",
hasSubInput: false, hasSubInput: false,
scptarg: "", scptarg: "",
charset: { charset: {
@ -311,6 +347,7 @@ export default {
showSidebar: this.action.type !== "run", showSidebar: this.action.type !== "run",
isRunCodePage: this.action.type === "run", isRunCodePage: this.action.type === "run",
commandString: this.$q.platform.is.mac ? "⌘" : "ctrl", commandString: this.$q.platform.is.mac ? "⌘" : "ctrl",
configurationPage: this.$parent.$parent.$parent.$parent,
}; };
}, },
props: { props: {
@ -326,6 +363,11 @@ export default {
currentProgramLogo() { currentProgramLogo() {
return "/logo/" + this.quickcommandInfo.program + ".png"; return "/logo/" + this.quickcommandInfo.program + ".png";
}, },
allQuickCommandTags() {
return this.configurationPage.allQuickCommandTags.filter(
(x) => x !== "默认" && x !== "未分类" && x !== "搜索结果"
);
},
}, },
created() {}, created() {},
methods: { methods: {
@ -336,7 +378,10 @@ export default {
this.action.type === "edit" this.action.type === "edit"
? 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,
JSON.parse(JSON.stringify(quickCommandInfo))
);
// //
let currentQuickCommandCmds = this.getCommandType(); let currentQuickCommandCmds = this.getCommandType();
// Object // Object
@ -427,7 +472,7 @@ export default {
this.quickcommandInfo.customOptions?.ext, this.quickcommandInfo.customOptions?.ext,
], ],
}, },
"其他编程语言或自定义解释器路径" "自定义解释器路径"
) )
.then((res) => { .then((res) => {
if (res) if (res)
@ -541,6 +586,17 @@ export default {
} }
return data; return data;
}, },
//
cmdMatchVerify() {
this.cmdType.valueType === "regex" &&
!/^\/.*?\/[igm]*$/.test(this.cmdMatch) &&
(this.cmdMatch = `/${this.cmdMatch}/`);
},
//
platformVerify() {
this.quickcommandInfo.features.platform > 0 ||
this.quickcommandInfo.features.platform.push(window.processPlatform);
},
}, },
}; };
</script> </script>

View File

@ -0,0 +1,44 @@
const outputTypes = {
ignore: {
name: "ignore",
label: "忽略输出并隐藏",
icon: "more_horiz"
},
nothing: {
name: "nothing",
label: "忽略输出且不隐藏",
icon: "blur_linear"
},
text: {
name: "text",
label: "纯文本输出",
icon: "text_snippet"
},
html: {
name: "html",
label: "html格式输出",
icon: "html"
},
terminal: {
name: "terminal",
label: "在终端显示",
icon: "terminal"
},
clip: {
name: "clip",
label: "复制到剪贴板",
icon: "content_paste"
},
send: {
name: "send",
label: "发送到活动窗口",
icon: "web_asset"
},
notice: {
name: "notice",
label: "发送系统通知",
icon: "sms"
},
};
export default outputTypes