From 96c3fd433ff4e553d41a2173c24499483fb04d85 Mon Sep 17 00:00:00 2001
From: nap0o <144927971+nap0o@users.noreply.github.com>
Date: Fri, 1 Nov 2024 09:28:14 -0400
Subject: [PATCH] =?UTF-8?q?feat:=20status-server=E4=B8=BB=E9=A2=98?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A5=97=E9=A4=90=E4=BF=A1=E6=81=AF=E5=B1=95?=
=?UTF-8?q?=E7=A4=BA=20(#464)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat: status-server主题增加套餐信息展示
1. 首页通过在后台配置PublicNote字段,实现agent套餐信息展示
2. 一些其他小优化
* 1.未获取agent国家时,默认彩虹旗修改为联合国旗
---
resource/l10n/en-US.toml | 3 +
resource/l10n/es-ES.toml | 3 +
resource/l10n/zh-CN.toml | 3 +
resource/l10n/zh-TW.toml | 3 +
.../static/theme-server-status/css/dark.css | 5 ++
.../static/theme-server-status/css/light.css | 7 ++
.../theme-server-status/css/light.plus.css | 5 ++
.../static/theme-server-status/css/main.css | 19 ++++
.../template/theme-server-status/header.html | 6 +-
.../theme-server-status/home-group-false.html | 43 ++++++++-
.../theme-server-status/home-group-true.html | 43 ++++++++-
.../template/theme-server-status/home.html | 90 +++++++++++--------
.../template/theme-server-status/network.html | 4 +-
13 files changed, 187 insertions(+), 47 deletions(-)
diff --git a/resource/l10n/en-US.toml b/resource/l10n/en-US.toml
index 38cdfa5..64036f3 100644
--- a/resource/l10n/en-US.toml
+++ b/resource/l10n/en-US.toml
@@ -750,3 +750,6 @@ other = "d"
[CustomNameservers]
other = "Custom Public DNS Nameservers for DDNS (separate with comma)"
+
+[Plan]
+other = "Plan"
diff --git a/resource/l10n/es-ES.toml b/resource/l10n/es-ES.toml
index c6b598c..1516253 100644
--- a/resource/l10n/es-ES.toml
+++ b/resource/l10n/es-ES.toml
@@ -750,3 +750,6 @@ other = "d"
[CustomNameservers]
other = "Servidores DNS públicos personalizados para DDNS (separar con coma)"
+
+[Plan]
+other = "Plan"
diff --git a/resource/l10n/zh-CN.toml b/resource/l10n/zh-CN.toml
index 204b830..8046298 100644
--- a/resource/l10n/zh-CN.toml
+++ b/resource/l10n/zh-CN.toml
@@ -750,3 +750,6 @@ other = "天"
[CustomNameservers]
other = "自定义DDNS使用的公共DNS服务器(逗号分隔)"
+
+[Plan]
+other = "套餐"
diff --git a/resource/l10n/zh-TW.toml b/resource/l10n/zh-TW.toml
index 4e41db7..c9ba6c5 100644
--- a/resource/l10n/zh-TW.toml
+++ b/resource/l10n/zh-TW.toml
@@ -750,3 +750,6 @@ other = "天"
[CustomNameservers]
other = "自訂DDNS使用的公共DNS伺服器(逗號分隔)"
+
+[Plan]
+other = "套餐"
diff --git a/resource/static/theme-server-status/css/dark.css b/resource/static/theme-server-status/css/dark.css
index 47b57ee..00e8e12 100755
--- a/resource/static/theme-server-status/css/dark.css
+++ b/resource/static/theme-server-status/css/dark.css
@@ -90,6 +90,11 @@ body[theme="dark"] .table > tbody > tr.expandRow.odd > td:before {
body[theme="dark"] .table > tbody > tr.expandRow.even > td:before {
background-color: rgba(28, 29, 38, 1);
}
+
+body[theme="dark"] .plan {
+ background-image: none;
+ background-color: rgba(255, 255, 255, 0.075);
+}
/* expandRow展开部分样式结束 */
body[theme="dark"] .progress {
diff --git a/resource/static/theme-server-status/css/light.css b/resource/static/theme-server-status/css/light.css
index 9262d49..cfa9921 100755
--- a/resource/static/theme-server-status/css/light.css
+++ b/resource/static/theme-server-status/css/light.css
@@ -116,6 +116,13 @@ body[theme="light"] tr.odd.expandRow > :hover {
background: #ffffff !important;
}
+body[theme="light"] .plan {
+ color: #000000;
+ background-color: #f5f5f5;
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
+}
+
body[theme="light"] .progress-bar {
color: #000000;
}
diff --git a/resource/static/theme-server-status/css/light.plus.css b/resource/static/theme-server-status/css/light.plus.css
index b74c805..da791ca 100644
--- a/resource/static/theme-server-status/css/light.plus.css
+++ b/resource/static/theme-server-status/css/light.plus.css
@@ -104,6 +104,11 @@ body[theme="light"] .table > tbody > tr.expandRow.odd > td:before {
body[theme="light"] .table > tbody > tr.expandRow.even > td:before {
background-color: unset;
}
+
+body[theme="light"] .plan {
+ background-image: none;
+ background-color: rgba(0, 0, 0, 0.015);
+}
/* expandRow展开部分样式结束 */
body[theme="light"] .progress {
diff --git a/resource/static/theme-server-status/css/main.css b/resource/static/theme-server-status/css/main.css
index 0526b4c..5f6756f 100755
--- a/resource/static/theme-server-status/css/main.css
+++ b/resource/static/theme-server-status/css/main.css
@@ -268,6 +268,22 @@ tr.accordion-toggle{
font-size: 80%;
}
+.plan {
+ display: inline-block;
+ font-size: 85%;
+ margin-right: 2px;
+ padding: 2px 5px;
+ border-radius: 2px;
+}
+
+.network-route, .extra {
+ margin-right: 6px;
+}
+
+.last {
+ margin-right: 2px;
+}
+
.temp-detail {
cursor: pointer;
}
@@ -557,6 +573,9 @@ footer p {
min-width: 75px;
max-width: 75px;
}
+ .plan {
+ display: inline;
+ }
.accordian-body {
margin: 5px 0px 5px 10px;
}
diff --git a/resource/template/theme-server-status/header.html b/resource/template/theme-server-status/header.html
index f1a098f..4247a70 100644
--- a/resource/template/theme-server-status/header.html
+++ b/resource/template/theme-server-status/header.html
@@ -26,9 +26,9 @@
-
-
-
+
+
+
diff --git a/resource/template/theme-server-status/home-group-false.html b/resource/template/theme-server-status/home-group-false.html
index cd1792c..4a8f42b 100644
--- a/resource/template/theme-server-status/home-group-false.html
+++ b/resource/template/theme-server-status/home-group-false.html
@@ -35,8 +35,8 @@
@#getPlatformName(node.os) === '' && node.stateuptime > 0 ? 'linux' : getPlatformName(node.os)#@
-
- @#node.stateuptime > 0 ? (node.location || 'RB') : ''#@
+
+ @#node.stateuptime > 0 ? (node.location || 'UN') : ''#@
|
@@ -88,6 +88,45 @@
+
+ {{tr "Plan"}}:
+
+ FREE
+ PAYG
+ @#node.additional.price.amount#@@#(node.additional.price.cycle ? '/' + node.additional.price.cycle : '')#@
+
+
+
+ {{tr "Lifetime"}}
+ {{tr "Expired"}}
+ @#node.additional.remaining.endDate.toISOString().split('T')[0]#@
+
+
+
+ @#node.additional.plan.bandwidth#@
+
+
+
+
+ @#node.additional.plan.trafficVol#@
+
+
+ IPv4
+
+
+ IPv6
+
+
+
+ @#item#@
+
+
+
+
+
+
{{tr "Platform"}}:
@#node.host.Platform#@@#node.host.PlatformVersion ? '-' + node.host.PlatformVersion : ''#@
diff --git a/resource/template/theme-server-status/home-group-true.html b/resource/template/theme-server-status/home-group-true.html
index 986a5e2..664940c 100644
--- a/resource/template/theme-server-status/home-group-true.html
+++ b/resource/template/theme-server-status/home-group-true.html
@@ -38,8 +38,8 @@
@#getPlatformName(node.os) === '' && node.stateuptime > 0 ? 'linux' : getPlatformName(node.os)#@
|
-
- @#node.stateuptime > 0 ? (node.location || 'RB') : ''#@
+
+ @#node.stateuptime > 0 ? (node.location || 'UN') : ''#@
|
@@ -91,6 +91,45 @@
+
+ {{tr "Plan"}}:
+
+ FREE
+ PAYG
+ @#node.additional.price.amount#@@#(node.additional.price.cycle ? '/' + node.additional.price.cycle : '')#@
+
+
+
+ {{tr "Lifetime"}}
+ {{tr "Expired"}}
+ @#node.additional.remaining.endDate.toISOString().split('T')[0]#@
+
+
+
+ @#node.additional.plan.bandwidth#@
+
+
+
+
+ @#node.additional.plan.trafficVol#@
+
+
+ IPv4
+
+
+ IPv6
+
+
+
+ @#item#@
+
+
+
+
+
+
{{tr "Platform"}}:
@#node.host.Platform#@@#node.host.PlatformVersion ? '-' + node.host.PlatformVersion : ''#@
diff --git a/resource/template/theme-server-status/home.html b/resource/template/theme-server-status/home.html
index 0a91f32..212c922 100644
--- a/resource/template/theme-server-status/home.html
+++ b/resource/template/theme-server-status/home.html
@@ -117,43 +117,54 @@
initAdditional(servers) {
let nodes = {};
servers?.forEach(server => {
- if (server.PublicNote) {
- const remainingFormat = this.getRemainingFormat(server.live, server.PublicNote);
- const remainingDays = this.getRemainingDays(this.getNoteElementValue(server.PublicNote, "billingDataMod", "endDate"), server.PublicNote);
- const remainingPercent = this.getRemainingPercent(
- this.getNoteElementValue(server.PublicNote, "billingDataMod", "startDate"),
- this.getNoteElementValue(server.PublicNote, "billingDataMod", "endDate"),
- server.PublicNote
- );
- const priceAmount = this.getNoteElementValue(server.PublicNote, "billingDataMod", "amount");
- const priceCycle = this.getNoteElementValue(server.PublicNote, "billingDataMod", "cycle");
+ //处理异常
+ if (!server.PublicNote) return;
- // 初始化节点
- nodes[server.ID] = {
- "remaining": {},
- "price": {}
- };
+ // 初始化节点
+ nodes[server.ID] = {
+ "remaining": {},
+ "price": {},
+ "plan": {}
+ };
- if (remainingFormat) {
- nodes[server.ID].remaining.format = remainingFormat;
- }
+ // 处理 billingDataMod 的 remaining 配置
+ const remainingEndDate = this.getRemainingDays(this.getNoteElementValue(server.PublicNote, "billingDataMod", "endDate"), server.PublicNote, 1);
+ const remainingFormat = this.getRemainingFormat(server.live, server.PublicNote);
+ const remainingDays = this.getRemainingDays(this.getNoteElementValue(server.PublicNote, "billingDataMod", "endDate"), server.PublicNote);
+ const remainingPercent = this.getRemainingPercent(
+ this.getNoteElementValue(server.PublicNote, "billingDataMod", "startDate"),
+ this.getNoteElementValue(server.PublicNote, "billingDataMod", "endDate"),
+ server.PublicNote
+ );
+ // 设置 remaining 属性
+ if (remainingEndDate) nodes[server.ID].remaining.endDate = remainingEndDate;
+ if (remainingFormat) nodes[server.ID].remaining.format = remainingFormat;
+ if (remainingDays) nodes[server.ID].remaining.days = remainingDays;
+ if (remainingPercent) nodes[server.ID].remaining.percent = this.toFixed2(100 - remainingPercent);
- if (remainingDays) {
- nodes[server.ID].remaining.days = remainingDays;
- }
-
- if (remainingPercent) {
- nodes[server.ID].remaining.percent = this.toFixed2(100 - remainingPercent);
- }
-
- if (priceAmount) {
- nodes[server.ID].price.amount = priceAmount;
- }
-
- if (priceCycle && priceAmount) {
- nodes[server.ID].price.cycle = priceCycle;
- }
- }
+ // 处理 billingDataMod 的 price 配置
+ const priceAmount = this.getNoteElementValue(server.PublicNote, "billingDataMod", "amount");
+ const priceCycle = this.getNoteElementValue(server.PublicNote, "billingDataMod", "cycle");
+ // 设置 price 属性
+ if (priceAmount) nodes[server.ID].price.amount = priceAmount;
+ if (priceCycle && priceAmount) nodes[server.ID].price.cycle = priceCycle;
+
+ // 处理 planDataMod 配置
+ const planBandwidth = this.getNoteElementValue(server.PublicNote, "planDataMod", "bandwidth");
+ const planTrafficVol = this.getNoteElementValue(server.PublicNote, "planDataMod", "trafficVol");
+ const planTrafficType = this.getNoteElementValue(server.PublicNote, "planDataMod", "trafficType");
+ const planIPv4 = this.getNoteElementValue(server.PublicNote, "planDataMod", "IPv4");
+ const planIPv6 = this.getNoteElementValue(server.PublicNote, "planDataMod", "IPv6");
+ const planNetworkRoute = this.getNoteElementValue(server.PublicNote, "planDataMod", "networkRoute");
+ const planExtra = this.getNoteElementValue(server.PublicNote, "planDataMod", "extra");
+ // 设置 plan 属性
+ if (planBandwidth) nodes[server.ID].plan.bandwidth = planBandwidth;
+ if (planTrafficVol) nodes[server.ID].plan.trafficVol = planTrafficVol;
+ if (planTrafficType) nodes[server.ID].plan.trafficType = planTrafficType;
+ if (planIPv4) nodes[server.ID].plan.ipv4 = planIPv4 >= 1;
+ if (planIPv6) nodes[server.ID].plan.ipv6 = planIPv6 >= 1;
+ if (planNetworkRoute) nodes[server.ID].plan.networkRoute = planNetworkRoute.split(',');
+ if (planExtra) nodes[server.ID].plan.extra = planExtra.split(',');
});
return nodes;
},
@@ -859,7 +870,7 @@
const expiration = new Date(endDate);
const current = this.getAdjustTimezone(new Date(endDate), new Date());
- // 如果 expiration 无效,返回 null 并记录日志
+ // 如果 expiration 无效,记录日志
if (isNaN(expiration.getTime())) {
console.log("getAutoRenewalEndDate: Invalid expiration format");
}
@@ -1055,7 +1066,7 @@
return this.formatPercents(online, this.toFixed2(percent));
},
- getRemainingDays(endDate, note) {
+ getRemainingDays(endDate, note, type) {
// 检查 endDate 是否有效
if (!endDate || typeof endDate !== 'string') {
return null;
@@ -1066,9 +1077,9 @@
return "lifetime";
}
- // 检查 startDate 和 endDate 是否为合法的Date
+ // 检查 endDate 是否为合法的Date
if (isNaN(new Date(endDate).getTime())) {
- return "NaN";
+ return type === 1 ? null : "NaN";
}
// 获取当前时间,并调整时区
@@ -1087,6 +1098,9 @@
// 确定到期时间
const end = autoRenewal ? autoEndDate.date : new Date(endDate);
+ // 直接返回处理后的到期时间
+ if (type === 1) return end;
+
// 计算剩余天数
const timeDiff = end - currentTime;
const daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
diff --git a/resource/template/theme-server-status/network.html b/resource/template/theme-server-status/network.html
index 10295cf..6e7dfd1 100644
--- a/resource/template/theme-server-status/network.html
+++ b/resource/template/theme-server-status/network.html
@@ -11,7 +11,7 @@
- @#server.Name#@
+ @#server.Name#@
@@ -332,7 +332,7 @@
},
getServerCountryCode(id){
const result = this.servers.find(item => item.ID == id);
- return result.Host.CountryCode ? result.Host.CountryCode : 'rb';
+ return result.Host.CountryCode ? result.Host.CountryCode : 'un';
},
getNextServerId(id) {
const currentIndex = this.servers.findIndex(item => item.ID === id);
| | |