From 3fc280f2dbf5b9a714db6ac68eb48d6907242f95 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Sat, 2 Nov 2024 16:23:53 +0800 Subject: [PATCH] update 2024-11-02 16:23:53 --- alist/Makefile | 4 +- .../htdocs/nekobox/status-bar.php | 107 +++++++++++++----- 2 files changed, 83 insertions(+), 28 deletions(-) diff --git a/alist/Makefile b/alist/Makefile index ad62af00f..f547e2bf6 100644 --- a/alist/Makefile +++ b/alist/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=alist PKG_VERSION:=3.39.0 -PKG_WEB_VERSION:=3.38.0 +PKG_WEB_VERSION:=3.39.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz @@ -23,7 +23,7 @@ define Download/$(PKG_NAME)-web FILE:=$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz URL_FILE:=dist.tar.gz URL:=https://github.com/alist-org/alist-web/releases/download/$(PKG_WEB_VERSION)/ - HASH:=8c76d6863bc77e0b5da1cbae10b6cec2b3332fcb4e41f055747f4cc5ab04c06a + HASH:=59f5dae6fed76ca708b12a7a6323ef85cdee48861ffafb8864c785b7d7c36e89 endef PKG_BUILD_DEPENDS:=golang/host diff --git a/luci-app-nekobox/htdocs/nekobox/status-bar.php b/luci-app-nekobox/htdocs/nekobox/status-bar.php index 2a5e71d3d..ee6af1355 100644 --- a/luci-app-nekobox/htdocs/nekobox/status-bar.php +++ b/luci-app-nekobox/htdocs/nekobox/status-bar.php @@ -202,6 +202,24 @@ $lang = $_GET['lang'] ?? 'en'; transform: scale(1.1); } +.ping-status { + text-align: center; + margin: 10px 0; + padding: 5px; +} +#ping-result { + margin: 0; + color: #666; + font-size: 14px; +} +.site-icon { + cursor: pointer; +} + +#flag { + cursor: pointer; +} + @media (max-width: 768px) { .cbi-section { padding: 0 10px; @@ -289,29 +307,32 @@ $lang = $_GET['lang'] ?? 'en';
- +

Checking...

-
+
+
+

+
- - + +
- - + +
- - + +
- - + +
@@ -351,7 +372,30 @@ $lang = $_GET['lang'] ?? 'en'; } }; + async function pingHost(site, siteName) { + const url = checkSiteStatus.sites[site]; + const resultElement = document.getElementById('ping-result'); + + try { + resultElement.innerHTML = `正在测试 ${siteName} 的连接延迟...`; + resultElement.style.color = '#666'; + const startTime = performance.now(); + await fetch(url, { + mode: 'no-cors', + cache: 'no-cache' + }); + const endTime = performance.now(); + const pingTime = Math.round(endTime - startTime); + resultElement.innerHTML = `${siteName} 连接延迟: ${pingTime}ms`; + resultElement.style.color = pingTime > 200 ? '#ff6b6b' : '#20c997'; + } catch (error) { + resultElement.innerHTML = `${siteName} 连接超时`; + resultElement.style.color = '#ff6b6b'; + } + } + let IP = { + isRefreshing: false, fetchIP: async () => { try { const [ipifyResp, ipsbResp] = await Promise.all([ @@ -368,8 +412,12 @@ $lang = $_GET['lang'] ?? 'en'; throw error; } }, + get: (url, type) => - fetch(url, { method: 'GET' }).then((resp) => { + fetch(url, { + method: 'GET', + cache: 'no-store' + }).then((resp) => { if (type === 'text') return Promise.all([resp.ok, resp.status, resp.text(), resp.headers]); else @@ -384,21 +432,18 @@ $lang = $_GET['lang'] ?? 'en'; console.error("Error fetching data:", error); throw error; }), + Ipip: async (ip, elID) => { - if (ip === cachedIP && cachedInfo) { - console.log("Using cached IP info"); - IP.updateUI(cachedInfo, elID); - } else { - try { - const resp = await IP.get(`https://api.ip.sb/geoip/${ip}`, 'json'); - cachedIP = ip; - cachedInfo = resp.data; - IP.updateUI(resp.data, elID); - } catch (error) { - console.error("Error in Ipip function:", error); - } + try { + const resp = await IP.get(`https://api.ip.sb/geoip/${ip}`, 'json'); + cachedIP = ip; + cachedInfo = resp.data; + IP.updateUI(resp.data, elID); + } catch (error) { + console.error("Error in Ipip function:", error); } }, + updateUI: (data, elID) => { let country = translate[data.country] || data.country; let isp = translate[data.isp] || data.isp; @@ -413,20 +458,30 @@ $lang = $_GET['lang'] ?? 'en'; $("#flag").attr("src", _IMG + "flags/" + countryAbbr + ".png"); document.getElementById(elID).style.color = '#FF00FF'; }, + getIpipnetIP: async () => { + if(IP.isRefreshing) return; + try { + IP.isRefreshing = true; + document.getElementById('d-ip').innerHTML = "Checking..."; + document.getElementById('ipip').innerHTML = "Loading..."; + $("#flag").attr("src", _IMG + "img/loading.svg"); + const ip = await IP.fetchIP(); await IP.Ipip(ip, 'ipip'); } catch (error) { console.error("Error in getIpipnetIP function:", error); + } finally { + IP.isRefreshing = false; } } }; IP.getIpipnetIP(); checkSiteStatus.check(); - setInterval(IP.getIpipnetIP, 5000); - setInterval(() => checkSiteStatus.check(), 30000); + setInterval(() => checkSiteStatus.check(), 30000); + setInterval(IP.getIpipnetIP, 180000); - + \ No newline at end of file