mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-13 09:34:10 +08:00
编辑、新建命令功能
This commit is contained in:
parent
40d7248b79
commit
10de5052c6
@ -276,17 +276,11 @@ export default {
|
|||||||
},
|
},
|
||||||
// 编辑命令
|
// 编辑命令
|
||||||
editCommand() {
|
editCommand() {
|
||||||
let routeData = {
|
let event = {
|
||||||
from: "configuration",
|
type: "edit",
|
||||||
action: "edit",
|
data: this.commandInfo.features.code,
|
||||||
data: this.commandInfo,
|
|
||||||
};
|
};
|
||||||
this.$router.push({
|
this.$emit("commandChanged", event);
|
||||||
name: "code",
|
|
||||||
params: {
|
|
||||||
data: JSON.stringify(routeData),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
// 运行命令
|
// 运行命令
|
||||||
runCommand() {
|
runCommand() {
|
||||||
@ -297,33 +291,21 @@ export default {
|
|||||||
// 启用/禁用命令
|
// 启用/禁用命令
|
||||||
toggleCommandActivated() {
|
toggleCommandActivated() {
|
||||||
let event = {
|
let event = {
|
||||||
type: "disable",
|
|
||||||
data: this.commandInfo.features.code,
|
data: this.commandInfo.features.code,
|
||||||
};
|
};
|
||||||
if (!this.$utools.whole.removeFeature(this.commandInfo.features.code)) {
|
event.type = this.isCommandActivated ? "enable" : "disable";
|
||||||
this.$utools.whole.setFeature(
|
|
||||||
JSON.parse(JSON.stringify(this.commandInfo.features))
|
|
||||||
);
|
|
||||||
event.type = "enable";
|
|
||||||
}
|
|
||||||
this.$emit("commandChanged", event);
|
this.$emit("commandChanged", event);
|
||||||
},
|
},
|
||||||
// 移除命令
|
// 移除命令
|
||||||
removeCommand() {
|
removeCommand() {
|
||||||
quickcommand.showConfirmBox("删除这个快捷命令").then((x) => {
|
quickcommand.showConfirmBox("删除这个快捷命令").then((x) => {
|
||||||
if (!x) return;
|
if (!x) return;
|
||||||
let code = this.commandInfo.features.code;
|
|
||||||
utools.copyText(JSON.stringify(this.commandInfo, null, 4));
|
|
||||||
this.$utools.delDB(this.$utools.DBPRE.QC + code);
|
|
||||||
this.$utools.whole.removeFeature(code);
|
|
||||||
this.isCommandAlive = false;
|
this.isCommandAlive = false;
|
||||||
|
let code = this.commandInfo.features.code;
|
||||||
this.$emit("commandChanged", {
|
this.$emit("commandChanged", {
|
||||||
type: "remove",
|
type: "remove",
|
||||||
data: code,
|
data: code,
|
||||||
});
|
});
|
||||||
quickcommand.showMessageBox(
|
|
||||||
"删除成功,为防止误操作,已将删除的命令复制到剪贴板"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 导出到剪贴板
|
// 导出到剪贴板
|
||||||
|
@ -1,8 +1,195 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md relative">
|
||||||
<div class="row q-gutter-sm">
|
<!-- 匹配类型 -->
|
||||||
<div class="col-3">
|
<div class="row q-gutter-sm q-py-xs" v-if="notRunCodePage">
|
||||||
<div style="max-width: 300px">
|
<div class="col">
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
color="teal"
|
||||||
|
transition-show="jump-down"
|
||||||
|
transition-hide="jump-up"
|
||||||
|
label-color="teal"
|
||||||
|
v-model="currentMatchType"
|
||||||
|
:options="matchTypes"
|
||||||
|
label="匹配类型"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-avatar rounded>
|
||||||
|
<img :src="'/logo/' + quickcommandInfo.program + '.png'" />
|
||||||
|
</q-avatar>
|
||||||
|
</template>
|
||||||
|
<template v-slot:option="scope">
|
||||||
|
<q-item v-bind="scope.itemProps">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<img width="32" :src="'/logo/' + scope.opt + '.png'" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label v-html="scope.opt" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
color="teal"
|
||||||
|
transition-show="jump-down"
|
||||||
|
transition-hide="jump-up"
|
||||||
|
label-color="teal"
|
||||||
|
v-model="quickcommandInfo.program"
|
||||||
|
:options="programLanguages"
|
||||||
|
label="匹配规则"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-avatar rounded>
|
||||||
|
<img :src="'/logo/' + quickcommandInfo.program + '.png'" />
|
||||||
|
</q-avatar>
|
||||||
|
</template>
|
||||||
|
<template v-slot:option="scope">
|
||||||
|
<q-item v-bind="scope.itemProps">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<img width="32" :src="'/logo/' + scope.opt + '.png'" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label v-html="scope.opt" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- 说明、图标及标签 -->
|
||||||
|
<div class="row q-gutter-sm q-py-xs" v-if="notRunCodePage">
|
||||||
|
<div class="col-auto">
|
||||||
|
<q-img width="40px" src="/logo/quickcommand.png"></q-img>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
color="teal"
|
||||||
|
transition-show="jump-down"
|
||||||
|
transition-hide="jump-up"
|
||||||
|
label-color="teal"
|
||||||
|
v-model="currentMatchType"
|
||||||
|
:options="matchTypes"
|
||||||
|
label="说明"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-avatar rounded>
|
||||||
|
<img :src="'/logo/' + quickcommandInfo.program + '.png'" />
|
||||||
|
</q-avatar>
|
||||||
|
</template>
|
||||||
|
<template v-slot:option="scope">
|
||||||
|
<q-item v-bind="scope.itemProps">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<img width="32" :src="'/logo/' + scope.opt + '.png'" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label v-html="scope.opt" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
color="teal"
|
||||||
|
transition-show="jump-down"
|
||||||
|
transition-hide="jump-up"
|
||||||
|
label-color="teal"
|
||||||
|
v-model="quickcommandInfo.program"
|
||||||
|
:options="programLanguages"
|
||||||
|
label="标签"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-avatar rounded>
|
||||||
|
<img :src="'/logo/' + quickcommandInfo.program + '.png'" />
|
||||||
|
</q-avatar>
|
||||||
|
</template>
|
||||||
|
<template v-slot:option="scope">
|
||||||
|
<q-item v-bind="scope.itemProps">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<img width="32" :src="'/logo/' + scope.opt + '.png'" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label v-html="scope.opt" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- 特殊变量、输出 -->
|
||||||
|
<div class="row q-gutter-sm q-py-xs" v-if="notRunCodePage">
|
||||||
|
<div class="col">
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
color="teal"
|
||||||
|
transition-show="jump-down"
|
||||||
|
transition-hide="jump-up"
|
||||||
|
label-color="teal"
|
||||||
|
v-model="currentMatchType"
|
||||||
|
:options="matchTypes"
|
||||||
|
label="变量"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-avatar rounded>
|
||||||
|
<img :src="'/logo/' + quickcommandInfo.program + '.png'" />
|
||||||
|
</q-avatar>
|
||||||
|
</template>
|
||||||
|
<template v-slot:option="scope">
|
||||||
|
<q-item v-bind="scope.itemProps">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<img width="32" :src="'/logo/' + scope.opt + '.png'" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label v-html="scope.opt" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
color="teal"
|
||||||
|
transition-show="jump-down"
|
||||||
|
transition-hide="jump-up"
|
||||||
|
label-color="teal"
|
||||||
|
v-model="quickcommandInfo.program"
|
||||||
|
:options="programLanguages"
|
||||||
|
label="输出"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-avatar rounded>
|
||||||
|
<img :src="'/logo/' + quickcommandInfo.program + '.png'" />
|
||||||
|
</q-avatar>
|
||||||
|
</template>
|
||||||
|
<template v-slot:option="scope">
|
||||||
|
<q-item v-bind="scope.itemProps">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<img width="32" :src="'/logo/' + scope.opt + '.png'" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label v-html="scope.opt" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- 编程语言 -->
|
||||||
|
<div class="row q-gutter-sm q-py-xs">
|
||||||
|
<div class="col">
|
||||||
|
<div>
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
@ -10,8 +197,9 @@
|
|||||||
transition-show="jump-down"
|
transition-show="jump-down"
|
||||||
transition-hide="jump-up"
|
transition-hide="jump-up"
|
||||||
label-color="teal"
|
label-color="teal"
|
||||||
|
@update:model-value="programChanged"
|
||||||
v-model="quickcommandInfo.program"
|
v-model="quickcommandInfo.program"
|
||||||
:options="options"
|
:options="programLanguages"
|
||||||
label="编程语言"
|
label="编程语言"
|
||||||
>
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
@ -32,8 +220,9 @@
|
|||||||
</q-select>
|
</q-select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col-auto">
|
||||||
<div
|
<div
|
||||||
|
style="max-width: 300px"
|
||||||
class="row q-gutter-sm"
|
class="row q-gutter-sm"
|
||||||
v-show="quickcommandInfo.program === 'custom'"
|
v-show="quickcommandInfo.program === 'custom'"
|
||||||
>
|
>
|
||||||
@ -109,20 +298,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<MonocaEditor
|
||||||
<MonocaEditor
|
class="absolute"
|
||||||
ref="editor"
|
ref="editor"
|
||||||
style="
|
:style="{
|
||||||
position: fixed;
|
bottom: '2px',
|
||||||
bottom: 2px;
|
left: '2px',
|
||||||
left: 2px;
|
right: '2px',
|
||||||
right: 2px;
|
top: this.action.type === 'run' ? '70px' : '250px',
|
||||||
top: 70px;
|
borderRadius: '4px',
|
||||||
border-radius: 4px;
|
border: '1px solid #8080808c',
|
||||||
border: 1px solid #8080808c;
|
}"
|
||||||
"
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<q-dialog v-model="isResultShow" @hide="runResult = ''" position="bottom">
|
<q-dialog v-model="isResultShow" @hide="runResult = ''" position="bottom">
|
||||||
<q-card style="width: 90vh">
|
<q-card style="width: 90vh">
|
||||||
<q-toolbar>
|
<q-toolbar>
|
||||||
@ -158,7 +345,9 @@ export default {
|
|||||||
components: { MonocaEditor },
|
components: { MonocaEditor },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
options: Object.keys(this.$programmings),
|
programLanguages: Object.keys(this.$programmings),
|
||||||
|
matchTypes: ["关键字", "正则", "窗口", "文件", "专业模式"],
|
||||||
|
currentMatchType: "关键字",
|
||||||
quickcommandInfo: {
|
quickcommandInfo: {
|
||||||
features: {
|
features: {
|
||||||
explain: "",
|
explain: "",
|
||||||
@ -194,25 +383,21 @@ export default {
|
|||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentProgram() {
|
notRunCodePage() {
|
||||||
return this.quickcommandInfo.program;
|
return this.action.type !== "run";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
watch: {
|
|
||||||
currentProgram(val) {
|
|
||||||
this.setLanguage(val);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
|
window.commandEditor = this;
|
||||||
this.bindKeys();
|
this.bindKeys();
|
||||||
|
|
||||||
let quickCommandInfo =
|
let quickCommandInfo =
|
||||||
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, quickCommandInfo);
|
||||||
|
this.setLanguage(this.quickcommandInfo.program);
|
||||||
this.$refs.editor.setEditorValue(quickCommandInfo.cmd);
|
this.$refs.editor.setEditorValue(quickCommandInfo.cmd);
|
||||||
// 只有新建或运行时才保存记录
|
// 只有新建或运行时才保存记录
|
||||||
if (this.action.type === "edit") return;
|
if (this.action.type === "edit") return;
|
||||||
@ -233,6 +418,9 @@ export default {
|
|||||||
that.runCurrentCommand();
|
that.runCurrentCommand();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
programChanged(value) {
|
||||||
|
this.setLanguage(value);
|
||||||
|
},
|
||||||
// 匹配编程语言
|
// 匹配编程语言
|
||||||
matchLanguage() {
|
matchLanguage() {
|
||||||
let language = Object.values(this.$programmings).filter(
|
let language = Object.values(this.$programmings).filter(
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="relative">
|
||||||
<!-- 标签栏 -->
|
<!-- 标签栏 -->
|
||||||
<!-- 面板视图不显示标签栏 -->
|
<!-- 面板视图不显示标签栏 -->
|
||||||
<div v-show="commandCardStyle !== 'mini'">
|
<div
|
||||||
<q-tabs
|
v-show="commandCardStyle !== 'mini'"
|
||||||
v-model="currentTag"
|
class="absolute-left"
|
||||||
vertical
|
:style="{
|
||||||
outside-arrows
|
width: tabBarWidth,
|
||||||
:shrink="false"
|
zIndex: 1,
|
||||||
class="text-teal fixed-left"
|
}"
|
||||||
:style="{
|
>
|
||||||
width: tabBarWidth,
|
<q-tabs v-model="currentTag" vertical outside-arrows class="text-teal">
|
||||||
boxShadow: barShadow,
|
|
||||||
zIndex: 1,
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<!-- 所有标签 -->
|
<!-- 所有标签 -->
|
||||||
<q-tab
|
<q-tab
|
||||||
:alert="activatedQuickPanels.includes(tag)"
|
:alert="activatedQuickPanels.includes(tag)"
|
||||||
@ -38,7 +34,7 @@
|
|||||||
<!-- 面板栏 -->
|
<!-- 面板栏 -->
|
||||||
<q-tab-panels
|
<q-tab-panels
|
||||||
animated
|
animated
|
||||||
class="fixed-right"
|
class="absolute-right"
|
||||||
:style="{
|
:style="{
|
||||||
bottom: footerBarHeight,
|
bottom: footerBarHeight,
|
||||||
left: tabBarWidth,
|
left: tabBarWidth,
|
||||||
@ -86,11 +82,10 @@
|
|||||||
</q-tab-panels>
|
</q-tab-panels>
|
||||||
<!-- 底栏 -->
|
<!-- 底栏 -->
|
||||||
<div
|
<div
|
||||||
class="fixed-bottom"
|
class="absolute-bottom"
|
||||||
:style="{
|
:style="{
|
||||||
height: footerBarHeight,
|
height: footerBarHeight,
|
||||||
left: tabBarWidth,
|
left: tabBarWidth,
|
||||||
boxShadow: barShadow,
|
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -278,15 +273,60 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 命令编辑界面 -->
|
||||||
|
<q-dialog
|
||||||
|
v-model="isCommandEditorShow"
|
||||||
|
persistent
|
||||||
|
:maximized="maximizedToggle"
|
||||||
|
transition-show="slide-up"
|
||||||
|
transition-hide="slide-down"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-bar>
|
||||||
|
<q-space />
|
||||||
|
<q-btn
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="minimize"
|
||||||
|
@click="maximizedToggle = false"
|
||||||
|
:disable="!maximizedToggle"
|
||||||
|
>
|
||||||
|
<q-tooltip
|
||||||
|
v-if="maximizedToggle"
|
||||||
|
content-class="bg-white text-primary"
|
||||||
|
>Minimize</q-tooltip
|
||||||
|
>
|
||||||
|
</q-btn>
|
||||||
|
<q-btn
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="crop_square"
|
||||||
|
@click="maximizedToggle = true"
|
||||||
|
:disable="maximizedToggle"
|
||||||
|
>
|
||||||
|
<q-tooltip
|
||||||
|
v-if="!maximizedToggle"
|
||||||
|
content-class="bg-white text-primary"
|
||||||
|
>Maximize</q-tooltip
|
||||||
|
>
|
||||||
|
</q-btn>
|
||||||
|
<q-btn dense flat icon="close" v-close-popup>
|
||||||
|
<q-tooltip content-class="bg-white text-primary">Close</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</q-bar>
|
||||||
|
<CommandEditor :action="commandEditorAction"></CommandEditor>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import quickcommandParser from "../js/quickcommandParser.js";
|
import quickcommandParser from "../js/quickcommandParser.js";
|
||||||
import CommandCard from "components/CommandCard";
|
import CommandCard from "components/CommandCard";
|
||||||
|
import CommandEditor from "components/CommandEditor.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { CommandCard },
|
components: { CommandCard, CommandEditor },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentTag: "默认",
|
currentTag: "默认",
|
||||||
@ -295,8 +335,10 @@ export default {
|
|||||||
activatedQuickPanels: [],
|
activatedQuickPanels: [],
|
||||||
allQuickCommands: [],
|
allQuickCommands: [],
|
||||||
commandSearchKeyword: "",
|
commandSearchKeyword: "",
|
||||||
|
isCommandEditorShow: false,
|
||||||
|
maximizedToggle:true,
|
||||||
|
commandEditorAction: {},
|
||||||
footerBarHeight: "40px",
|
footerBarHeight: "40px",
|
||||||
barShadow: "2px 0 5px 2px #0000001f",
|
|
||||||
commandCardStyle: "normal",
|
commandCardStyle: "normal",
|
||||||
commandCardStyleSheet: {
|
commandCardStyleSheet: {
|
||||||
mini: {
|
mini: {
|
||||||
@ -331,9 +373,7 @@ export default {
|
|||||||
cmd.features.explain.includes(this.commandSearchKeyword)
|
cmd.features.explain.includes(this.commandSearchKeyword)
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return commands.filter(
|
return commands.filter((cmd) => cmd.tags?.includes(this.currentTag));
|
||||||
(cmd) => cmd.tags?.includes(this.currentTag)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 所有命令对应的标签
|
// 所有命令对应的标签
|
||||||
@ -361,7 +401,6 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// 初始化
|
// 初始化
|
||||||
initPage() {
|
initPage() {
|
||||||
console.log(this.$route);
|
|
||||||
window.configuration = this;
|
window.configuration = this;
|
||||||
// 已启用的 features
|
// 已启用的 features
|
||||||
let activatedFeatures = this.getActivatedFeatures();
|
let activatedFeatures = this.getActivatedFeatures();
|
||||||
@ -407,27 +446,57 @@ export default {
|
|||||||
.forEach((x) => (allQcs[x.data.features.code] = x.data));
|
.forEach((x) => (allQcs[x.data.features.code] = x.data));
|
||||||
return allQcs;
|
return allQcs;
|
||||||
},
|
},
|
||||||
// 监听命令变更时间
|
// 监听命令变更事件
|
||||||
commandChanged(event) {
|
commandChanged(event) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "remove":
|
case "remove":
|
||||||
delete this.allQuickCommands[event.data];
|
this.removeCommand(event.data);
|
||||||
if (!this.allQuickCommandTags.includes(this.currentTag))
|
|
||||||
this.currentTag = "默认";
|
|
||||||
return;
|
return;
|
||||||
case "enable":
|
case "enable":
|
||||||
this.activatedQuickCommandFeatureCodes.push(event.data);
|
this.enableCommand(event.data);
|
||||||
return;
|
return;
|
||||||
case "disable":
|
case "disable":
|
||||||
this.activatedQuickCommandFeatureCodes =
|
this.disableCommand(event.data);
|
||||||
this.activatedQuickCommandFeatureCodes.filter(
|
|
||||||
(x) => x !== event.data
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
|
case "edit":
|
||||||
|
this.editCommand(event.data);
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 启用命令
|
||||||
|
enableCommand(code) {
|
||||||
|
this.$utools.whole.setFeature(
|
||||||
|
JSON.parse(JSON.stringify(this.allQuickCommands[code].features))
|
||||||
|
);
|
||||||
|
this.activatedQuickCommandFeatureCodes.push(code);
|
||||||
|
},
|
||||||
|
// 禁用命令
|
||||||
|
disableCommand(code) {
|
||||||
|
this.$utools.whole.removeFeature(code);
|
||||||
|
this.activatedQuickCommandFeatureCodes =
|
||||||
|
this.activatedQuickCommandFeatureCodes.filter((x) => x !== code);
|
||||||
|
},
|
||||||
|
// 删除命令
|
||||||
|
removeCommand(code) {
|
||||||
|
utools.copyText(JSON.stringify(this.allQuickCommands[code], null, 4));
|
||||||
|
delete this.allQuickCommands[code];
|
||||||
|
this.$utools.delDB(this.$utools.DBPRE.QC + code);
|
||||||
|
this.disableCommand(code);
|
||||||
|
if (!this.allQuickCommandTags.includes(this.currentTag))
|
||||||
|
this.currentTag = "默认";
|
||||||
|
quickcommand.showMessageBox(
|
||||||
|
"删除成功,为防止误操作,已将删除的命令复制到剪贴板"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
// 编辑命令
|
||||||
|
editCommand(code) {
|
||||||
|
this.commandEditorAction = {
|
||||||
|
type: "edit",
|
||||||
|
data: this.allQuickCommands[code],
|
||||||
|
};
|
||||||
|
this.isCommandEditorShow = true;
|
||||||
|
},
|
||||||
// 从文件导入命令
|
// 从文件导入命令
|
||||||
importCommandFromFile(file) {
|
importCommandFromFile(file) {
|
||||||
// 指定文件时直接读取否则弹出选择文件对话框
|
// 指定文件时直接读取否则弹出选择文件对话框
|
||||||
@ -596,19 +665,11 @@ export default {
|
|||||||
},
|
},
|
||||||
// 新建命令
|
// 新建命令
|
||||||
addNewCommand() {
|
addNewCommand() {
|
||||||
let routeData = {
|
this.commandEditorAction = {
|
||||||
from: "configuration",
|
type: "new",
|
||||||
action: "new",
|
data: {},
|
||||||
data: {
|
|
||||||
currentTag: this.currentTag,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
this.$router.push({
|
this.isCommandEditorShow = true;
|
||||||
name: "code",
|
|
||||||
params: {
|
|
||||||
data: JSON.stringify(routeData),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user