Files
hfb_sys/frontend/public/site-bootstrap.js
T

41 lines
1.3 KiB
JavaScript

/* global document, URLSearchParams, window */
;(() => {
// 生产 HTML 已由后端按 Host 注入 title/meta/icon;已注入时不要重复覆盖。
// 这里仅作为静态兜底,兼容缓存中的旧 HTML 和尚未接入后端注入的域名。
if (document.querySelector('meta[name="site-shell"]')) return
const host = window.location.hostname.toLowerCase()
const params = new URLSearchParams(window.location.search)
const tenantHint = (params.get('tenant_code') || params.get('tenant') || '').toLowerCase()
const isJieyou =
host === 'zuhaox.com' ||
host.endsWith('.zuhaox.com') ||
host.startsWith('jieyou.') ||
tenantHint === 'jieyou'
if (!isJieyou) return
document.title = '解忧商行 - 官方租号平台'
document.documentElement.dataset.siteBootstrap = 'jieyou'
function applyIcon(id, rel, href, type) {
let link = document.getElementById(id)
if (!link) {
link = document.createElement('link')
link.id = id
link.rel = rel
document.head.appendChild(link)
}
link.href = href
if (type) link.type = type
}
applyIcon('site-icon', 'icon', '/jieyou-favicon.svg', 'image/svg+xml')
applyIcon(
'site-apple-touch-icon',
'apple-touch-icon',
'/jieyou-apple-touch-icon.png',
'image/png'
)
})()