Compare commits
2 Commits
ebf41d74c8
...
671504bb33
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
671504bb33 | ||
|
|
2ec91a6085 |
14
web1/src/composables/useAppDark.js
Normal file
14
web1/src/composables/useAppDark.js
Normal file
@ -0,0 +1,14 @@
|
||||
import { useDark } from '@vueuse/core'
|
||||
|
||||
const darkOptions = {
|
||||
selector: 'html',
|
||||
attribute: 'class',
|
||||
valueDark: 'dark',
|
||||
valueLight: '',
|
||||
storageKey: 'guzhi-color-scheme',
|
||||
initialValue: 'light',
|
||||
}
|
||||
|
||||
export function useAppDark() {
|
||||
return useDark(darkOptions)
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
<script setup>
|
||||
import { useAppStore } from '@/store'
|
||||
import { useDark, useToggle } from '@vueuse/core'
|
||||
import { useToggle } from '@vueuse/core'
|
||||
import { useAppDark } from '@/composables/useAppDark'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const isDark = useDark()
|
||||
const isDark = useAppDark()
|
||||
const toggleDark = () => {
|
||||
appStore.toggleDark()
|
||||
useToggle(isDark)()
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { useDark } from '@vueuse/core'
|
||||
import { lStorage } from '@/utils'
|
||||
import i18n from '~/i18n'
|
||||
import { useAppDark } from '@/composables/useAppDark'
|
||||
|
||||
const currentLocale = lStorage.get('locale')
|
||||
const { locale } = i18n.global
|
||||
|
||||
const isDark = useDark()
|
||||
const isDark = useAppDark()
|
||||
export const useAppStore = defineStore('app', {
|
||||
state() {
|
||||
return {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user