chore: init
This commit is contained in:
commit
76fb0845ec
24 files changed
+4433
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { watch, computed, Ref } from 'vue'
|
||||
import { useStorage, usePreferredDark } from '@vueuse/core'
|
||||
|
||||
const preferredDark = usePreferredDark()
|
||||
const schema = useStorage('vitesse-schema', 'auto') as Ref<'auto' | 'dark' | 'light'>
|
||||
|
||||
export const isDark = computed({
|
||||
get() {
|
||||
return schema.value === 'auto' ? preferredDark.value : schema.value === 'dark'
|
||||
},
|
||||
set(v: boolean) {
|
||||
if (v === preferredDark.value)
|
||||
schema.value = 'auto'
|
||||
else
|
||||
schema.value = v ? 'dark' : 'light'
|
||||
},
|
||||
})
|
||||
|
||||
watch(
|
||||
isDark,
|
||||
(v) => {
|
||||
const html = document.getElementsByTagName('html')[0]
|
||||
html.classList.toggle('schema-dark', v)
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
Reference in new issue
Block a user