Comments (2)
可以,后期可以看看,这个功能还是很好的。
之前有根据时间来自动设置夜间模式,但是这个功能当时有点小缺陷,不是特别好,所以后面直接改成手动控制了
from halo-theme-xue.
自己动手,丰衣足食
修改 source/js/_plugins/night-mode.js
文件记录:
修改后经过测试是可以的~~~ 而且不影响手动开关夜间模式的功能。
// 首先定义一个key:
var userSelectNightModeId = 'userSelectNightMode';
// 在 clickNightMode 方法中增加一行,原有的不要动
//这里的目的是记录用户已经手动选择过夜间模式了
//如果用户点击 switch,手动开关了夜间模式,就不要自动跟随系统的夜间模式了
hanUtils.setLocalStorage(userSelectNightModeId, true);
autoNightMode: function () {
// 如果用户手动选择过夜间模式,则不要自动跟随系统的夜间模式,而是继续用之前的模式
// 如果用户未手动选择过,则自动跟随系统的夜间模式
if(hanUtils.getLocalStorage(userSelectNightModeId)){
// 根据当前时间判断是否是晚上
// 如果当前是晚上,由于各种设置会不一样,这里干脆写死, 并且开启了自动夜晚模式
nightMode.changeNightMode(hanUtils.getLocalStorage(nightModeId));
}else{
nightMode.changeNightMode(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches);
}
}
from halo-theme-xue.
Related Issues (20)
- 图片加载失败 HOT 1
- nav 可以增加PC端毛玻璃的效果吗? HOT 1
- 冰天雪地求2.0beta1更新 适配瞬间和图库插件 HOT 1
- 关于next分支的相册和文章页 HOT 1
- 关于元数据和分页的问题 HOT 1
- 请教下关于模板的问题 HOT 1
- next分支首页不更新文章浏览次数等统计信息 HOT 1
- 请问如何将首页背景更换为视频? HOT 2
- 瞬间前台不显示图片 HOT 2
- 部署之后遇到了语法过期的问题 HOT 2
- halo2.9 首页文章卡片不显示访问数据与摘要 HOT 1
- Halo 2.x 一直默认深夜模式 HOT 4
- 瞬间图片无法显示 HOT 1
- 分类标签下面预览位置错位 HOT 2
- 想请教一下怎么关闭分类页面顶部图片自动变色功能 HOT 1
- Priv_Next_Page失效
- 谁能教教我,这个红框框里的东西怎么去掉呀
- 文章透明封面图背景显示
- Github和邮箱连接添加后无法删除
- 友情链接设置头像图片但不显示 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from halo-theme-xue.