mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
fix(landing): заголовок «Loading...» и пустая иконка вкладки на лендингах
Публичный лендинг (QuickPurchase) рендерится вне AppShell, а useBranding с заголовком/иконкой завязан на авторизацию — поэтому на лендинге вкладка оставалась с дефолтным «Loading...» из index.html (тайтл обновлялся только при заданном meta_title) и без favicon (href="data:,"). - index.html: нейтральная дефолтная иконка-монограмма вместо пустого data-URI и тайтл «VPN» вместо «Loading...». - QuickPurchase: тайтл берётся из meta_title || title лендинга; favicon ставится из брендинга (кастомный лого-блоб или буквенная монограмма), брендинг тянется из публичного эндпоинта. - favicon-хелперы вынесены в utils/favicon.ts; useBranding переведён на них (DRY) + добавлен буквенный фолбэк, чтобы иконка была всегда. - Тип LandingTariff дополнен is_daily/daily_price_kopeks (синхронно с бэком).
This commit is contained in:
35
src/utils/favicon.ts
Normal file
35
src/utils/favicon.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Favicon helpers.
|
||||
*
|
||||
* The static fallback in index.html is a neutral monogram so the tab is never
|
||||
* left without an icon. Once branding is known we override it with the custom
|
||||
* logo (or a brand-letter monogram) via {@link setFavicon}.
|
||||
*/
|
||||
|
||||
/** Point the page favicon at `href`, creating the <link> if needed. */
|
||||
export function setFavicon(href: string): void {
|
||||
if (!href) return;
|
||||
let link = document.querySelector<HTMLLinkElement>("link[rel*='icon']");
|
||||
if (!link) {
|
||||
link = document.createElement('link');
|
||||
link.rel = 'icon';
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
link.href = href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a square monogram favicon (SVG data URI) from a brand letter.
|
||||
* Used when the deployment has no custom logo, so every page still gets an
|
||||
* icon that matches the brand letter instead of the browser's blank default.
|
||||
*/
|
||||
export function letterFaviconDataUri(letter: string): string {
|
||||
const ch = (letter || 'V').trim().charAt(0).toUpperCase() || 'V';
|
||||
const svg =
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">` +
|
||||
`<rect width="64" height="64" rx="14" fill="#0a0f1a"/>` +
|
||||
`<text x="50%" y="50%" font-family="Manrope,Arial,sans-serif" font-size="38" ` +
|
||||
`font-weight="700" fill="#ffffff" text-anchor="middle" dominant-baseline="central">${ch}</text>` +
|
||||
`</svg>`;
|
||||
return `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user