mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
🚸 使用服务器端时间判断机器离线
This commit is contained in:
5
resource/template/theme-daynight/home.html
vendored
5
resource/template/theme-daynight/home.html
vendored
@@ -263,14 +263,15 @@
|
||||
});
|
||||
}
|
||||
ws.onmessage = function (evt) {
|
||||
statusCards.servers = JSON.parse(evt.data)
|
||||
const data = JSON.parse(evt.data)
|
||||
statusCards.servers = data.servers
|
||||
const keys = Object.keys(statusCards.servers)
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const ns = statusCards.servers[keys[i]];
|
||||
if (!ns.Host) ns.live = false
|
||||
else {
|
||||
const lastActive = new Date(ns.LastActive).getTime()
|
||||
if (Date.now() - lastActive > 20 * 1000) {
|
||||
if (data.now - lastActive > 10 * 1000) {
|
||||
ns.live = false
|
||||
} else {
|
||||
ns.live = true
|
||||
|
||||
5
resource/template/theme-default/home.html
vendored
5
resource/template/theme-default/home.html
vendored
@@ -254,13 +254,14 @@
|
||||
}
|
||||
ws.onmessage = function (evt) {
|
||||
const oldServers = statusCards.servers
|
||||
statusCards.servers = JSON.parse(evt.data)
|
||||
const data = JSON.parse(evt.data)
|
||||
statusCards.servers = data.servers
|
||||
for (let i = 0; i < statusCards.servers.length; i++) {
|
||||
const ns = statusCards.servers[i];
|
||||
if (!ns.Host) ns.live = false
|
||||
else {
|
||||
const lastActive = new Date(ns.LastActive).getTime()
|
||||
if (Date.now() - lastActive > 20 * 1000) {
|
||||
if (data.now - lastActive > 10 * 1000) {
|
||||
ns.live = false
|
||||
} else {
|
||||
ns.live = true
|
||||
|
||||
5
resource/template/theme-hotaru/home.html
vendored
5
resource/template/theme-hotaru/home.html
vendored
@@ -259,13 +259,14 @@
|
||||
});
|
||||
}
|
||||
ws.onmessage = function (evt) {
|
||||
statusCards.servers = JSON.parse(evt.data)
|
||||
const data = JSON.parse(evt.data)
|
||||
statusCards.servers = data.servers
|
||||
for (let i = 0; i < statusCards.servers.length; i++) {
|
||||
const ns = statusCards.servers[i];
|
||||
if (!ns.Host) ns.live = false
|
||||
else {
|
||||
const lastActive = new Date(ns.LastActive).getTime()
|
||||
if (Date.now() - lastActive > 20 * 1000) {
|
||||
if (data.now - lastActive > 10 * 1000) {
|
||||
ns.live = false
|
||||
} else {
|
||||
ns.live = true
|
||||
|
||||
Reference in New Issue
Block a user