快捷键调整

This commit is contained in:
fofolee 2022-04-21 10:23:38 +08:00
parent 70321d7df3
commit bb247ee8c8
2 changed files with 27 additions and 11 deletions

View File

@ -221,6 +221,7 @@
:placeholder="true"
ref="editor"
@typing="(val) => (quickcommandInfo.cmd = val)"
@keyStroke="monacoKeyStroke"
:style="{
top: languageBarHeight + 'px',
left: this.action.type === 'run' ? 0 : this.sideBarWidth + 'px',
@ -272,6 +273,7 @@ export default {
resultMaxLength: 10000,
showSidebar: this.action.type !== "run",
isRunCodePage: this.action.type === "run",
listener: null,
};
},
props: {
@ -279,17 +281,9 @@ export default {
},
mounted() {
this.init();
this.$refs.sidebar?.init();
},
beforeUnmount() {
!!this.recording && document.removeEventListener("keyup", this.recording);
if (this.action.type !== "run") return;
let command = _.cloneDeep(this.quickcommandInfo);
command.cursorPosition = this.$refs.editor.getCursorPosition();
this.$root.utools.putDB(
command,
this.$root.utools.DBPRE.CFG + "codeHistory"
);
this.saveCodeHistory();
},
computed: {
configurationPage() {
@ -320,6 +314,7 @@ export default {
if (this.quickcommandInfo.tags?.includes("默认") && !utools.isDev()) {
this.canCommandSave = false;
}
this.$refs.sidebar?.init();
},
programChanged(value) {
this.setLanguage(value);
@ -383,6 +378,27 @@ export default {
command.cmdType = this.$refs.sidebar?.cmdType.name;
this.$refs.result.runCurrentCommand(command);
},
saveCodeHistory() {
if (this.action.type !== "run") return;
let command = _.cloneDeep(this.quickcommandInfo);
command.cursorPosition = this.$refs.editor.getCursorPosition();
this.$root.utools.putDB(
command,
this.$root.utools.DBPRE.CFG + "codeHistory"
);
},
monacoKeyStroke(event) {
switch (event) {
case "run":
this.runCurrentCommand();
break;
case "save":
this.saveCurrentCommand();
break;
default:
break;
}
},
},
};
</script>

View File

@ -217,7 +217,7 @@ export default {
this.rawEditor.addCommand(
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyB,
() => {
that.$parent.runCurrentCommand();
that.$emit("keyStroke", "run");
}
);
// alt + z
@ -229,7 +229,7 @@ export default {
this.rawEditor.addCommand(
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS,
() => {
that.$parent.saveCurrentCommand();
that.$emit("keyStroke", "save");
}
);
},