完善保存命令功能

This commit is contained in:
fofolee 2022-04-07 17:30:26 +08:00
parent 827e19b559
commit 9694570dea
4 changed files with 32 additions and 8 deletions

View File

@ -161,7 +161,7 @@ export default {
programLanguages: Object.keys(this.$programmings), programLanguages: Object.keys(this.$programmings),
sideBarWidth: "290px", sideBarWidth: "290px",
languageBarHeight: "40px", languageBarHeight: "40px",
canCommandSave: this.action.type === "edit" ? true : false, canCommandSave: this.action.type === "code" ? false : true,
quickcommandInfo: { quickcommandInfo: {
features: { features: {
explain: "", explain: "",
@ -202,7 +202,7 @@ export default {
}, },
computed: { computed: {
allQuickCommandTags() { allQuickCommandTags() {
return this.parentPage.allQuickCommandTags.filter( return this.parent.allQuickCommandTags.filter(
(x) => x !== "默认" && x !== "未分类" && x !== "搜索结果" (x) => x !== "默认" && x !== "未分类" && x !== "搜索结果"
); );
}, },
@ -407,9 +407,24 @@ export default {
}, },
// //
saveCurrentCommand() { saveCurrentCommand() {
let updatedData = this.$refs.editor.SaveMenuData(); let updatedData = this.$refs.menu.SaveMenuData();
if (!updatedData) return; if (!updatedData) return;
_.merge(this.quickcommandInfo, updatedData); Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
this.$utools.putDB(
_.cloneDeep(this.quickcommandInfo),
this.$utools.DBPRE.QC + this.quickcommandInfo.features.code
);
this.$emit("editorEvent", {
type: "save",
data: _.cloneDeep(this.quickcommandInfo),
});
this.closeEditor();
this.$nextTick(() => {
document
.getElementById(this.quickcommandInfo.features.code)
.querySelector(".q-toggle[aria-checked='false']")
?.click();
});
}, },
}, },
}; };

View File

@ -256,7 +256,12 @@ export default {
outputTypes: outputTypes, outputTypes: outputTypes,
outputTypesOptions: Object.keys(outputTypes), outputTypesOptions: Object.keys(outputTypes),
specialVar: "{{}}", specialVar: "{{}}",
allQuickCommandTags: this.$parent.parent.allQuickCommandTags, allQuickCommandTags: _.without(
this.$parent.parent.allQuickCommandTags,
"默认",
"未分类",
"搜索结果"
),
}; };
}, },
props: { props: {
@ -282,7 +287,7 @@ export default {
this.currentCommand, this.currentCommand,
_.pick(this.quickcommandInfo, "tags", "output", "features") _.pick(this.quickcommandInfo, "tags", "output", "features")
); );
this.setIcon(this.currentCommand.program); this.setIcon(this.quickcommandInfo.program);
this.platformVerify(); this.platformVerify();
}, },
// 使 // 使

View File

@ -96,6 +96,7 @@ const commandTypes = {
icon: "construction", icon: "construction",
desc: "通过json格式的配置实现同时匹配关键字、窗口、文件甚至图片或者指定文件数量、窗口类等", desc: "通过json格式的配置实现同时匹配关键字、窗口、文件甚至图片或者指定文件数量、窗口类等",
valueType: "json", valueType: "json",
disabledSpecialVars: null,
matchToCmds: (rules, desc) => JSON.parse(rules), matchToCmds: (rules, desc) => JSON.parse(rules),
verify: rules => { verify: rules => {
try { try {

View File

@ -422,12 +422,12 @@ export default {
let el = document.getElementById(code); let el = document.getElementById(code);
el.scrollIntoViewIfNeeded(); el.scrollIntoViewIfNeeded();
// //
el.style.filter = "invert(1) drop-shadow(1px 1px 5px #0000008e)"; el.style.filter = "drop-shadow(2px 4px 6px black)";
el.style.transform = "translateY(-5px)"; el.style.transform = "translateY(-5px)";
setTimeout(() => { setTimeout(() => {
el.style.filter = ""; el.style.filter = "";
el.style.transform = ""; el.style.transform = "";
}, 500); }, 800);
}); });
}, },
// //
@ -513,6 +513,9 @@ export default {
case "close": case "close":
this.isCommandEditorShow = false; this.isCommandEditorShow = false;
return; return;
case "save":
this.allQuickCommands[event.data.features.code] = event.data;
this.locateToCommand(event.data.tags, event.data.features.code);
default: default:
return; return;
} }