feat: Add foundational UI components, pages, and theme management for the e-learning application.
This commit is contained in:
parent
baf389643b
commit
5fe454df95
12 changed files with 359 additions and 338 deletions
|
|
@ -13,17 +13,7 @@ export const useThemeMode = () => {
|
|||
localStorage.setItem('theme', value ? 'dark' : 'light')
|
||||
}
|
||||
|
||||
const initTheme = () => {
|
||||
if (!process.client) return
|
||||
const saved = localStorage.getItem('theme') // 'dark' | 'light' | null
|
||||
const prefersDark = window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false
|
||||
|
||||
const value = saved ? saved === 'dark' : prefersDark
|
||||
isDark.value = value
|
||||
applyTheme(value)
|
||||
}
|
||||
|
||||
onMounted(initTheme)
|
||||
|
||||
watch(isDark, (v) => applyTheme(v))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue