Добавлены настройки темы по умолчанию

This commit is contained in:
Ilia Miheev
2026-06-21 00:36:31 +03:00
parent c9347b8d20
commit 810bf469f9
10 changed files with 51 additions and 29 deletions
+4 -13
View File
@@ -1,7 +1,9 @@
import { ref, computed, onMounted } from 'vue'
import { inject, ref, computed } from 'vue'
import { resolveTheme } from '../config/applyTheme'
export function useTheme() {
const theme = ref('dark')
const config = inject('appConfig')
const theme = ref(resolveTheme(config))
const isLightTheme = computed(() => theme.value === 'light')
@@ -15,16 +17,5 @@ export function useTheme() {
applyTheme(theme.value === 'dark' ? 'light' : 'dark')
}
onMounted(() => {
const saved = localStorage.getItem('theme')
if (saved === 'dark' || saved === 'light') {
applyTheme(saved)
return
}
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
applyTheme(prefersDark ? 'dark' : 'light')
})
return { theme, isLightTheme, toggleTheme }
}