diff --git a/README.md b/README.md
index 64cb9b5..e135e35 100644
--- a/README.md
+++ b/README.md
@@ -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)

@@ -26,7 +26,7 @@
【服务端】:
```bash
-`onetouch`:
+`OneTouch`:
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
diff --git a/web/index.html b/web/index.html
index 49a7e66..eaa8f13 100644
--- a/web/index.html
+++ b/web/index.html
@@ -50,8 +50,8 @@
风格
diff --git a/web/js/serverstatus.js b/web/js/serverstatus.js
index cf8a519..44b0fc3 100644
--- a/web/js/serverstatus.js
+++ b/web/js/serverstatus.js
@@ -318,14 +318,17 @@ setInterval(updateTime, 2000);
// styleswitcher.js
-function setActiveStyleSheet(title) {
- var i, a, main;
- for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
- if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
- a.disabled = true;
- if(a.getAttribute("title") == title) a.disabled = false;
- }
- }
+function setActiveStyleSheet(title, cookie=false) {
+ var i, a, main;
+ for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
+ if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
+ a.disabled = true;
+ if(a.getAttribute("title") == title) a.disabled = false;
+ }
+ }
+ if (true==cookie) {
+ createCookie("style", title, 365);
+ }
}
function getActiveStyleSheet() {
@@ -337,15 +340,6 @@ function getActiveStyleSheet() {
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) {
if (days) {
var date = new Date();
@@ -370,16 +364,19 @@ function readCookie(name) {
}
window.onload = function(e) {
- var cookie = readCookie("style");
- var title = cookie ? cookie : getPreferredStyleSheet();
- setActiveStyleSheet(title);
+ var cookie = readCookie("style");
+ if (cookie && cookie != 'null' ) {
+ 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);