From bea19a263db88fef44b4356082b199fbfcc39a25 Mon Sep 17 00:00:00 2001 From: "Shishkevich D." <135337715+shishkevichd@users.noreply.github.com> Date: Sun, 6 Apr 2025 16:40:33 +0700 Subject: Code refactoring (#2865) * refactor: use vue inline styles in entire application * refactor: setting row in dashboard page * refactor: use blob for download file in text modal * refactor: move all html templates in `web/html` folder * refactor: `DeviceUtils` -> `MediaQueryMixin` The transition to mixins has been made, as they can update themselves. * chore: pretty right buttons in `outbounds` tab in xray settings * refactor: add translations for system status * refactor: adjust gutter spacing in setting list item * refactor: use native `a-input-password` for password field * chore: return old system status with new translations * chore: add missing translation --- web/assets/js/util/index.js | 63 +- web/html/component/aClientTable.html | 267 ++++ web/html/component/aCustomStatistic.html | 42 + web/html/component/aPersianDatepicker.html | 72 + web/html/component/aSettingListItem.html | 49 + web/html/component/aSidebar.html | 103 ++ web/html/component/aTableSortable.html | 232 +++ web/html/component/aThemeSwitch.html | 119 ++ web/html/form/allocate.html | 15 + web/html/form/client.html | 172 +++ web/html/form/inbound.html | 133 ++ web/html/form/outbound.html | 517 +++++++ web/html/form/protocol/dokodemo.html | 20 + web/html/form/protocol/http.html | 26 + web/html/form/protocol/shadowsocks.html | 50 + web/html/form/protocol/socks.html | 34 + web/html/form/protocol/trojan.html | 50 + web/html/form/protocol/vless.html | 50 + web/html/form/protocol/vmess.html | 23 + web/html/form/protocol/wireguard.html | 76 + web/html/form/reality_settings.html | 56 + web/html/form/sniffing.html | 29 + web/html/form/stream/external_proxy.html | 29 + web/html/form/stream/stream_grpc.html | 13 + web/html/form/stream/stream_httpupgrade.html | 26 + web/html/form/stream/stream_kcp.html | 48 + web/html/form/stream/stream_settings.html | 51 + web/html/form/stream/stream_sockopt.html | 66 + web/html/form/stream/stream_tcp.html | 72 + web/html/form/stream/stream_ws.html | 29 + web/html/form/stream/stream_xhttp.html | 46 + web/html/form/tls_settings.html | 116 ++ web/html/inbounds.html | 1530 +++++++++++++++++++ web/html/index.html | 752 ++++++++++ web/html/login.html | 21 +- web/html/modals/client_bulk_modal.html | 250 ++++ web/html/modals/client_modal.html | 172 +++ web/html/modals/dns_modal.html | 114 ++ web/html/modals/fakedns_modal.html | 57 + web/html/modals/inbound_info_modal.html | 572 ++++++++ web/html/modals/inbound_modal.html | 144 ++ web/html/modals/prompt_modal.html | 71 + web/html/modals/qrcode_modal.html | 162 +++ web/html/modals/text_modal.html | 62 + web/html/modals/warp_modal.html | 246 ++++ web/html/modals/xray_balancer_modal.html | 123 ++ web/html/modals/xray_outbound_modal.html | 127 ++ web/html/modals/xray_reverse_modal.html | 138 ++ web/html/modals/xray_rule_modal.html | 246 ++++ web/html/settings.html | 542 +++++++ web/html/settings/panel/general.html | 149 ++ web/html/settings/panel/security.html | 60 + web/html/settings/panel/subscription/general.html | 98 ++ web/html/settings/panel/subscription/json.html | 180 +++ web/html/settings/panel/telegram.html | 87 ++ web/html/settings/xray/advanced.html | 14 + web/html/settings/xray/balancers.html | 53 + web/html/settings/xray/basics.html | 275 ++++ web/html/settings/xray/dns.html | 149 ++ web/html/settings/xray/outbounds.html | 74 + web/html/settings/xray/reverse.html | 38 + web/html/settings/xray/routing.html | 119 ++ web/html/xray.html | 1450 ++++++++++++++++++ web/html/xui/component/aClientTable.html | 267 ---- web/html/xui/component/aCustomStatistic.html | 42 - web/html/xui/component/aPasswordInput.html | 57 - web/html/xui/component/aPersianDatepicker.html | 72 - web/html/xui/component/aSettingListItem.html | 49 - web/html/xui/component/aSidebar.html | 103 -- web/html/xui/component/aTableSortable.html | 232 --- web/html/xui/component/aThemeSwitch.html | 119 -- web/html/xui/form/allocate.html | 15 - web/html/xui/form/client.html | 172 --- web/html/xui/form/inbound.html | 133 -- web/html/xui/form/outbound.html | 517 ------- web/html/xui/form/protocol/dokodemo.html | 20 - web/html/xui/form/protocol/http.html | 26 - web/html/xui/form/protocol/shadowsocks.html | 50 - web/html/xui/form/protocol/socks.html | 34 - web/html/xui/form/protocol/trojan.html | 50 - web/html/xui/form/protocol/vless.html | 50 - web/html/xui/form/protocol/vmess.html | 23 - web/html/xui/form/protocol/wireguard.html | 76 - web/html/xui/form/reality_settings.html | 56 - web/html/xui/form/sniffing.html | 29 - web/html/xui/form/stream/external_proxy.html | 29 - web/html/xui/form/stream/stream_grpc.html | 13 - web/html/xui/form/stream/stream_httpupgrade.html | 26 - web/html/xui/form/stream/stream_kcp.html | 48 - web/html/xui/form/stream/stream_settings.html | 51 - web/html/xui/form/stream/stream_sockopt.html | 66 - web/html/xui/form/stream/stream_tcp.html | 72 - web/html/xui/form/stream/stream_ws.html | 29 - web/html/xui/form/stream/stream_xhttp.html | 46 - web/html/xui/form/tls_settings.html | 116 -- web/html/xui/inbounds.html | 1535 -------------------- web/html/xui/index.html | 743 ---------- web/html/xui/modals/client_bulk_modal.html | 250 ---- web/html/xui/modals/client_modal.html | 172 --- web/html/xui/modals/dns_modal.html | 114 -- web/html/xui/modals/fakedns_modal.html | 57 - web/html/xui/modals/inbound_info_modal.html | 572 -------- web/html/xui/modals/inbound_modal.html | 144 -- web/html/xui/modals/prompt_modal.html | 71 - web/html/xui/modals/qrcode_modal.html | 161 -- web/html/xui/modals/text_modal.html | 52 - web/html/xui/modals/warp_modal.html | 246 ---- web/html/xui/modals/xray_balancer_modal.html | 123 -- web/html/xui/modals/xray_outbound_modal.html | 127 -- web/html/xui/modals/xray_reverse_modal.html | 138 -- web/html/xui/modals/xray_rule_modal.html | 246 ---- web/html/xui/settings.html | 540 ------- web/html/xui/settings/panel/general.html | 149 -- web/html/xui/settings/panel/security.html | 60 - .../xui/settings/panel/subscription/general.html | 98 -- web/html/xui/settings/panel/subscription/json.html | 180 --- web/html/xui/settings/panel/telegram.html | 87 -- web/html/xui/settings/xray/advanced.html | 14 - web/html/xui/settings/xray/balancers.html | 53 - web/html/xui/settings/xray/basics.html | 275 ---- web/html/xui/settings/xray/dns.html | 149 -- web/html/xui/settings/xray/outbounds.html | 72 - web/html/xui/settings/xray/reverse.html | 38 - web/html/xui/settings/xray/routing.html | 119 -- web/html/xui/xray.html | 1450 ------------------ web/translation/translate.en_US.toml | 12 +- web/translation/translate.es_ES.toml | 14 +- web/translation/translate.fa_IR.toml | 14 +- web/translation/translate.id_ID.toml | 13 +- web/translation/translate.ja_JP.toml | 14 +- web/translation/translate.pt_BR.toml | 14 +- web/translation/translate.ru_RU.toml | 14 +- web/translation/translate.tr_TR.toml | 12 +- web/translation/translate.uk_UA.toml | 14 +- web/translation/translate.vi_VN.toml | 14 +- web/translation/translate.zh_CN.toml | 12 +- web/translation/translate.zh_TW.toml | 12 +- 137 files changed, 10874 insertions(+), 10777 deletions(-) create mode 100644 web/html/component/aClientTable.html create mode 100644 web/html/component/aCustomStatistic.html create mode 100644 web/html/component/aPersianDatepicker.html create mode 100644 web/html/component/aSettingListItem.html create mode 100644 web/html/component/aSidebar.html create mode 100644 web/html/component/aTableSortable.html create mode 100644 web/html/component/aThemeSwitch.html create mode 100644 web/html/form/allocate.html create mode 100644 web/html/form/client.html create mode 100644 web/html/form/inbound.html create mode 100644 web/html/form/outbound.html create mode 100644 web/html/form/protocol/dokodemo.html create mode 100644 web/html/form/protocol/http.html create mode 100644 web/html/form/protocol/shadowsocks.html create mode 100644 web/html/form/protocol/socks.html create mode 100644 web/html/form/protocol/trojan.html create mode 100644 web/html/form/protocol/vless.html create mode 100644 web/html/form/protocol/vmess.html create mode 100644 web/html/form/protocol/wireguard.html create mode 100644 web/html/form/reality_settings.html create mode 100644 web/html/form/sniffing.html create mode 100644 web/html/form/stream/external_proxy.html create mode 100644 web/html/form/stream/stream_grpc.html create mode 100644 web/html/form/stream/stream_httpupgrade.html create mode 100644 web/html/form/stream/stream_kcp.html create mode 100644 web/html/form/stream/stream_settings.html create mode 100644 web/html/form/stream/stream_sockopt.html create mode 100644 web/html/form/stream/stream_tcp.html create mode 100644 web/html/form/stream/stream_ws.html create mode 100644 web/html/form/stream/stream_xhttp.html create mode 100644 web/html/form/tls_settings.html create mode 100644 web/html/inbounds.html create mode 100644 web/html/index.html create mode 100644 web/html/modals/client_bulk_modal.html create mode 100644 web/html/modals/client_modal.html create mode 100644 web/html/modals/dns_modal.html create mode 100644 web/html/modals/fakedns_modal.html create mode 100644 web/html/modals/inbound_info_modal.html create mode 100644 web/html/modals/inbound_modal.html create mode 100644 web/html/modals/prompt_modal.html create mode 100644 web/html/modals/qrcode_modal.html create mode 100644 web/html/modals/text_modal.html create mode 100644 web/html/modals/warp_modal.html create mode 100644 web/html/modals/xray_balancer_modal.html create mode 100644 web/html/modals/xray_outbound_modal.html create mode 100644 web/html/modals/xray_reverse_modal.html create mode 100644 web/html/modals/xray_rule_modal.html create mode 100644 web/html/settings.html create mode 100644 web/html/settings/panel/general.html create mode 100644 web/html/settings/panel/security.html create mode 100644 web/html/settings/panel/subscription/general.html create mode 100644 web/html/settings/panel/subscription/json.html create mode 100644 web/html/settings/panel/telegram.html create mode 100644 web/html/settings/xray/advanced.html create mode 100644 web/html/settings/xray/balancers.html create mode 100644 web/html/settings/xray/basics.html create mode 100644 web/html/settings/xray/dns.html create mode 100644 web/html/settings/xray/outbounds.html create mode 100644 web/html/settings/xray/reverse.html create mode 100644 web/html/settings/xray/routing.html create mode 100644 web/html/xray.html delete mode 100644 web/html/xui/component/aClientTable.html delete mode 100644 web/html/xui/component/aCustomStatistic.html delete mode 100644 web/html/xui/component/aPasswordInput.html delete mode 100644 web/html/xui/component/aPersianDatepicker.html delete mode 100644 web/html/xui/component/aSettingListItem.html delete mode 100644 web/html/xui/component/aSidebar.html delete mode 100644 web/html/xui/component/aTableSortable.html delete mode 100644 web/html/xui/component/aThemeSwitch.html delete mode 100644 web/html/xui/form/allocate.html delete mode 100644 web/html/xui/form/client.html delete mode 100644 web/html/xui/form/inbound.html delete mode 100644 web/html/xui/form/outbound.html delete mode 100644 web/html/xui/form/protocol/dokodemo.html delete mode 100644 web/html/xui/form/protocol/http.html delete mode 100644 web/html/xui/form/protocol/shadowsocks.html delete mode 100644 web/html/xui/form/protocol/socks.html delete mode 100644 web/html/xui/form/protocol/trojan.html delete mode 100644 web/html/xui/form/protocol/vless.html delete mode 100644 web/html/xui/form/protocol/vmess.html delete mode 100644 web/html/xui/form/protocol/wireguard.html delete mode 100644 web/html/xui/form/reality_settings.html delete mode 100644 web/html/xui/form/sniffing.html delete mode 100644 web/html/xui/form/stream/external_proxy.html delete mode 100644 web/html/xui/form/stream/stream_grpc.html delete mode 100644 web/html/xui/form/stream/stream_httpupgrade.html delete mode 100644 web/html/xui/form/stream/stream_kcp.html delete mode 100644 web/html/xui/form/stream/stream_settings.html delete mode 100644 web/html/xui/form/stream/stream_sockopt.html delete mode 100644 web/html/xui/form/stream/stream_tcp.html delete mode 100644 web/html/xui/form/stream/stream_ws.html delete mode 100644 web/html/xui/form/stream/stream_xhttp.html delete mode 100644 web/html/xui/form/tls_settings.html delete mode 100644 web/html/xui/inbounds.html delete mode 100644 web/html/xui/index.html delete mode 100644 web/html/xui/modals/client_bulk_modal.html delete mode 100644 web/html/xui/modals/client_modal.html delete mode 100644 web/html/xui/modals/dns_modal.html delete mode 100644 web/html/xui/modals/fakedns_modal.html delete mode 100644 web/html/xui/modals/inbound_info_modal.html delete mode 100644 web/html/xui/modals/inbound_modal.html delete mode 100644 web/html/xui/modals/prompt_modal.html delete mode 100644 web/html/xui/modals/qrcode_modal.html delete mode 100644 web/html/xui/modals/text_modal.html delete mode 100644 web/html/xui/modals/warp_modal.html delete mode 100644 web/html/xui/modals/xray_balancer_modal.html delete mode 100644 web/html/xui/modals/xray_outbound_modal.html delete mode 100644 web/html/xui/modals/xray_reverse_modal.html delete mode 100644 web/html/xui/modals/xray_rule_modal.html delete mode 100644 web/html/xui/settings.html delete mode 100644 web/html/xui/settings/panel/general.html delete mode 100644 web/html/xui/settings/panel/security.html delete mode 100644 web/html/xui/settings/panel/subscription/general.html delete mode 100644 web/html/xui/settings/panel/subscription/json.html delete mode 100644 web/html/xui/settings/panel/telegram.html delete mode 100644 web/html/xui/settings/xray/advanced.html delete mode 100644 web/html/xui/settings/xray/balancers.html delete mode 100644 web/html/xui/settings/xray/basics.html delete mode 100644 web/html/xui/settings/xray/dns.html delete mode 100644 web/html/xui/settings/xray/outbounds.html delete mode 100644 web/html/xui/settings/xray/reverse.html delete mode 100644 web/html/xui/settings/xray/routing.html delete mode 100644 web/html/xui/xray.html (limited to 'web') diff --git a/web/assets/js/util/index.js b/web/assets/js/util/index.js index 625af8b9..93416abe 100644 --- a/web/assets/js/util/index.js +++ b/web/assets/js/util/index.js @@ -83,7 +83,7 @@ class PromiseUtil { class RandomUtil { static getSeq({ type = "default", hasNumbers = true, hasLowercase = true, hasUppercase = true } = {}) { let seq = ''; - + switch (type) { case "hex": seq += "0123456789abcdef"; @@ -488,7 +488,7 @@ class ClipboardManager { return new Promise((resolve) => { try { const textarea = window.document.createElement('textarea'); - + textarea.style.fontSize = '12pt'; textarea.style.border = '0'; textarea.style.padding = '0'; @@ -498,14 +498,14 @@ class ClipboardManager { textarea.style.top = `${window.pageYOffset || document.documentElement.scrollTop}px`; textarea.setAttribute('readonly', ''); textarea.value = content; - + window.document.body.appendChild(textarea); - + textarea.select(); window.document.execCommand("copy"); - + window.document.body.removeChild(textarea); - + resolve(true) } catch { resolve(false) @@ -558,7 +558,7 @@ class CPUFormatter { static cpuSpeedFormat(speed) { return speed > 1000 ? (speed / 1000).toFixed(2) + " GHz" : speed.toFixed(2) + " MHz"; } - + static cpuCoreFormat(cores) { return cores === 1 ? "1 Core" : cores + " Cores"; } @@ -579,7 +579,7 @@ class NumberFormatter { static addZero(num) { return num < 10 ? "0" + num : num; } - + static toFixed(num, n) { n = Math.pow(10, n); return Math.floor(num * n) / n; @@ -610,7 +610,7 @@ class CookieManager { } return ''; } - + static setCookie(cname, cvalue, exdays) { const d = new Date(); d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000); @@ -630,7 +630,7 @@ class ColorUtils { default: return "red"; } } - + static clientUsageColor(clientStats, trafficDiff) { switch (true) { case !clientStats || clientStats.total == 0: return "#7a316f"; @@ -639,7 +639,7 @@ class ColorUtils { default: return "#cf3c3c"; } } - + static userExpiryColor(threshold, client, isDark = false) { if (!client.enable) return isDark ? '#2c3950' : '#bcbcbc'; let now = new Date().getTime(), expiry = client.expiryTime; @@ -665,7 +665,7 @@ class URLBuilder { if (!host || host.length === 0) host = window.location.hostname; if (!port || port.length === 0) port = window.location.port; if (isTLS === undefined) isTLS = window.location.protocol === "https:"; - + const protocol = isTLS ? "https:" : "http:"; port = String(port); if (port === "" || (isTLS && port === "443") || (!isTLS && port === "80")) { @@ -673,7 +673,7 @@ class URLBuilder { } else { port = `:${port}`; } - + return `${protocol}//${host}${port}${base}${path}`; } } @@ -744,11 +744,11 @@ class LanguageManager { static getLanguage() { let lang = CookieManager.getCookie("lang"); - + if (!lang) { if (window.navigator) { lang = window.navigator.language || window.navigator.userLanguage; - + if (LanguageManager.isSupportLanguage(lang)) { CookieManager.setCookie("lang", lang, 150); } else { @@ -760,30 +760,43 @@ class LanguageManager { window.location.reload(); } } - + return lang; } - + static setLanguage(language) { if (!LanguageManager.isSupportLanguage(language)) { language = "en-US"; } - + CookieManager.setCookie("lang", language, 150); window.location.reload(); } - + static isSupportLanguage(language) { const languageFilter = LanguageManager.supportedLanguages.filter((lang) => { return lang.value === language }) - + return languageFilter.length > 0; - } + } } -class DeviceUtils { - static isMobile() { - return window.innerWidth <= 768; - } +const MediaQueryMixin = { + data() { + return { + isMobile: window.innerWidth <= 768, + }; + }, + methods: { + updateDeviceType() { + this.isMobile = window.innerWidth <= 768; + }, + }, + mounted() { + window.addEventListener('resize', this.updateDeviceType); + }, + beforeDestroy() { + window.removeEventListener('resize', this.updateDeviceType); + }, } \ No newline at end of file diff --git a/web/html/component/aClientTable.html b/web/html/component/aClientTable.html new file mode 100644 index 00000000..868112d9 --- /dev/null +++ b/web/html/component/aClientTable.html @@ -0,0 +1,267 @@ +{{define "component/aClientTable"}} + + + + + + + + +{{end}} diff --git a/web/html/component/aCustomStatistic.html b/web/html/component/aCustomStatistic.html new file mode 100644 index 00000000..0bff128d --- /dev/null +++ b/web/html/component/aCustomStatistic.html @@ -0,0 +1,42 @@ +{{define "component/customStatistic"}} + +{{end}} + +{{define "component/aCustomStatistic"}} + + + +{{end}} \ No newline at end of file diff --git a/web/html/component/aPersianDatepicker.html b/web/html/component/aPersianDatepicker.html new file mode 100644 index 00000000..ebd85a08 --- /dev/null +++ b/web/html/component/aPersianDatepicker.html @@ -0,0 +1,72 @@ +{{define "component/persianDatepickerTemplate"}} + +{{end}} + +{{define "component/aPersianDatepicker"}} + + + + +{{end}} \ No newline at end of file diff --git a/web/html/component/aSettingListItem.html b/web/html/component/aSettingListItem.html new file mode 100644 index 00000000..27a7abac --- /dev/null +++ b/web/html/component/aSettingListItem.html @@ -0,0 +1,49 @@ +{{define "component/settingListItem"}} + + + + + + + + + + + + + +{{end}} + +{{define "component/aSettingListItem"}} + +{{end}} diff --git a/web/html/component/aSidebar.html b/web/html/component/aSidebar.html new file mode 100644 index 00000000..dfaebb17 --- /dev/null +++ b/web/html/component/aSidebar.html @@ -0,0 +1,103 @@ +{{define "component/sidebar/content"}} + +{{end}} + +{{define "component/aSidebar"}} + + + +{{end}} \ No newline at end of file diff --git a/web/html/component/aTableSortable.html b/web/html/component/aTableSortable.html new file mode 100644 index 00000000..443ac50c --- /dev/null +++ b/web/html/component/aTableSortable.html @@ -0,0 +1,232 @@ +{{define "component/sortableTableTrigger"}} + +{{end}} + +{{define "component/aTableSortable"}} + + +{{end}} \ No newline at end of file diff --git a/web/html/component/aThemeSwitch.html b/web/html/component/aThemeSwitch.html new file mode 100644 index 00000000..ccc17714 --- /dev/null +++ b/web/html/component/aThemeSwitch.html @@ -0,0 +1,119 @@ +{{define "component/themeSwitchTemplate"}} + +{{end}} + +{{define "component/themeSwitchTemplateLogin"}} + +{{end}} + +{{define "component/aThemeSwitch"}} + +{{end}} \ No newline at end of file diff --git a/web/html/form/allocate.html b/web/html/form/allocate.html new file mode 100644 index 00000000..aba8d5c9 --- /dev/null +++ b/web/html/form/allocate.html @@ -0,0 +1,15 @@ +{{define "form/allocate"}} + + + + [[ s ]] + + + + + + + + + +{{end}} diff --git a/web/html/form/client.html b/web/html/form/client.html new file mode 100644 index 00000000..c67f1470 --- /dev/null +++ b/web/html/form/client.html @@ -0,0 +1,172 @@ +{{define "form/client"}} + + + + + + + + + + + + + + + + + + + [[ key ]] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +