diff options
| author | Shishkevich D. <135337715+shishkevichd@users.noreply.github.com> | 2025-04-06 12:40:33 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-06 12:40:33 +0300 |
| commit | bea19a263db88fef44b4356082b199fbfcc39a25 (patch) | |
| tree | a111e9328c6273ad9721118238c40cf3004f72a9 /web | |
| parent | 878e0d02cd01a045f4f32464124c59e24f98aedd (diff) | |
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
Diffstat (limited to 'web')
| -rw-r--r-- | web/assets/js/util/index.js | 63 | ||||
| -rw-r--r-- | web/html/component/aClientTable.html (renamed from web/html/xui/component/aClientTable.html) | 52 | ||||
| -rw-r--r-- | web/html/component/aCustomStatistic.html (renamed from web/html/xui/component/aCustomStatistic.html) | 0 | ||||
| -rw-r--r-- | web/html/component/aPersianDatepicker.html (renamed from web/html/xui/component/aPersianDatepicker.html) | 2 | ||||
| -rw-r--r-- | web/html/component/aSettingListItem.html (renamed from web/html/xui/component/aSettingListItem.html) | 2 | ||||
| -rw-r--r-- | web/html/component/aSidebar.html (renamed from web/html/xui/component/aSidebar.html) | 0 | ||||
| -rw-r--r-- | web/html/component/aTableSortable.html (renamed from web/html/xui/component/aTableSortable.html) | 2 | ||||
| -rw-r--r-- | web/html/component/aThemeSwitch.html (renamed from web/html/xui/component/aThemeSwitch.html) | 4 | ||||
| -rw-r--r-- | web/html/form/allocate.html (renamed from web/html/xui/form/allocate.html) | 0 | ||||
| -rw-r--r-- | web/html/form/client.html (renamed from web/html/xui/form/client.html) | 4 | ||||
| -rw-r--r-- | web/html/form/inbound.html (renamed from web/html/xui/form/inbound.html) | 2 | ||||
| -rw-r--r-- | web/html/form/outbound.html (renamed from web/html/xui/form/outbound.html) | 18 | ||||
| -rw-r--r-- | web/html/form/protocol/dokodemo.html (renamed from web/html/xui/form/protocol/dokodemo.html) | 0 | ||||
| -rw-r--r-- | web/html/form/protocol/http.html (renamed from web/html/xui/form/protocol/http.html) | 10 | ||||
| -rw-r--r-- | web/html/form/protocol/shadowsocks.html (renamed from web/html/xui/form/protocol/shadowsocks.html) | 2 | ||||
| -rw-r--r-- | web/html/form/protocol/socks.html (renamed from web/html/xui/form/protocol/socks.html) | 10 | ||||
| -rw-r--r-- | web/html/form/protocol/trojan.html (renamed from web/html/xui/form/protocol/trojan.html) | 2 | ||||
| -rw-r--r-- | web/html/form/protocol/vless.html (renamed from web/html/xui/form/protocol/vless.html) | 4 | ||||
| -rw-r--r-- | web/html/form/protocol/vmess.html (renamed from web/html/xui/form/protocol/vmess.html) | 0 | ||||
| -rw-r--r-- | web/html/form/protocol/wireguard.html (renamed from web/html/xui/form/protocol/wireguard.html) | 4 | ||||
| -rw-r--r-- | web/html/form/reality_settings.html (renamed from web/html/xui/form/reality_settings.html) | 2 | ||||
| -rw-r--r-- | web/html/form/sniffing.html (renamed from web/html/xui/form/sniffing.html) | 0 | ||||
| -rw-r--r-- | web/html/form/stream/external_proxy.html (renamed from web/html/xui/form/stream/external_proxy.html) | 14 | ||||
| -rw-r--r-- | web/html/form/stream/stream_grpc.html (renamed from web/html/xui/form/stream/stream_grpc.html) | 0 | ||||
| -rw-r--r-- | web/html/form/stream/stream_httpupgrade.html (renamed from web/html/xui/form/stream/stream_httpupgrade.html) | 6 | ||||
| -rw-r--r-- | web/html/form/stream/stream_kcp.html (renamed from web/html/xui/form/stream/stream_kcp.html) | 2 | ||||
| -rw-r--r-- | web/html/form/stream/stream_settings.html (renamed from web/html/xui/form/stream/stream_settings.html) | 2 | ||||
| -rw-r--r-- | web/html/form/stream/stream_sockopt.html (renamed from web/html/xui/form/stream/stream_sockopt.html) | 8 | ||||
| -rw-r--r-- | web/html/form/stream/stream_tcp.html (renamed from web/html/xui/form/stream/stream_tcp.html) | 16 | ||||
| -rw-r--r-- | web/html/form/stream/stream_ws.html (renamed from web/html/xui/form/stream/stream_ws.html) | 6 | ||||
| -rw-r--r-- | web/html/form/stream/stream_xhttp.html (renamed from web/html/xui/form/stream/stream_xhttp.html) | 8 | ||||
| -rw-r--r-- | web/html/form/tls_settings.html (renamed from web/html/xui/form/tls_settings.html) | 14 | ||||
| -rw-r--r-- | web/html/inbounds.html (renamed from web/html/xui/inbounds.html) | 77 | ||||
| -rw-r--r-- | web/html/index.html (renamed from web/html/xui/index.html) | 125 | ||||
| -rw-r--r-- | web/html/login.html | 21 | ||||
| -rw-r--r-- | web/html/modals/client_bulk_modal.html (renamed from web/html/xui/modals/client_bulk_modal.html) | 2 | ||||
| -rw-r--r-- | web/html/modals/client_modal.html (renamed from web/html/xui/modals/client_modal.html) | 2 | ||||
| -rw-r--r-- | web/html/modals/dns_modal.html (renamed from web/html/xui/modals/dns_modal.html) | 2 | ||||
| -rw-r--r-- | web/html/modals/fakedns_modal.html (renamed from web/html/xui/modals/fakedns_modal.html) | 0 | ||||
| -rw-r--r-- | web/html/modals/inbound_info_modal.html (renamed from web/html/xui/modals/inbound_info_modal.html) | 16 | ||||
| -rw-r--r-- | web/html/modals/inbound_modal.html (renamed from web/html/xui/modals/inbound_modal.html) | 0 | ||||
| -rw-r--r-- | web/html/modals/prompt_modal.html (renamed from web/html/xui/modals/prompt_modal.html) | 0 | ||||
| -rw-r--r-- | web/html/modals/qrcode_modal.html (renamed from web/html/xui/modals/qrcode_modal.html) | 3 | ||||
| -rw-r--r-- | web/html/modals/text_modal.html (renamed from web/html/xui/modals/text_modal.html) | 32 | ||||
| -rw-r--r-- | web/html/modals/warp_modal.html (renamed from web/html/xui/modals/warp_modal.html) | 18 | ||||
| -rw-r--r-- | web/html/modals/xray_balancer_modal.html (renamed from web/html/xui/modals/xray_balancer_modal.html) | 0 | ||||
| -rw-r--r-- | web/html/modals/xray_outbound_modal.html (renamed from web/html/xui/modals/xray_outbound_modal.html) | 2 | ||||
| -rw-r--r-- | web/html/modals/xray_reverse_modal.html (renamed from web/html/xui/modals/xray_reverse_modal.html) | 0 | ||||
| -rw-r--r-- | web/html/modals/xray_rule_modal.html (renamed from web/html/xui/modals/xray_rule_modal.html) | 8 | ||||
| -rw-r--r-- | web/html/settings.html (renamed from web/html/xui/settings.html) | 24 | ||||
| -rw-r--r-- | web/html/settings/panel/general.html (renamed from web/html/xui/settings/panel/general.html) | 20 | ||||
| -rw-r--r-- | web/html/settings/panel/security.html (renamed from web/html/xui/settings/panel/security.html) | 10 | ||||
| -rw-r--r-- | web/html/settings/panel/subscription/general.html (renamed from web/html/xui/settings/panel/subscription/general.html) | 4 | ||||
| -rw-r--r-- | web/html/settings/panel/subscription/json.html (renamed from web/html/xui/settings/panel/subscription/json.html) | 24 | ||||
| -rw-r--r-- | web/html/settings/panel/telegram.html (renamed from web/html/xui/settings/panel/telegram.html) | 4 | ||||
| -rw-r--r-- | web/html/settings/xray/advanced.html (renamed from web/html/xui/settings/xray/advanced.html) | 4 | ||||
| -rw-r--r-- | web/html/settings/xray/balancers.html (renamed from web/html/xui/settings/xray/balancers.html) | 20 | ||||
| -rw-r--r-- | web/html/settings/xray/basics.html (renamed from web/html/xui/settings/xray/basics.html) | 54 | ||||
| -rw-r--r-- | web/html/settings/xray/dns.html (renamed from web/html/xui/settings/xray/dns.html) | 18 | ||||
| -rw-r--r-- | web/html/settings/xray/outbounds.html (renamed from web/html/xui/settings/xray/outbounds.html) | 34 | ||||
| -rw-r--r-- | web/html/settings/xray/reverse.html (renamed from web/html/xui/settings/xray/reverse.html) | 8 | ||||
| -rw-r--r-- | web/html/settings/xray/routing.html (renamed from web/html/xui/settings/xray/routing.html) | 8 | ||||
| -rw-r--r-- | web/html/xray.html (renamed from web/html/xui/xray.html) | 28 | ||||
| -rw-r--r-- | web/html/xui/component/aPasswordInput.html | 57 | ||||
| -rw-r--r-- | web/translation/translate.en_US.toml | 12 | ||||
| -rw-r--r-- | web/translation/translate.es_ES.toml | 14 | ||||
| -rw-r--r-- | web/translation/translate.fa_IR.toml | 14 | ||||
| -rw-r--r-- | web/translation/translate.id_ID.toml | 13 | ||||
| -rw-r--r-- | web/translation/translate.ja_JP.toml | 14 | ||||
| -rw-r--r-- | web/translation/translate.pt_BR.toml | 14 | ||||
| -rw-r--r-- | web/translation/translate.ru_RU.toml | 14 | ||||
| -rw-r--r-- | web/translation/translate.tr_TR.toml | 12 | ||||
| -rw-r--r-- | web/translation/translate.uk_UA.toml | 14 | ||||
| -rw-r--r-- | web/translation/translate.vi_VN.toml | 14 | ||||
| -rw-r--r-- | web/translation/translate.zh_CN.toml | 12 | ||||
| -rw-r--r-- | web/translation/translate.zh_TW.toml | 12 |
76 files changed, 570 insertions, 473 deletions
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/xui/component/aClientTable.html b/web/html/component/aClientTable.html index 2bea96e8..868112d9 100644 --- a/web/html/xui/component/aClientTable.html +++ b/web/html/component/aClientTable.html @@ -2,30 +2,30 @@ <template slot="actions" slot-scope="text, client, index"> <a-tooltip> <template slot="title">{{ i18n "qrCode" }}</template> - <a-icon style="font-size: 24px;" class="normal-icon" type="qrcode" v-if="record.hasLink()" @click="showQrcode(record.id,client);"></a-icon> + <a-icon :style="{ fontSize: '24px' }" class="normal-icon" type="qrcode" v-if="record.hasLink()" @click="showQrcode(record.id,client);"></a-icon> </a-tooltip> <a-tooltip> <template slot="title">{{ i18n "pages.client.edit" }}</template> - <a-icon style="font-size: 24px;" class="normal-icon" type="edit" @click="openEditClient(record.id,client);"></a-icon> + <a-icon :style="{ fontSize: '24px' }" class="normal-icon" type="edit" @click="openEditClient(record.id,client);"></a-icon> </a-tooltip> <a-tooltip> <template slot="title">{{ i18n "info" }}</template> - <a-icon style="font-size: 24px;" class="normal-icon" type="info-circle" @click="showInfo(record.id,client);"></a-icon> + <a-icon :style="{ fontSize: '24px' }" class="normal-icon" type="info-circle" @click="showInfo(record.id,client);"></a-icon> </a-tooltip> <a-tooltip> <template slot="title">{{ i18n "pages.inbounds.resetTraffic" }}</template> <a-popconfirm @confirm="resetClientTraffic(client,record.id,false)" title='{{ i18n "pages.inbounds.resetTrafficContent"}}' :overlay-class-name="themeSwitcher.currentTheme" ok-text='{{ i18n "reset"}}' cancel-text='{{ i18n "cancel"}}'> - <a-icon slot="icon" type="question-circle-o" :style="themeSwitcher.isDarkTheme ? 'color: var(--color-primary-100)' : 'color: var(--color-primary-100)'"></a-icon> - <a-icon style="font-size: 24px; cursor: pointer;" class="normal-icon" type="retweet" v-if="client.email.length > 0"></a-icon> + <a-icon slot="icon" type="question-circle-o" :style="{ color: 'var(--color-primary-100)'}"></a-icon> + <a-icon :style="{ fontSize: '24px', cursor: 'pointer' }" class="normal-icon" type="retweet" v-if="client.email.length > 0"></a-icon> </a-popconfirm> </a-tooltip> <a-tooltip> <template slot="title"> - <span style="color: #FF4D4F"> {{ i18n "delete"}}</span> + <span :style="{ color: '#FF4D4F' }"> {{ i18n "delete"}}</span> </template> <a-popconfirm @confirm="delClient(record.id,client,false)" title='{{ i18n "pages.inbounds.deleteClientContent"}}' :overlay-class-name="themeSwitcher.currentTheme" ok-text='{{ i18n "delete"}}' ok-type="danger" cancel-text='{{ i18n "cancel"}}'> - <a-icon slot="icon" type="question-circle-o" style="color: #e04141"></a-icon> - <a-icon style="font-size: 24px; cursor: pointer;" class="delete-icon" type="delete" v-if="isRemovable(record.id)"></a-icon> + <a-icon slot="icon" type="question-circle-o" :style="{ color: '#e04141' }"></a-icon> + <a-icon :style="{ fontSize: '24px', cursor: 'pointer' }" class="delete-icon" type="delete" v-if="isRemovable(record.id)"></a-icon> </a-popconfirm> </a-tooltip> </template> @@ -124,9 +124,9 @@ </template> </span> </template> - <a-tag style="min-width: 50px; border: none;" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag> + <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag> </a-popover> - <a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)" style="border: none;" class="infinite-tag"> + <a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)" :style="{ border: 'none' }" class="infinite-tag"> <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor"> <path d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z" fill="currentColor"></path> </svg> @@ -135,27 +135,27 @@ </template> <template slot="actionMenu" slot-scope="text, client, index"> <a-dropdown :trigger="['click']"> - <a-icon @click="e => e.preventDefault()" type="ellipsis" style="font-size: 20px;"></a-icon> + <a-icon @click="e => e.preventDefault()" type="ellipsis" :style="{ fontSize: '20px' }"></a-icon> <a-menu slot="overlay" :theme="themeSwitcher.currentTheme"> <a-menu-item v-if="record.hasLink()" @click="showQrcode(record.id,client);"> - <a-icon style="font-size: 14px;" type="qrcode"></a-icon> + <a-icon :style="{ fontSize: '14px' }" type="qrcode"></a-icon> {{ i18n "qrCode" }} </a-menu-item> <a-menu-item @click="openEditClient(record.id,client);"> - <a-icon style="font-size: 14px;" type="edit"></a-icon> + <a-icon :style="{ fontSize: '14px' }" type="edit"></a-icon> {{ i18n "pages.client.edit" }} </a-menu-item> <a-menu-item @click="showInfo(record.id,client);"> - <a-icon style="font-size: 14px;" type="info-circle"></a-icon> + <a-icon :style="{ fontSize: '14px' }" type="info-circle"></a-icon> {{ i18n "info" }} </a-menu-item> <a-menu-item @click="resetClientTraffic(client,record.id)" v-if="client.email.length > 0"> - <a-icon style="font-size: 14px;" type="retweet"></a-icon> + <a-icon :style="{ fontSize: '14px' }" type="retweet"></a-icon> {{ i18n "pages.inbounds.resetTraffic" }} </a-menu-item> <a-menu-item v-if="isRemovable(record.id)" @click="delClient(record.id,client)"> - <a-icon style="font-size: 14px;" type="delete"></a-icon> - <span style="color: #FF4D4F"> {{ i18n "delete"}}</span> + <a-icon :style="{ fontSize: '14px' }" type="delete"></a-icon> + <span :style="{ color: '#FF4D4F' }"> {{ i18n "delete"}}</span> </a-menu-item> <a-menu-item> <a-switch v-model="client.enable" size="small" @change="switchEnableClient(record.id,client)"></a-switch> @@ -169,10 +169,10 @@ <template slot="content"> <table> <tr> - <td colspan="3" style="text-align: center;">{{ i18n "pages.inbounds.traffic" }}</td> + <td colspan="3" :style="{ textAlign: 'center' }">{{ i18n "pages.inbounds.traffic" }}</td> </tr> <tr> - <td width="80px" style="margin:0; text-align: right;font-size: 1em;"> [[ SizeFormatter.sizeFormat(getUpStats(record, client.email) + getDownStats(record, client.email)) ]] </td> + <td width="80
|
