1
0
Fork 0

update script code

This commit is contained in:
nanxiaobei 2021-08-21 04:22:56 +08:00
parent b9f899e1ef
commit d46e0d8ba8

View file

@ -61,16 +61,16 @@
` $tag ("" | absURL) site.Title $tag | safeHTML }} ` $tag ("" | absURL) site.Title $tag | safeHTML }}
<script> <script>
const bodyClass = document.body.classList; let bodyClass = document.body.classList;
const schemeDark = window.matchMedia('(prefers-color-scheme: dark)'); let schemeDark = window.matchMedia('(prefers-color-scheme: dark)');
const buttonDark = document.querySelector('.btn-theme'); let buttonDark = document.querySelector('.btn-theme');
const setDark = () => { let setDark = () => {
bodyClass.add('dark'); bodyClass.add('dark');
localStorage.setItem('dark', 'true'); localStorage.setItem('dark', 'true');
}; };
const setLight = () => { let setLight = () => {
bodyClass.remove('dark'); bodyClass.remove('dark');
localStorage.removeItem('dark'); localStorage.removeItem('dark');
}; };