File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 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
97109const 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// 设置初始主题
106118const 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 // 生命周期钩子
You can’t perform that action at this time.
0 commit comments