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