1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| import { addClass, hasClass, removeClass } from '@/utils/domUtils';
|
| export type CustomColorType = {
| name: string;
| light: string;
| dark: string;
| };
|
| export async function updateDarkTheme(mode: string | null = 'light') {
| const htmlRoot = document.getElementById('htmlRoot');
| if (!htmlRoot) {
| return;
| }
| const hasDarkClass = hasClass(htmlRoot, 'dark');
| if (mode === 'dark') {
| htmlRoot.setAttribute('data-theme', 'dark');
| if (!hasDarkClass) {
| addClass(htmlRoot, 'dark');
| }
| } else {
| htmlRoot.setAttribute('data-theme', 'light');
| if (hasDarkClass) {
| removeClass(htmlRoot, 'dark');
| }
| }
| }
|
|