mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-01 03:43:01 +00:00
Merge 5d84ed255d into 784ed39930
This commit is contained in:
commit
ed4643ba96
1 changed files with 44 additions and 9 deletions
|
|
@ -120,6 +120,10 @@
|
|||
oldAllSetting: new AllSetting(),
|
||||
allSetting: new AllSetting(),
|
||||
saveBtnDisable: true,
|
||||
entryHost: null,
|
||||
entryPort: null,
|
||||
entryProtocol: null,
|
||||
entryIsIP: false,
|
||||
user: {},
|
||||
lang: LanguageManager.getLanguage(),
|
||||
inboundOptions: [],
|
||||
|
|
@ -233,6 +237,9 @@
|
|||
loading(spinning = true) {
|
||||
this.loadingStates.spinning = spinning;
|
||||
},
|
||||
_isIp(h) {
|
||||
return /^[0-9.]+$/.test(h) || /^[0-9a-fA-F:]+$/.test(h);
|
||||
},
|
||||
async getAllSetting() {
|
||||
const msg = await HttpUtil.post("/panel/setting/all");
|
||||
|
||||
|
|
@ -307,16 +314,40 @@
|
|||
this.loading(true);
|
||||
const msg = await HttpUtil.post("/panel/setting/restartPanel");
|
||||
this.loading(false);
|
||||
if (msg.success) {
|
||||
this.loading(true);
|
||||
await PromiseUtil.sleep(5000);
|
||||
var { webCertFile, webKeyFile, webDomain: host, webPort: port, webBasePath: base } = this.allSetting;
|
||||
if (host == this.oldAllSetting.webDomain) host = null;
|
||||
if (port == this.oldAllSetting.webPort) port = null;
|
||||
const isTLS = webCertFile !== "" || webKeyFile !== "";
|
||||
const url = URLBuilder.buildURL({ host, port, isTLS, base, path: "panel/settings" });
|
||||
window.location.replace(url);
|
||||
if (!msg.success) return;
|
||||
|
||||
this.loading(true);
|
||||
await PromiseUtil.sleep(5000);
|
||||
|
||||
const { webDomain, webPort, webBasePath, webCertFile, webKeyFile } = this.allSetting;
|
||||
const newProtocol = (webCertFile || webKeyFile) ? "https:" : "http:";
|
||||
|
||||
if (!this.entryIsIP) {
|
||||
const base = webBasePath ? webBasePath.replace(/^\//, "") : "";
|
||||
const url = new URL(window.location.href);
|
||||
url.pathname = `/${base}panel/settings`;
|
||||
window.location.replace(url.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
let finalHost = this.entryHost;
|
||||
let finalPort = this.entryPort || "";
|
||||
|
||||
if (webDomain && this._isIp(webDomain)) {
|
||||
finalHost = webDomain;
|
||||
}
|
||||
|
||||
if (webPort && Number(webPort) !== Number(this.entryPort)) {
|
||||
finalPort = String(webPort);
|
||||
}
|
||||
|
||||
const base = webBasePath ? webBasePath.replace(/^\//, "") : "";
|
||||
|
||||
const url = new URL(`${newProtocol}//${finalHost}`);
|
||||
if (finalPort) url.port = finalPort;
|
||||
url.pathname = `/${base}panel/settings`;
|
||||
|
||||
window.location.replace(url.toString());
|
||||
},
|
||||
toggleTwoFactor(newValue) {
|
||||
if (newValue) {
|
||||
|
|
@ -568,6 +599,10 @@
|
|||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.entryHost = window.location.hostname;
|
||||
this.entryPort = window.location.port;
|
||||
this.entryProtocol = window.location.protocol;
|
||||
this.entryIsIP = this._isIp(this.entryHost);
|
||||
await this.getAllSetting();
|
||||
await this.loadInboundTags();
|
||||
while (true) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue