mirror of https://github.com/cppla/ServerStatus
主题默认跟随系统,直至你手动选择了模式
parent
ef0229b2d7
commit
43c1c1279f
|
@ -6,7 +6,7 @@
|
||||||
[](https://github.com/cppla/ServerStatus)
|
[](https://github.com/cppla/ServerStatus)
|
||||||
[](https://github.com/cppla/ServerStatus)
|
[](https://github.com/cppla/ServerStatus)
|
||||||
[](https://github.com/cppla/ServerStatus)
|
[](https://github.com/cppla/ServerStatus)
|
||||||
[](https://github.com/cppla/ServerStatus)
|
[](https://github.com/cppla/ServerStatus)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
【服务端】:
|
【服务端】:
|
||||||
```bash
|
```bash
|
||||||
|
|
||||||
`onetouch`:
|
`OneTouch`:
|
||||||
|
|
||||||
wget --no-check-certificate -qO serverstatus-config.json https://raw.githubusercontent.com/cppla/ServerStatus/master/server/config.json && mkdir serverstatus-monthtraffic
|
wget --no-check-certificate -qO serverstatus-config.json https://raw.githubusercontent.com/cppla/ServerStatus/master/server/config.json && mkdir serverstatus-monthtraffic
|
||||||
docker run -d --restart=always --name=serverstatus -v ~/serverstatus-config.json:/ServerStatus/server/config.json -v ~/serverstatus-monthtraffic:/usr/share/nginx/html/json -p 80:80 -p 35601:35601 cppla/serverstatus:latest
|
docker run -d --restart=always --name=serverstatus -v ~/serverstatus-config.json:/ServerStatus/server/config.json -v ~/serverstatus-monthtraffic:/usr/share/nginx/html/json -p 80:80 -p 35601:35601 cppla/serverstatus:latest
|
||||||
|
|
|
@ -50,8 +50,8 @@
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">风格<b class="caret"></b></a>
|
<a data-toggle="dropdown" class="dropdown-toggle" href="#">风格<b class="caret"></b></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="#" onclick="setActiveStyleSheet('dark')">黑夜</a></li>
|
<li><a href="#" onclick="setActiveStyleSheet('dark', true)">黑夜</a></li>
|
||||||
<li><a href="#" onclick="setActiveStyleSheet('light')">白天</a></li>
|
<li><a href="#" onclick="setActiveStyleSheet('light', true)">白天</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -318,14 +318,17 @@ setInterval(updateTime, 2000);
|
||||||
|
|
||||||
|
|
||||||
// styleswitcher.js
|
// styleswitcher.js
|
||||||
function setActiveStyleSheet(title) {
|
function setActiveStyleSheet(title, cookie=false) {
|
||||||
var i, a, main;
|
var i, a, main;
|
||||||
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
|
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
|
||||||
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
|
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
|
||||||
a.disabled = true;
|
a.disabled = true;
|
||||||
if(a.getAttribute("title") == title) a.disabled = false;
|
if(a.getAttribute("title") == title) a.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (true==cookie) {
|
||||||
|
createCookie("style", title, 365);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getActiveStyleSheet() {
|
function getActiveStyleSheet() {
|
||||||
|
@ -337,15 +340,6 @@ function getActiveStyleSheet() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPreferredStyleSheet() {
|
|
||||||
var i, a;
|
|
||||||
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
|
|
||||||
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title"))
|
|
||||||
return a.getAttribute("title");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createCookie(name,value,days) {
|
function createCookie(name,value,days) {
|
||||||
if (days) {
|
if (days) {
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
|
@ -370,16 +364,19 @@ function readCookie(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function(e) {
|
window.onload = function(e) {
|
||||||
var cookie = readCookie("style");
|
var cookie = readCookie("style");
|
||||||
var title = cookie ? cookie : getPreferredStyleSheet();
|
if (cookie && cookie != 'null' ) {
|
||||||
setActiveStyleSheet(title);
|
setActiveStyleSheet(cookie);
|
||||||
|
} else {
|
||||||
|
function handleChange (mediaQueryListEvent) {
|
||||||
|
if (mediaQueryListEvent.matches) {
|
||||||
|
setActiveStyleSheet('dark');
|
||||||
|
} else {
|
||||||
|
setActiveStyleSheet('light');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const mediaQueryListDark = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
|
setActiveStyleSheet(mediaQueryListDark.matches ? 'dark' : 'light');
|
||||||
|
mediaQueryListDark.addEventListener("change",handleChange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onunload = function(e) {
|
|
||||||
var title = getActiveStyleSheet();
|
|
||||||
createCookie("style", title, 365);
|
|
||||||
}
|
|
||||||
|
|
||||||
var cookie = readCookie("style");
|
|
||||||
var title = cookie ? cookie : getPreferredStyleSheet();
|
|
||||||
setActiveStyleSheet(title);
|
|
||||||
|
|
Loading…
Reference in New Issue