From f22720926dbdb7c56accf8173f16e580ff961a90 Mon Sep 17 00:00:00 2001 From: fofolee Date: Thu, 7 Apr 2022 21:36:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=B0=83=E6=95=B4=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MonocaEditor.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/MonocaEditor.vue b/src/components/MonocaEditor.vue index de828f8..0db8cc1 100644 --- a/src/components/MonocaEditor.vue +++ b/src/components/MonocaEditor.vue @@ -30,6 +30,14 @@ export default { rawEditor() { return toRaw(this.editor); }, + isDark() { + return this.$q.dark.isActive; + }, + }, + watch: { + isDark() { + this.setEditorTheme(); + }, }, methods: { initEditor() { @@ -44,13 +52,13 @@ export default { enabled: false, }, }; - if (this.$q.dark.isActive) monacoEditorPreferences.theme = "vs-dark"; this.editor = monaco.editor.create( document.getElementById("monocaEditor"), monacoEditorPreferences ); this.loadTypes(); this.registerLanguage(); + this.setEditorTheme(); }, loadTypes() { monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({ @@ -139,6 +147,9 @@ export default { }); }); }, + setEditorTheme() { + monaco.editor.setTheme(this.isDark ? "vs-dark" : "vs"); + }, getEditorValue() { return this.rawEditor.getValue(); },