feat: 集成简易暗黑模式

This commit is contained in:
zclzone
2022-12-18 19:19:42 +08:00
parent dda778fdde
commit 9548a0bfc8
5 changed files with 42 additions and 0 deletions

View File

@@ -20,6 +20,9 @@ import { useCssVar } from '@vueuse/core'
import { kebabCase } from 'lodash-es'
import { setupMessage, setupDialog } from '@/utils'
import { naiveThemeOverrides } from '~/settings'
import { useAppStore } from '@/store'
const appStore = useAppStore()
function setupCssVar() {
const common = naiveThemeOverrides.common
@@ -47,4 +50,12 @@ const NaiveProviderContent = defineComponent({
return h('div')
},
})
watch(
() => appStore.darkMode,
(v) => {
if (v) document.documentElement.classList.add('dark')
else document.documentElement.classList.remove('dark')
}
)
</script>