Skip to content

Commit e690478

Browse files
committed
refactor: reduce redundant code
1 parent 9e9762c commit e690478

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/hooks/useAutoThemeSwitcher.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import type { AppStore } from '@/stores/modules/app'
33
export default function useAutoThemeSwitcher(appStore: AppStore) {
44
const handleAttributeChange = () => {
55
const rootElement = document.documentElement
6-
if (rootElement.classList.contains('dark'))
7-
appStore.switchMode('dark')
8-
else
9-
appStore.switchMode('light')
6+
const mode = rootElement.classList.contains('dark') ? 'dark' : 'light'
7+
appStore.switchMode(mode)
108
}
119

1210
const observerOptions = {

0 commit comments

Comments
 (0)