feat: 支持配置系统图标

This commit is contained in:
Nixevol
2026-07-05 00:27:44 +08:00
parent c56ca91edd
commit accc8a7d6f
20 changed files with 182 additions and 36 deletions
+19
View File
@@ -0,0 +1,19 @@
export const DEFAULT_APP_ICON_URL = '/app-icon.svg';
export function resolveAppIcon(url?: string | null): string {
const value = String(url || '').trim();
return value || DEFAULT_APP_ICON_URL;
}
export function setFavicon(url?: string | null): void {
const href = resolveAppIcon(url);
const selectors = ['link[rel="icon"]', 'link[rel="shortcut icon"]'];
let link = document.head.querySelector<HTMLLinkElement>(selectors.join(','));
if (!link) {
link = document.createElement('link');
link.rel = 'icon';
document.head.appendChild(link);
}
link.type = href.endsWith('.svg') ? 'image/svg+xml' : '';
link.href = href;
}