mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-10 07:24:37 +08:00
动态调整编辑器主题
This commit is contained in:
parent
70374d75b6
commit
f22720926d
@ -30,6 +30,14 @@ export default {
|
|||||||
rawEditor() {
|
rawEditor() {
|
||||||
return toRaw(this.editor);
|
return toRaw(this.editor);
|
||||||
},
|
},
|
||||||
|
isDark() {
|
||||||
|
return this.$q.dark.isActive;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isDark() {
|
||||||
|
this.setEditorTheme();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initEditor() {
|
initEditor() {
|
||||||
@ -44,13 +52,13 @@ export default {
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (this.$q.dark.isActive) monacoEditorPreferences.theme = "vs-dark";
|
|
||||||
this.editor = monaco.editor.create(
|
this.editor = monaco.editor.create(
|
||||||
document.getElementById("monocaEditor"),
|
document.getElementById("monocaEditor"),
|
||||||
monacoEditorPreferences
|
monacoEditorPreferences
|
||||||
);
|
);
|
||||||
this.loadTypes();
|
this.loadTypes();
|
||||||
this.registerLanguage();
|
this.registerLanguage();
|
||||||
|
this.setEditorTheme();
|
||||||
},
|
},
|
||||||
loadTypes() {
|
loadTypes() {
|
||||||
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
||||||
@ -139,6 +147,9 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setEditorTheme() {
|
||||||
|
monaco.editor.setTheme(this.isDark ? "vs-dark" : "vs");
|
||||||
|
},
|
||||||
getEditorValue() {
|
getEditorValue() {
|
||||||
return this.rawEditor.getValue();
|
return this.rawEditor.getValue();
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user