mirror of
https://github.com/gotson/komga.git
synced 2025-12-23 08:52:45 +01:00
use new syntax for vuetify theme change
This commit is contained in:
parent
37b734d380
commit
19ce6c8a10
1 changed files with 6 additions and 11 deletions
|
|
@ -1,24 +1,19 @@
|
|||
import { useTheme } from 'vuetify'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { usePreferredDark } from '@vueuse/core'
|
||||
|
||||
export function useThemeWatcher() {
|
||||
const appStore = useAppStore()
|
||||
const theme = useTheme()
|
||||
const prefersDark = usePreferredDark()
|
||||
|
||||
function updateTheme(selectedTheme: string, prefersDark: boolean) {
|
||||
if (selectedTheme === 'system') {
|
||||
theme.global.name.value = prefersDark ? 'dark' : 'light'
|
||||
} else {
|
||||
theme.global.name.value = selectedTheme
|
||||
}
|
||||
function updateTheme(selectedTheme: string) {
|
||||
theme.change(selectedTheme)
|
||||
}
|
||||
|
||||
watch([() => appStore.theme, prefersDark], ([selectedTheme, prefersDark]) =>
|
||||
updateTheme(selectedTheme, prefersDark),
|
||||
watch(
|
||||
() => appStore.theme,
|
||||
(selectedTheme) => updateTheme(selectedTheme),
|
||||
)
|
||||
|
||||
// trigger an update on startup to get the proper theme loaded
|
||||
updateTheme(appStore.theme, prefersDark.value)
|
||||
updateTheme(appStore.theme)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue