mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-04-24 19:28:37 +00:00
13 lines
443 B
TypeScript
13 lines
443 B
TypeScript
/**
|
|
* 统一生成页面标题,避免多处写入 document.title 产生覆盖冲突。
|
|
*/
|
|
export function resolveDocumentTitle(routeTitle: unknown, siteName?: string): string {
|
|
const normalizedSiteName = typeof siteName === 'string' && siteName.trim() ? siteName.trim() : 'Sub2API'
|
|
|
|
if (typeof routeTitle === 'string' && routeTitle.trim()) {
|
|
return `${routeTitle.trim()} - ${normalizedSiteName}`
|
|
}
|
|
|
|
return normalizedSiteName
|
|
}
|