diff --git a/package.json b/package.json index aa6b9b5..f52be4b 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/store/index.ts b/src/store/index.ts new file mode 100644 index 0000000..87c2c0a --- /dev/null +++ b/src/store/index.ts @@ -0,0 +1 @@ +export * from './local' diff --git a/src/store/local.ts b/src/store/local.ts new file mode 100644 index 0000000..45fe7cb --- /dev/null +++ b/src/store/local.ts @@ -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'> diff --git a/src/utils/dark.ts b/src/utils/dark.ts index 06c9593..413997b 100644 --- a/src/utils/dark.ts +++ b/src/utils/dark.ts @@ -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' }, })