From ecd0b39e80dbe9bf4648c24c2332ac3f7b6702b1 Mon Sep 17 00:00:00 2001 From: fofolee Date: Sun, 3 Apr 2022 23:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MonocaEditor.vue | 15 ++++++--- src/pages/CodeRunner.vue | 60 ++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/components/MonocaEditor.vue b/src/components/MonocaEditor.vue index 1f14137..11e36a3 100644 --- a/src/components/MonocaEditor.vue +++ b/src/components/MonocaEditor.vue @@ -26,6 +26,11 @@ export default { mounted() { this.initEditor(); }, + computed: { + rawEditor() { + return toRaw(this.editor); + }, + }, methods: { initEditor() { let monacoEditorPreferences = { @@ -80,7 +85,7 @@ export default { }; let createDependencyProposals = (range, keyWords, editor, curWord) => { let keys = []; - let tokens = getTokens(editor.getModel().getValue()); + let tokens = getTokens(toRaw(editor).getModel().getValue()); // 自定义变量、字符串 for (const item of tokens) { if (item != curWord.word) { @@ -135,16 +140,16 @@ export default { }); }, getEditorValue() { - return toRaw(this.editor).getValue(); + return this.rawEditor.getValue(); }, setEditorValue(value) { - toRaw(this.editor).setValue(value); + this.rawEditor.setValue(value); }, setEditorLanguage(language) { - monaco.editor.setModelLanguage(this.editor.getModel(), language); + monaco.editor.setModelLanguage(this.rawEditor.getModel(), language); }, addEditorCommand(key, callback) { - this.editor.addCommand(key, callback); + this.rawEditor.addCommand(key, callback); }, }, }; diff --git a/src/pages/CodeRunner.vue b/src/pages/CodeRunner.vue index 2b59e2c..ecb1857 100644 --- a/src/pages/CodeRunner.vue +++ b/src/pages/CodeRunner.vue @@ -6,9 +6,10 @@ - - - + + 查看文档 + 脚本及输出编码设置 + 运行命令 + @@ -91,12 +111,12 @@ ref="editor" style=" position: fixed; - bottom: 1px; - left: 1px; - right: 1px; + bottom: 2px; + left: 2px; + right: 2px; top: 70px; border-radius: 4px; - border: 2px solid #3376cd; + border: 1px solid #8080808c; " /> @@ -121,7 +141,7 @@ > - +