Skip to content

Commit 842ff0e

Browse files
committed
优化文档日志暗色主题规则
1 parent ea39853 commit 842ff0e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/views/knowledgeFile/documentLog.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,27 @@
4343
}
4444
});
4545
46-
// 定义主题规则
46+
// 定义亮色主题规则
4747
monaco.editor.defineTheme('customLogTheme', {
4848
base: 'vs',
4949
inherit: true,
5050
rules: [
5151
{ token: 'uuid', foreground: '#808080' }, // 灰色
5252
{ token: 'timestamp', foreground: '#CE9178' }, // 紫色
5353
],
54-
colors: {}
54+
colors: { }
55+
});
56+
// 定义暗色主题规则
57+
monaco.editor.defineTheme('customLogThemeDark', {
58+
base: 'vs-dark',
59+
inherit: true,
60+
rules: [
61+
{ token: 'uuid', foreground: '#808080' }, // 灰色
62+
{ token: 'timestamp', foreground: '#CE9178' }, // 紫色
63+
],
64+
colors: {
65+
'editor.background': '#1f2329'
66+
}
5567
});
5668
}
5769
@@ -97,15 +109,15 @@
97109
const observeThemeChange = () => {
98110
const body = document.body;
99111
observer = new MutationObserver(() => {
100-
const newTheme = body.getAttribute('theme') === 'dark' ? 'vs-dark' : 'vs';
112+
const newTheme = body.getAttribute('theme') === 'dark' ? 'customLogThemeDark' : 'customLogTheme';
101113
monaco.editor.setTheme(newTheme);
102114
});
103115
observer.observe(body, { attributes: true, attributeFilter: ['theme'] });
104116
};
105117
// 设置初始主题
106118
const setInitialTheme = () => {
107119
const body = document.body;
108-
const initialTheme = body.getAttribute('theme') === 'dark' ? 'vs-dark' : 'vs';
120+
const initialTheme = body.getAttribute('theme') === 'dark' ? 'customLogThemeDark' : 'customLogTheme';
109121
monaco.editor.setTheme(initialTheme);
110122
};
111123
// 生命周期钩子

0 commit comments

Comments
 (0)