mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-13 03:15:48 +02:00
wip: force theme #40
This commit is contained in:
parent
42d832cd9f
commit
bc247ffd23
23 changed files with 891 additions and 564 deletions
|
@ -5,17 +5,22 @@ import {useSettingsStore} from '@/pinia'
|
|||
import {dark_mode} from '@/lib/theme'
|
||||
|
||||
let media = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
|
||||
const callback = (media: { matches: any; }) => {
|
||||
const settings = useSettingsStore()
|
||||
if (media.matches) {
|
||||
dark_mode(true)
|
||||
settings.set_theme('dark')
|
||||
} else {
|
||||
dark_mode(false)
|
||||
settings.set_theme('default')
|
||||
if (settings.preference_theme === 'auto') {
|
||||
if (media.matches) {
|
||||
dark_mode(true)
|
||||
settings.set_theme('dark')
|
||||
} else {
|
||||
dark_mode(false)
|
||||
settings.set_theme('auto')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callback(media)
|
||||
|
||||
if (typeof media.addEventListener === 'function') {
|
||||
media.addEventListener('change', callback)
|
||||
} else if (typeof media.addListener === 'function') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue