-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Waline无法跟随博客开关暗黑模式 #87
Comments
OK,我知道是怎么回事了 |
不对,Kaze会根据浏览器暗黑模式的开关来决定加 <% if(config.prismjs && config.prismjs.enable && theme.prism && theme.prism.darkTheme) { %>
<script>
var setDarkmode = function(mode) {
var setting = mode || localStorage.getItem('user-color-scheme');
if(setting === getCssMediaQuery()) {
document.documentElement.setAttribute('data-user-color-scheme', setting);
localStorage.removeItem('user-color-scheme');
document.getElementById('theme-color').content = themeColor[setting];
document.getElementById('theme-color').dataset.mode = setting;
prismThemeChange();
} else if(reverseDarkList[setting]) {
document.documentElement.setAttribute('data-user-color-scheme', setting);
document.getElementById('theme-color').content = themeColor[setting];
document.getElementById('theme-color').dataset.mode = setting;
prismThemeChange();
} else {
document.documentElement.setAttribute('data-user-color-scheme', window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
localStorage.removeItem('user-color-scheme');
document.getElementById('theme-color').content = themeColor[getCssMediaQuery()];
document.getElementById('theme-color').dataset.mode = getCssMediaQuery();
prismThemeChange();
}
};
setDarkmode();
</script>
<% } else { %>
<script>
var setDarkmode = function(mode) {
var setting = mode || localStorage.getItem('user-color-scheme');
if(setting === getCssMediaQuery()) {
document.documentElement.setAttribute('data-user-color-scheme', setting);
localStorage.removeItem('user-color-scheme');
document.getElementById('theme-color').content = themeColor[setting];
document.getElementById('theme-color').dataset.mode = setting;
} else if(reverseDarkList[setting]) {
document.documentElement.setAttribute('data-user-color-scheme', setting);
document.getElementById('theme-color').content = themeColor[setting];
document.getElementById('theme-color').dataset.mode = setting;
} else {
document.documentElement.setAttribute('data-user-color-scheme'), window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
localStorage.removeItem('user-color-scheme');
document.getElementById('theme-color').content = themeColor[getCssMediaQuery()];
document.getElementById('theme-color').dataset.mode = getCssMediaQuery();
}
};
setDarkmode();
</script>
<% } %> 然后 |
Describe the bug 描述问题
Waline无法跟随博客开关暗黑模式
To Reproduce 如何复现
打开Waline评论之后默认配置就能复现
Environment 使用环境
hexo: 5.3.0
hexo-cli: 4.3.2
Kaze: v1.1.0-beta6
Additional context 额外信息
我发现在博客网页源代码中,Waline配置的
dark
的参数是'html[data-user-color-scheme="dark"]'
。可能和这个有关系?The text was updated successfully, but these errors were encountered: