add local setting for auto/light/dark

This commit is contained in:
Your Name 2024-04-14 13:24:22 -04:00 committed by Henri Dickson
parent 84f4d3aa43
commit 55701c1ffe
4 changed files with 28 additions and 10 deletions

View file

@ -45,6 +45,7 @@
style.innerHTML = ".solo-hidden {display: none;}"; style.innerHTML = ".solo-hidden {display: none;}";
document.head.appendChild(style); document.head.appendChild(style);
} }
$('html').attr('data-theme', localStorage.getItem("theme_color"))
})(); })();
</script> </script>
<link rel="icon" href="{{ site_icon }}"> <link rel="icon" href="{{ site_icon }}">

View file

@ -100,7 +100,7 @@ server {
proxy_cache_valid any 72h; proxy_cache_valid any 72h;
add_header X-Cache $upstream_cache_status; add_header X-Cache $upstream_cache_status;
} }
location ~* ^/(static|@|\.well-known|actor|inbox|api/v1|api/v2|oauth|tags|settings|media|proxy|admin|djadmin) { location ~* ^/(static|@|\.well-known|actor|inbox|api/v1|api/v2|oauth|tags|settings|media|proxy|admin|djadmin|pages|about) {
proxy_pass http://takahe; proxy_pass http://takahe;
} }
location / { location / {

View file

@ -112,7 +112,7 @@ server {
proxy_cache_valid any 72h; proxy_cache_valid any 72h;
add_header X-Cache $upstream_cache_status; add_header X-Cache $upstream_cache_status;
} }
location ~* ^/(@|\.well-known|actor|inbox|api/v1|api/v2|oauth|tags|settings|media|proxy|admin|djadmin) { location ~* ^/(@|\.well-known|actor|inbox|api/v1|api/v2|oauth|tags|settings|media|proxy|admin|djadmin|pages|about) {
proxy_pass http://takahe; proxy_pass http://takahe;
} }
location /api/ { location /api/ {

View file

@ -181,7 +181,16 @@
<details> <details>
<summary>{% trans '当前设备设置' %}</summary> <summary>{% trans '当前设备设置' %}</summary>
<form onsubmit="return false;"> <form onsubmit="return false;">
<h6>专注模式 (实验功能)</h6> <h6>明暗风格</h6>
<p>
<input type="radio" name="theme_color" id="theme_auto" value="">
<label for="theme_auto">系统</label>
<input type="radio" name="theme_color" id="theme_light" value="light">
<label for="theme_light">明亮</label>
<input type="radio" name="theme_color" id="theme_dark" value="dark">
<label for="theme_dark">暗色</label>
</p>
<h6>专注模式</h6>
<p> <p>
<input type="checkbox" id="solo_mode"> <input type="checkbox" id="solo_mode">
<label for="solo_mode">启用专注模式后搜索和条目页面将不再显示来自他人的评价和打分</label> <label for="solo_mode">启用专注模式后搜索和条目页面将不再显示来自他人的评价和打分</label>
@ -193,13 +202,21 @@
</form> </form>
</details> </details>
<script> <script>
$("#user_style").val(localStorage.getItem("user_style")||""); var _c=$('html').attr('data-theme')||null;
$("#solo_mode").prop("checked", localStorage.getItem("solo_mode")=="1"); if (_c=="light") $('input[id=theme_light]').prop('checked', true);
function save_local() { if (_c=="dark") $('input[id=theme_dark]').prop('checked', true);
localStorage.setItem("user_style", $("#user_style").val()); if (!_c) $('input[id=theme_auto]').prop('checked', true);
localStorage.setItem("solo_mode", $("#solo_mode").prop("checked")?"1":"0"); $("#user_style").val(localStorage.getItem("user_style")||"");
alert("本地设置已保存"); $("#solo_mode").prop("checked", localStorage.getItem("solo_mode")=="1");
} function save_local() {
var _c=$('input[name=theme_color]:checked').val();
if (_c=="") _c=null;
$('html').attr('data-theme', _c);
localStorage.setItem("theme_color", _c);
localStorage.setItem("user_style", $("#user_style").val());
localStorage.setItem("solo_mode", $("#solo_mode").prop("checked")?"1":"0");
alert("当前设备设置已保存");
}
</script> </script>
</article> </article>
<article> <article>