From d137deccfa49fdd202dc7ce5147ad71d450c3134 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Mon, 8 May 2023 18:04:12 +0430 Subject: [PATCH 01/12] fix style height when rotating + move cookie util to their specific file --- web/assets/css/custom.css | 20 +++++++- web/assets/js/axios-init.js | 4 +- web/assets/js/langs.js | 84 ++++++++++++--------------------- web/assets/js/util/common.js | 41 ++++++++++++---- web/assets/js/util/date-util.js | 5 +- web/assets/js/util/utils.js | 15 ++---- 6 files changed, 89 insertions(+), 80 deletions(-) diff --git a/web/assets/css/custom.css b/web/assets/css/custom.css index 718e87f8..728619e0 100644 --- a/web/assets/css/custom.css +++ b/web/assets/css/custom.css @@ -1,5 +1,23 @@ -#app { +html, +body { height: 100vh; + width: 100vw; + margin: 0; + padding: 0; + overflow: hidden; +} + +#app { + height: 100%; + min-height: 100vh; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + margin: 0; + padding: 0; + overflow: auto; } .ant-space { diff --git a/web/assets/js/axios-init.js b/web/assets/js/axios-init.js index bd55c3cf..b864b714 100644 --- a/web/assets/js/axios-init.js +++ b/web/assets/js/axios-init.js @@ -2,7 +2,7 @@ axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; axios.interceptors.request.use( - config => { + (config) => { if (config.data instanceof FormData) { config.headers['Content-Type'] = 'multipart/form-data'; } else { @@ -12,5 +12,5 @@ axios.interceptors.request.use( } return config; }, - error => Promise.reject(error) + (error) => Promise.reject(error), ); diff --git a/web/assets/js/langs.js b/web/assets/js/langs.js index e83b05f3..9e1f0911 100644 --- a/web/assets/js/langs.js +++ b/web/assets/js/langs.js @@ -1,41 +1,41 @@ const supportLangs = [ { - name : "English", - value : "en-US", - icon : "đŸ‡ē🇸" + name: 'English', + value: 'en-US', + icon: 'đŸ‡ē🇸', }, { - name : "Farsi", - value : "fa_IR", - icon : "🇮🇷" + name: 'Farsi', + value: 'fa_IR', + icon: '🇮🇷', }, { - name : "æą‰č¯­", - value : "zh-Hans", - icon : "đŸ‡¨đŸ‡ŗ" + name: 'æą‰č¯­', + value: 'zh-Hans', + icon: 'đŸ‡¨đŸ‡ŗ', }, { - name : "Russian", - value : "ru_RU", - icon : "🇷đŸ‡ē" + name: 'Russian', + value: 'ru_RU', + icon: '🇷đŸ‡ē', }, -] +]; -function getLang(){ - let lang = getCookie('lang') +function getLang() { + let lang = getCookie('lang'); - if (! lang){ - if (window.navigator){ + if (!lang) { + if (window.navigator) { lang = window.navigator.language || window.navigator.userLanguage; - if (isSupportLang(lang)){ - setCookie('lang' , lang , 150) - }else{ - setCookie('lang' , 'en-US' , 150) + if (isSupportLang(lang)) { + setCookie('lang', lang, 150); + } else { + setCookie('lang', 'en-US', 150); window.location.reload(); } - }else{ - setCookie('lang' , 'en-US' , 150) + } else { + setCookie('lang', 'en-US', 150); window.location.reload(); } } @@ -43,47 +43,21 @@ function getLang(){ return lang; } -function setLang(lang){ - - if (!isSupportLang(lang)){ +function setLang(lang) { + if (!isSupportLang(lang)) { lang = 'en-US'; } - setCookie('lang' , lang , 150) + setCookie('lang', lang, 150); window.location.reload(); } -function isSupportLang(lang){ - for (l of supportLangs){ - if (l.value === lang){ +function isSupportLang(lang) { + for (l of supportLangs) { + if (l.value === lang) { return true; } } return false; } - - - -function getCookie(cname) { - let name = cname + "="; - let decodedCookie = decodeURIComponent(document.cookie); - let ca = decodedCookie.split(';'); - for(let i = 0; i { setTimeout(resolve, timeout) }); } - } const seq = [ @@ -95,7 +93,6 @@ const shortIdSeq = [ ]; class RandomUtil { - static randomIntRange(min, max) { return parseInt(Math.random() * (max - min) + min, 10); } @@ -153,8 +150,8 @@ class RandomUtil { static randomText() { var chars = 'abcdefghijklmnopqrstuvwxyz1234567890'; var string = ''; - var len = 6 + Math.floor(Math.random() * 5) - for(var ii=0; ii Date: Mon, 8 May 2023 18:15:08 +0430 Subject: [PATCH 02/12] create theme-switch component --- web/html/xui/component/themeSwitch.html | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 web/html/xui/component/themeSwitch.html diff --git a/web/html/xui/component/themeSwitch.html b/web/html/xui/component/themeSwitch.html new file mode 100644 index 00000000..1966d079 --- /dev/null +++ b/web/html/xui/component/themeSwitch.html @@ -0,0 +1,58 @@ +{{define "component/themeSwitchTemplate"}} + +{{end}} + +{{define "component/themeSwitcher"}} + +{{end}} \ No newline at end of file From 7d0c3b6517e6c9b8367e63400c83789c7ddab93f Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Mon, 8 May 2023 18:19:59 +0430 Subject: [PATCH 03/12] remove themeChanger from siderDrawer --- web/html/xui/common_sider.html | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/web/html/xui/common_sider.html b/web/html/xui/common_sider.html index d059e920..34666b56 100644 --- a/web/html/xui/common_sider.html +++ b/web/html/xui/common_sider.html @@ -27,10 +27,7 @@ - + - + {{end}} From 0e266b88f0eb70bf46d3ecc4df148794bc307205 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Mon, 8 May 2023 19:14:22 +0430 Subject: [PATCH 04/12] update UI to use themeSwitcher --- web/html/common/prompt_modal.html | 14 +- web/html/common/qrcode_modal.html | 8 +- web/html/common/text_modal.html | 4 +- web/html/xui/client_bulk_modal.html | 68 +- web/html/xui/client_modal.html | 45 +- web/html/xui/common_sider.html | 12 +- web/html/xui/form/client.html | 34 +- web/html/xui/form/inbound.html | 8 +- web/html/xui/form/protocol/dokodemo.html | 2 +- web/html/xui/form/protocol/shadowsocks.html | 10 +- web/html/xui/form/protocol/socks.html | 3 +- web/html/xui/form/protocol/trojan.html | 11 +- web/html/xui/form/protocol/vless.html | 15 +- web/html/xui/form/protocol/vmess.html | 6 +- web/html/xui/form/sniffing.html | 34 +- 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_tcp.html | 18 +- web/html/xui/form/stream/stream_ws.html | 6 +- web/html/xui/form/tls_settings.html | 14 +- web/html/xui/inbound_client_table.html | 12 +- web/html/xui/inbound_info_modal.html | 148 +- web/html/xui/inbound_modal.html | 16 +- web/html/xui/inbounds.html | 138 +- web/html/xui/index.html | 54 +- web/html/xui/settings.html | 1471 +++++++++-------- 27 files changed, 1094 insertions(+), 1065 deletions(-) diff --git a/web/html/common/prompt_modal.html b/web/html/common/prompt_modal.html index 4b8a13d0..17a65ec1 100644 --- a/web/html/common/prompt_modal.html +++ b/web/html/common/prompt_modal.html @@ -1,7 +1,7 @@ {{define "promptModal"}} {}, - }) { + title = '', + type = 'text', + value = '', + okText = '{{ i18n "sure"}}', + confirm = () => {}, + }) { this.title = title; this.type = type; this.value = value; diff --git a/web/html/common/qrcode_modal.html b/web/html/common/qrcode_modal.html index f492dabb..2bd2f00f 100644 --- a/web/html/common/qrcode_modal.html +++ b/web/html/common/qrcode_modal.html @@ -1,10 +1,12 @@ {{define "qrcodeModal"}} - {{ i18n "pages.inbounds.clickOnQRcode" }} + + {{ i18n "pages.inbounds.clickOnQRcode" }} + @@ -19,7 +21,7 @@ qrcode: null, clipboard: null, visible: false, - show: function (title='', content='', dbInbound=new DBInbound(), copyText='') { + show: function (title = '', content = '', dbInbound = new DBInbound(), copyText = '') { this.title = title; this.content = content; this.dbInbound = dbInbound; diff --git a/web/html/common/text_modal.html b/web/html/common/text_modal.html index ce77d0ca..1514051b 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 @@ -71,20 +71,20 @@
- + {{ i18n "none" }} [[ key ]] - + {{ i18n "none" }} [[ key ]] - {{ i18n "pages.inbounds.totalFlow" }} (GB) + {{ i18n "pages.inbounds.totalFlow" }} (GB)