feat: migrate yacd url to dynamic

This commit is contained in:
divocat
2025-10-02 23:25:14 +03:00
parent cd133838cb
commit 3988588c9f
5 changed files with 14 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
export function getBaseUrl(): string {
const { protocol, hostname } = window.location;
return `${protocol}//${hostname}`;
}

View File

@@ -0,0 +1 @@
export * from './getBaseUrl';

View File

@@ -3,3 +3,4 @@
export * from './validators';
export * from './constants';
export * from './helpers';

View File

@@ -7,7 +7,7 @@
function createAdditionalSection(mainSection) {
let o = mainSection.tab('additional', _('Additional Settings'));
o = mainSection.taboption('additional', form.Flag, 'yacd', _('Yacd enable'), '<a href="http://openwrt.lan:9090/ui" target="_blank">openwrt.lan:9090/ui</a>');
o = mainSection.taboption('additional', form.Flag, 'yacd', _('Yacd enable'), `<a href="${main.getBaseUrl()}:9090/ui" target="_blank">${main.getBaseUrl()}:9090/ui</a>`);
o.default = '0';
o.rmempty = false;
o.ucisection = 'main';

View File

@@ -189,6 +189,12 @@ var COMMAND_SCHEDULING = {
P10_PRIORITY: 1900
// Lowest priority
};
// src/helpers/getBaseUrl.ts
function getBaseUrl() {
const { protocol, hostname } = window.location;
return `${protocol}//${hostname}`;
}
return baseclass.extend({
ALLOWED_WITH_RUSSIA_INSIDE,
BOOTSTRAP_DNS_SERVER_OPTIONS,
@@ -207,6 +213,7 @@ return baseclass.extend({
REGIONAL_OPTIONS,
STATUS_COLORS,
UPDATE_INTERVAL_OPTIONS,
getBaseUrl,
validateDNS,
validateDomain,
validateIPV4,