mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-07-04 15:12:45 +08:00
monoca 添加快捷键
This commit is contained in:
parent
8c5996bc93
commit
261aafacce
@ -125,8 +125,7 @@
|
|||||||
icon="play_arrow"
|
icon="play_arrow"
|
||||||
label="运行"
|
label="运行"
|
||||||
@click="runCurrentCommand()"
|
@click="runCurrentCommand()"
|
||||||
><q-tooltip>{{ commandString }}+b</q-tooltip></q-btn
|
></q-btn>
|
||||||
>
|
|
||||||
<q-btn
|
<q-btn
|
||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
@ -136,8 +135,7 @@
|
|||||||
icon="save"
|
icon="save"
|
||||||
label="保存"
|
label="保存"
|
||||||
@click="saveCurrentCommand()"
|
@click="saveCurrentCommand()"
|
||||||
><q-tooltip>{{ commandString }}+s</q-tooltip></q-btn
|
></q-btn>
|
||||||
>
|
|
||||||
</q-btn-group>
|
</q-btn-group>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -186,7 +184,6 @@ export default {
|
|||||||
resultMaxLength: 10000,
|
resultMaxLength: 10000,
|
||||||
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",
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -213,7 +210,6 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
window.commandEditor = this;
|
window.commandEditor = this;
|
||||||
this.bindKeys();
|
|
||||||
let quickCommandInfo =
|
let quickCommandInfo =
|
||||||
this.action.type === "run"
|
this.action.type === "run"
|
||||||
? this.$utools.getDB(this.$utools.DBPRE.CFG + "preferences")
|
? this.$utools.getDB(this.$utools.DBPRE.CFG + "preferences")
|
||||||
@ -230,14 +226,6 @@ export default {
|
|||||||
if (this.action.type === "run")
|
if (this.action.type === "run")
|
||||||
this.$profile.codeHistory = this.quickcommandInfo;
|
this.$profile.codeHistory = this.quickcommandInfo;
|
||||||
},
|
},
|
||||||
// 绑定快捷键
|
|
||||||
bindKeys() {
|
|
||||||
let that = this;
|
|
||||||
// ctrl+b 运行
|
|
||||||
this.$refs.editor.addEditorCommand(2048 | 32, function () {
|
|
||||||
that.runCurrentCommand();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
programChanged(value) {
|
programChanged(value) {
|
||||||
this.setLanguage(value);
|
this.setLanguage(value);
|
||||||
this.$refs.sidebar?.setIcon(value);
|
this.$refs.sidebar?.setIcon(value);
|
||||||
@ -339,7 +327,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 保存
|
// 保存
|
||||||
saveCurrentCommand() {
|
saveCurrentCommand() {
|
||||||
let updatedData = this.$refs.sidebar.SaveMenuData();
|
let updatedData = this.$refs.sidebar?.SaveMenuData();
|
||||||
if (!updatedData) return;
|
if (!updatedData) return;
|
||||||
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
|
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
|
||||||
let newQuickcommandInfo = _.cloneDeep(this.quickcommandInfo);
|
let newQuickcommandInfo = _.cloneDeep(this.quickcommandInfo);
|
||||||
|
@ -21,6 +21,8 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editor: null,
|
editor: null,
|
||||||
|
wordWrap: "off",
|
||||||
|
commandString: this.$q.platform.is.mac ? "⌘" : "ctrl",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -54,6 +56,7 @@ export default {
|
|||||||
this.registerLanguage();
|
this.registerLanguage();
|
||||||
this.setEditorTheme();
|
this.setEditorTheme();
|
||||||
this.listenEditroValue();
|
this.listenEditroValue();
|
||||||
|
this.bindKeys();
|
||||||
},
|
},
|
||||||
loadTypes() {
|
loadTypes() {
|
||||||
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
||||||
@ -154,9 +157,6 @@ export default {
|
|||||||
setEditorLanguage(language) {
|
setEditorLanguage(language) {
|
||||||
monaco.editor.setModelLanguage(this.rawEditor.getModel(), language);
|
monaco.editor.setModelLanguage(this.rawEditor.getModel(), language);
|
||||||
},
|
},
|
||||||
addEditorCommand(key, callback) {
|
|
||||||
this.rawEditor.addCommand(key, callback);
|
|
||||||
},
|
|
||||||
repacleEditorSelection(text) {
|
repacleEditorSelection(text) {
|
||||||
var selection = this.rawEditor.getSelection();
|
var selection = this.rawEditor.getSelection();
|
||||||
var range = new monaco.Range(
|
var range = new monaco.Range(
|
||||||
@ -182,6 +182,28 @@ export default {
|
|||||||
this.$parent.quickcommandInfo.cmd = this.getEditorValue();
|
this.$parent.quickcommandInfo.cmd = this.getEditorValue();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
bindKeys() {
|
||||||
|
let that = this;
|
||||||
|
// ctrl + b 运行
|
||||||
|
this.rawEditor.addCommand(
|
||||||
|
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyB,
|
||||||
|
() => {
|
||||||
|
that.$parent.runCurrentCommand();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// alt + z 换行
|
||||||
|
this.rawEditor.addCommand(monaco.KeyMod.Alt | monaco.KeyCode.KeyZ, () => {
|
||||||
|
that.wordWrap = that.wordWrap === "off" ? "on" : "off";
|
||||||
|
that.rawEditor.updateOptions({ wordWrap: that.wordWrap });
|
||||||
|
});
|
||||||
|
// ctrl + s 保存
|
||||||
|
this.rawEditor.addCommand(
|
||||||
|
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS,
|
||||||
|
() => {
|
||||||
|
that.$parent.saveCurrentCommand();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user