Compare commits

...

2 Commits

Author SHA1 Message Date
Wei_佳
671504bb33 Merge branch 'release'
* release:
  refactor: 使用自定义useAppDark替代vueuse的useDark
2025-11-19 16:36:33 +08:00
Wei_佳
2ec91a6085 refactor: 使用自定义useAppDark替代vueuse的useDark
将ThemeMode组件和app store中的useDark替换为自定义的useAppDark composable,统一暗色模式管理逻辑
2025-11-18 15:17:55 +08:00
3 changed files with 19 additions and 4 deletions

View 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)
}

View File

@ -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)()

View File

@ -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 {