Skip to content

Commit

Permalink
feat: 支持跟随系统切换夜间模式
Browse files Browse the repository at this point in the history
  • Loading branch information
pumelotea committed Jun 21, 2022
1 parent 6a60543 commit fc0e500
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/global/config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {ref, watch} from "vue"
import {darkTheme} from "naive-ui"
import {darkTheme,useOsTheme} from "naive-ui"

const isMenuCollapsed = ref(false)
const osTheme = useOsTheme()
const theme = ref(null)
const isDark = ref(false)

const isDarkTheme = ref(false)


watch(isDarkTheme, val => {
if (val) {
theme.value = darkTheme
Expand All @@ -16,7 +18,11 @@ watch(isDarkTheme, val => {
}
})

const isMenuCollapsed = ref(false)
watch(osTheme,val=>{
isDarkTheme.value = val === 'dark'
})

isDarkTheme.value = osTheme.value === 'dark'

export {
isDarkTheme,
Expand Down

0 comments on commit fc0e500

Please sign in to comment.