更新 main.go

This commit is contained in:
XOF
2025-12-30 03:51:30 +08:00
parent 761d6776a9
commit 42f1483a80

87
main.go
View File

@@ -175,7 +175,7 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
statusIPv6 = "🟡" statusIPv6 = "🟡"
} }
// 🔥 自动检测访问协议和地址 // 自动检测访问协议和地址
protocol := "http" protocol := "http"
if r.TLS != nil || r.Header.Get("X-Forwarded-Proto") == "https" { if r.TLS != nil || r.Header.Get("X-Forwarded-Proto") == "https" {
protocol = "https" protocol = "https"
@@ -263,35 +263,35 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
} }
h1 { h1 {
font-size: 2.5em; font-size: 2.5em;
margin-bottom: 10px; margin-bottom: 10px;
position: relative; position: relative;
/* 🔥 先设置普通颜色作为基础 */ color: #667eea;
color: #667eea; }
}
/* 只在支持的浏览器上应用渐变 */ @supports (background-clip: text) or (-webkit-background-clip: text) {
@supports (background-clip: text) or (-webkit-background-clip: text) { h1 {
h1 { background: linear-gradient(135deg, #667eea 0%%, #764ba2 100%%);
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); -webkit-background-clip: text;
-webkit-background-clip: text; -webkit-text-fill-color: transparent;
-webkit-text-fill-color: transparent; background-clip: text;
background-clip: text; }
} }
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
h1 { h1 {
color: #818cf8; color: #818cf8;
} }
@supports (background-clip: text) or (-webkit-background-clip: text) { @supports (background-clip: text) or (-webkit-background-clip: text) {
h1 { h1 {
background: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%); background: linear-gradient(135deg, #818cf8 0%%, #a78bfa 100%%);
-webkit-background-clip: text; -webkit-background-clip: text;
-webkit-text-fill-color: transparent; -webkit-text-fill-color: transparent;
background-clip: text; background-clip: text;
} }
} }
} }
.subtitle { .subtitle {
color: var(--text-secondary); color: var(--text-secondary);
@@ -511,8 +511,8 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
<body> <body>
<div class="container"> <div class="container">
<header> <header>
<h1>CHNRoute RSC 服务</h1> <h1>🇨🇳 CHNRoute RSC 服务</h1>
<p class="subtitle">自动转换 IP 列表为 RouterOS 可导入格式</p> <p class="subtitle">自动转换中国 IP 列表为 RouterOS 可导入格式</p>
</header> </header>
<!-- 下载区域 --> <!-- 下载区域 -->
@@ -588,12 +588,12 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
<div class="status-item"> <div class="status-item">
<div class="status-icon">%s</div> <div class="status-icon">%s</div>
<div class="status-label">IPv4 缓存</div> <div class="status-label">IPv4 缓存</div>
<div class="status-time">已缓存 %s</div> <div class="status-time">已缓存 %v</div>
</div> </div>
<div class="status-item"> <div class="status-item">
<div class="status-icon">%s</div> <div class="status-icon">%s</div>
<div class="status-label">IPv6 缓存</div> <div class="status-label">IPv6 缓存</div>
<div class="status-time">已缓存 %s</div> <div class="status-time">已缓存 %v</div>
</div> </div>
</div> </div>
</div> </div>
@@ -634,21 +634,20 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
</script> </script>
</body> </body>
</html>`, </html>`,
baseURL, baseURL, // 下载地址 IPv4 baseURL, baseURL, // 1-2: 下载地址 IPv4 (href + 显示文本)
baseURL, baseURL, // 下载地址 IPv6 baseURL, baseURL, // 3-4: 下载地址 IPv6 (href + 显示文本)
protocolBadge, // 协议徽章 protocolBadge, // 5: 协议徽章
protocolNote, // 协议提示 protocolNote, // 6: 协议提示
baseURL, fetchMode, // 一键导入 baseURL, fetchMode, // 7-8: 一键导入 (url + mode)
baseURL, fetchMode, // 自动更新 baseURL, fetchMode, // 9-10: 自动更新 (url + mode)
baseURL, fetchMode, // IPv6 导入 baseURL, fetchMode, // 11-12: IPv6 导入 (url + mode)
statusIPv4, cacheAgeIPv4, // 状态 IPv4 statusIPv4, cacheAgeIPv4, // 13-14: IPv4 状态图标 + 缓存时间
statusIPv6, cacheAgeIPv6) // 状态 IPv6 statusIPv6, cacheAgeIPv6) // 15-16: IPv6 状态图标 + 缓存时间
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Write([]byte(html)) w.Write([]byte(html))
} }
func main() { func main() {
// 启动时预热缓存 // 启动时预热缓存
go func() { go func() {