Merge branch 'main' of https://git.1024tool.vip/zfc/guzhi
This commit is contained in:
commit
c905d2492b
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>
|
<script setup>
|
||||||
import { useAppStore } from '@/store'
|
import { useAppStore } from '@/store'
|
||||||
import { useDark, useToggle } from '@vueuse/core'
|
import { useToggle } from '@vueuse/core'
|
||||||
|
import { useAppDark } from '@/composables/useAppDark'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const isDark = useDark()
|
const isDark = useAppDark()
|
||||||
const toggleDark = () => {
|
const toggleDark = () => {
|
||||||
appStore.toggleDark()
|
appStore.toggleDark()
|
||||||
useToggle(isDark)()
|
useToggle(isDark)()
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { useDark } from '@vueuse/core'
|
|
||||||
import { lStorage } from '@/utils'
|
import { lStorage } from '@/utils'
|
||||||
import i18n from '~/i18n'
|
import i18n from '~/i18n'
|
||||||
|
import { useAppDark } from '@/composables/useAppDark'
|
||||||
|
|
||||||
const currentLocale = lStorage.get('locale')
|
const currentLocale = lStorage.get('locale')
|
||||||
const { locale } = i18n.global
|
const { locale } = i18n.global
|
||||||
|
|
||||||
const isDark = useDark()
|
const isDark = useAppDark()
|
||||||
export const useAppStore = defineStore('app', {
|
export const useAppStore = defineStore('app', {
|
||||||
state() {
|
state() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user