diff --git a/web/assets/js/model/models.js b/web/assets/js/model/models.js
index 122145fb..dd602c46 100644
--- a/web/assets/js/model/models.js
+++ b/web/assets/js/model/models.js
@@ -141,6 +141,19 @@ class DBInbound {
return Inbound.fromJson(config);
}
+ isMultiUser() {
+ switch (this.protocol) {
+ case Protocols.VMESS:
+ case Protocols.VLESS:
+ case Protocols.TROJAN:
+ return true;
+ case Protocols.SHADOWSOCKS:
+ return this.toInbound().isSSMultiUser;
+ default:
+ return false;
+ }
+ }
+
hasLink() {
switch (this.protocol) {
case Protocols.VMESS:
diff --git a/web/assets/js/util/common.js b/web/assets/js/util/common.js
index 8e30bce7..b2f15fb2 100644
--- a/web/assets/js/util/common.js
+++ b/web/assets/js/util/common.js
@@ -52,13 +52,15 @@ function safeBase64(str) {
function formatSecond(second) {
if (second < 60) {
- return second.toFixed(0) + ' s';
+ return second.toFixed(0) + 's';
} else if (second < 3600) {
- return (second / 60).toFixed(0) + ' m';
+ return (second / 60).toFixed(0) + 'm';
} else if (second < 3600 * 24) {
- return (second / 3600).toFixed(0) + ' h';
+ return (second / 3600).toFixed(0) + 'h';
} else {
- return (second / 3600 / 24).toFixed(0) + ' d';
+ day = Math.floor(second / 3600 / 24);
+ remain = ((second/3600) - (day*24)).toFixed(0);
+ return day + 'd' + (remain > 0 ? ' ' + remain + 'h' : '');
}
}
@@ -72,7 +74,7 @@ function addZero(num) {
function toFixed(num, n) {
n = Math.pow(10, n);
- return Math.round(num * n) / n;
+ return Math.floor(num * n) / n;
}
function debounce(fn, delay) {
@@ -115,15 +117,39 @@ function setCookie(cname, cvalue, exdays) {
function usageColor(data, threshold, total) {
switch (true) {
case data === null:
- return 'blue';
- case total <= 0:
- return 'blue';
+ return "green";
+ case total < 0:
+ return "blue";
+ case total == 0:
+ return "purple";
case data < total - threshold:
- return 'cyan';
+ return "blue";
case data < total:
- return 'orange';
+ return "orange";
default:
- return 'red';
+ return "red";
+ }
+}
+
+function userExpiryColor(threshold, client, isDark = false) {
+ if (!client.enable) {
+ return isDark ? '#2c3950' : '#bcbcbc';
+ }
+ now = new Date().getTime(),
+ expiry = client.expiryTime;
+ switch (true) {
+ case expiry === null:
+ return "#389e0d";
+ case expiry < 0:
+ return "#0e49b5";
+ case expiry == 0:
+ return "#7a316f";
+ case now < expiry - threshold:
+ return "#0e49b5";
+ case now < expiry:
+ return "#ffa031";
+ default:
+ return "#e04141";
}
}
diff --git a/web/html/common/prompt_modal.html b/web/html/common/prompt_modal.html
index 17a65ec1..a61b4454 100644
--- a/web/html/common/prompt_modal.html
+++ b/web/html/common/prompt_modal.html
@@ -2,7 +2,7 @@