From 729d8549e2b536a10c402a88e0d4cfde9e4baf3f Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Mon, 4 Dec 2023 19:17:38 +0100 Subject: [PATCH] new frontend and mobile view #1286 --- web/assets/js/model/models.js | 13 + web/assets/js/util/common.js | 48 +- web/html/common/prompt_modal.html | 2 +- web/html/common/qrcode_modal.html | 4 +- web/html/common/text_modal.html | 2 +- web/html/xui/client_bulk_modal.html | 8 +- web/html/xui/client_modal.html | 7 +- web/html/xui/common_sider.html | 10 +- web/html/xui/component/password.html | 4 +- web/html/xui/component/themeSwitch.html | 26 +- web/html/xui/form/client.html | 29 +- web/html/xui/form/inbound.html | 4 +- web/html/xui/form/protocol/dokodemo.html | 2 +- web/html/xui/form/protocol/shadowsocks.html | 93 +- web/html/xui/form/protocol/trojan.html | 99 +- web/html/xui/form/protocol/vless.html | 104 +- web/html/xui/form/protocol/vmess.html | 90 +- web/html/xui/form/stream/stream_kcp.html | 2 +- web/html/xui/form/stream/stream_quic.html | 4 +- web/html/xui/form/stream/stream_settings.html | 2 +- web/html/xui/form/stream/stream_sockopt.html | 2 +- web/html/xui/form/tls_settings.html | 29 +- web/html/xui/inbound_client_table.html | 248 ++++- web/html/xui/inbound_info_modal.html | 4 +- web/html/xui/inbound_modal.html | 2 +- web/html/xui/inbounds.html | 474 ++++++--- web/html/xui/index.html | 73 +- web/html/xui/settings.html | 825 +--------------- web/html/xui/xray.html | 911 ++++++++++++++++++ 29 files changed, 1698 insertions(+), 1423 deletions(-) create mode 100644 web/html/xui/xray.html 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 @@ + :ok-text="promptModal.okText" cancel-text='{{ i18n "cancel" }}' :class="themeSwitcher.currentTheme"> @@ -13,7 +13,7 @@ {{ i18n "pages.inbounds.client" }} diff --git a/web/html/common/text_modal.html b/web/html/common/text_modal.html index 1514051b..2b455ae4 100644 --- a/web/html/common/text_modal.html +++ b/web/html/common/text_modal.html @@ -1,7 +1,7 @@ {{define "textModal"}} - + Random Random+Prefix Random+Prefix+Num @@ -72,13 +72,13 @@
- + {{ i18n "none" }} [[ key ]] - + {{ i18n "none" }} [[ key ]] diff --git a/web/html/xui/client_modal.html b/web/html/xui/client_modal.html index e7c23098..b2c03129 100644 --- a/web/html/xui/client_modal.html +++ b/web/html/xui/client_modal.html @@ -1,8 +1,11 @@ {{define "clientsModal"}} + {{template "form/client"}} diff --git a/web/html/xui/xray.html b/web/html/xui/xray.html new file mode 100644 index 00000000..db5aa202 --- /dev/null +++ b/web/html/xui/xray.html @@ -0,0 +1,911 @@ + + +{{template "head" .}} + + + + {{ template "commonSider" . }} + + + + + + + + + {{ i18n "pages.settings.save" }} + {{ i18n "pages.settings.restartPanel" }} + + + + + + + + + + + {{ i18n "pages.settings.resetDefaultConfig" }} + + + + +

+ + {{ i18n "pages.settings.templates.generalConfigsDesc" }} +

+
+ + + + + + + + + + + + + + + + + + + +
+ + +

+ + {{ i18n "pages.settings.templates.blockConfigsDesc" }} +

+
+ + + + + +
+ + +

+ + {{ i18n "pages.settings.templates.blockCountryConfigsDesc" }} +

+
+ + + + + + +
+ + +

+ + {{ i18n "pages.settings.templates.directCountryConfigsDesc" }} +

+
+ + + + + + +
+ + +

+ + {{ i18n "pages.settings.templates.ipv4ConfigsDesc" }} +

+
+ + +
+ + +

+ + {{ i18n "pages.settings.templates.warpConfigsDesc" }} +

+
+ + + + +
+
+
+ + +

+ + {{ i18n "pages.settings.templates.manualListsDesc" }} +

+
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
+
+
+
+
+{{template "js" .}} +{{template "component/themeSwitcher" .}} +{{template "component/setting"}} + + + \ No newline at end of file