Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
•
9aeba67
1
Parent(s):
9d900a2
fix: 解决亮暗色切换按钮未跟随系统切换问题
Browse files- assets/custom.js +2 -0
assets/custom.js
CHANGED
@@ -172,9 +172,11 @@ function adjustDarkMode() {
|
|
172 |
const darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
173 |
|
174 |
// 根据当前颜色模式设置初始状态
|
|
|
175 |
toggleDarkMode(darkModeQuery.matches);
|
176 |
// 监听颜色模式变化
|
177 |
darkModeQuery.addEventListener("change", (e) => {
|
|
|
178 |
toggleDarkMode(e.matches);
|
179 |
});
|
180 |
// apSwitch = document.querySelector('.apSwitch input[type="checkbox"]');
|
|
|
172 |
const darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
173 |
|
174 |
// 根据当前颜色模式设置初始状态
|
175 |
+
apSwitch.checked = darkModeQuery.matches;
|
176 |
toggleDarkMode(darkModeQuery.matches);
|
177 |
// 监听颜色模式变化
|
178 |
darkModeQuery.addEventListener("change", (e) => {
|
179 |
+
apSwitch.checked = e.matches;
|
180 |
toggleDarkMode(e.matches);
|
181 |
});
|
182 |
// apSwitch = document.querySelector('.apSwitch input[type="checkbox"]');
|