Skip to content

Commit

Permalink
feature: html添加夜间模式
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Jul 11, 2022
1 parent 3462251 commit 2aa8687
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@
opacity: 0;
}
}
@media (prefers-color-scheme: dark) {
html,
body {
background-color: #000;
}
}

@media (prefers-color-scheme: light) {
html,
body {
background-color: #fff;
}
}
</style>
<div class="loading">
<div></div>
Expand All @@ -150,15 +163,6 @@
<div></div>
</div>
</div>
<script>
window.onload = function () {
const stora = localStorage.getItem('appConfigMode');
if (stora) {
const appConfigMode = JSON.parse(stora);
document.body.style.background = appConfigMode.themeMode === 'dark' ? '#000' : '';
}
};
</script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

0 comments on commit 2aa8687

Please sign in to comment.