Skip to content

Commit

Permalink
fix: can set dark mode always, close #355
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Oct 2, 2022
1 parent a4b5328 commit df6ba22
Show file tree
Hide file tree
Showing 5 changed files with 444 additions and 449 deletions.
2 changes: 1 addition & 1 deletion demo/_config.yun.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mode: auto
mode: dark

avatar:
url: https://www.yunyoujun.cn/images/avatar.jpg
Expand Down
6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"dayjs": "^1.11.5"
},
"devDependencies": {
"@vueuse/core": "^9.2.0",
"@vueuse/core": "^9.3.0",
"sass": "^1.55.0",
"unocss": "^0.45.22",
"unocss": "^0.45.26",
"unplugin-vue-components": "^0.22.7",
"vitepress": "1.0.0-alpha.15"
"vitepress": "1.0.0-alpha.18"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
},
"devDependencies": {
"@antfu/eslint-config": "^0.27.0",
"@types/node": "^18.7.18",
"@types/node": "^18.7.23",
"bumpp": "^8.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.23.1",
"eslint": "^8.24.0",
"esno": "~0.16.3",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"tsup": "^6.2.3",
"typescript": "^4.8.3",
"typescript": "^4.8.4",
"zx": "^7.0.8"
},
"lint-staged": {
Expand Down
3 changes: 2 additions & 1 deletion packages/hexo-theme-yun/layout/_partial/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- var copyright = config.copyright || config.author

doctype html
html(lang=config.language)
html(lang=config.language, class=theme.mode === 'dark' ? 'dark' : '')
head
meta(charset='UTF-8')
meta(http-equiv="X-UA-Compatible" content="IE=edge")
Expand All @@ -24,6 +24,7 @@ html(lang=config.language)
block preconnect
script.
(function() {
if (CONFIG.mode !== 'auto') return
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
const setting = localStorage.getItem('darken-mode') || 'auto'
if (setting === 'dark' || (prefersDark && setting !== 'light'))
Expand Down

1 comment on commit df6ba22

@vercel
Copy link

@vercel vercel bot commented on df6ba22 Oct 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.