完善标签等功能

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
} from 'quasar/wrappers'
import UTOOLS from "../js/utools.js";
import programmings from '../js/programs.js';
import programmings from '../js/options/programs.js';
// 配置数据存取
let defaultProfile = {

View File

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

View File

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

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