dpl/frontends/hn/runtime-config.mjs

34 lines
1.8 KiB
JavaScript

export function adaptConfig(original, settings, location) {
const config = structuredClone(original);
config.PANEL_TYPE = 'Xboard';
config.API_CONFIG = {urlMode: 'auto', showCheckBackend: false, staticBaseUrl: [], autoConfig: {useSameProtocol: true, appendApiPath: true, apiPath: '/api/v1'}};
config.API_MIDDLEWARE_ENABLED = false;
config.API_MIDDLEWARE_URL = '';
config.API_MIDDLEWARE_KEY = '';
config.SITE_CONFIG.siteName = settings.title || 'hardnerd';
config.SITE_CONFIG.siteDescription = settings.description || 'hardnerd · 探索全球网络';
config.SITE_CONFIG.copyright = `© ${new Date().getFullYear()} ${settings.full_name || 'hardnerd.net'}`;
config.SITE_CONFIG.customLandingPage = '';
config.DEFAULT_CONFIG.defaultTheme = 'dark';
config.DEFAULT_CONFIG.primaryColor = '#8bcf36';
config.AUTH_LAYOUT_CONFIG.splitLayout.leftContent.backgroundImage = '';
config.AUTHORIZED_DOMAINS = [location.hostname];
config.SHOP_CONFIG.showPlanFeatureCards = false;
config.SHOP_CONFIG.popup.enabled = false;
config.CLIENT_CONFIG.showDownloadCard = false;
config.CLIENT_CONFIG.clientLinks = {};
config.PROFILE_CONFIG.showRecentDevices = false;
config.CUSTOMER_SERVICE_CONFIG.enabled = false;
config.TICKET_CONFIG.isImageHosting = false;
config.TICKET_CONFIG.imggbKey = '';
config.MORE_PAGE_CONFIG.enableCustomCards = false;
config.MORE_PAGE_CONFIG.customCards = [];
const scrub = value => {
if (typeof value === 'string' && /ezdemo\.xyz|loliapi\.com|t\.me\/your_|github\.com\/xxx|store\/apps\/xxx|\/app\/xxx/.test(value)) return '';
if (Array.isArray(value)) return value.map(scrub);
if (value && typeof value === 'object') return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, scrub(item)]));
return value;
};
return scrub(config);
}