MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / setThemeMode

Function setThemeMode

src/controller/setting/setting.ts:9–33  ·  view source on GitHub ↗
(mode: 'dark' | 'light' | 'auto' | string)

Source from the content-addressed store, hash-verified

7 nmConfig.settings.themeMode === 'auto' && setThemeMode(nmConfig.settings.themeMode)
8})
9function setThemeMode(mode: 'dark' | 'light' | 'auto' | string): void {
10 const body = document.body
11 let isDarkMode: boolean = false
12
13 switch (mode) {
14 case 'dark':
15 isDarkMode = true
16 break
17 case 'light':
18 isDarkMode = false
19 break
20 case 'auto':
21 isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
22 break
23 }
24
25 // 根据模式设置页面主题和背景颜色
26 if (isDarkMode) {
27 document.body.setAttribute('arco-theme', 'dark')
28 body.style.backgroundColor = '#2E2E2E'
29 } else {
30 document.body.removeAttribute('arco-theme')
31 body.style.backgroundColor = '#FFFFFF'
32 }
33}
34
35//获取是否启用自启
36async function getAutostartState(): Promise<boolean> {

Callers 3

Setting_pageFunction · 0.90
initFunction · 0.90
setting.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected