chore: refactoring
This commit is contained in:
parent
86b3ed348f
commit
c6547d4359
@ -3,7 +3,7 @@
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev": "vite -p 3333 --open",
|
||||
"build": "cross-env NODE_ENV=production vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
|
1
src/store/index.ts
Normal file
1
src/store/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './local'
|
4
src/store/local.ts
Normal file
4
src/store/local.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { Ref } from 'vue'
|
||||
import { useStorage } from '@vueuse/core'
|
||||
|
||||
export const colorSchema = useStorage('vitesse-schema', 'auto') as Ref<'auto' | 'dark' | 'light'>
|
@ -1,18 +1,18 @@
|
||||
import { watch, computed, Ref } from 'vue'
|
||||
import { useStorage, usePreferredDark } from '@vueuse/core'
|
||||
import { watch, computed } from 'vue'
|
||||
import { usePreferredDark } from '@vueuse/core'
|
||||
import { colorSchema } from '../store'
|
||||
|
||||
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'
|
||||
return colorSchema.value === 'auto' ? preferredDark.value : colorSchema.value === 'dark'
|
||||
},
|
||||
set(v: boolean) {
|
||||
if (v === preferredDark.value)
|
||||
schema.value = 'auto'
|
||||
colorSchema.value = 'auto'
|
||||
else
|
||||
schema.value = v ? 'dark' : 'light'
|
||||
colorSchema.value = v ? 'dark' : 'light'
|
||||
},
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user