/**
 * 解析菜单外链 / 静态资源路径（兼容 VITE_BASE_URL 子目录部署）
 */
export function resolveAppAssetUrl(relativeOrAbsolute: string): string {
  const link = relativeOrAbsolute.trim()
  if (!link) {
    return link
  }
  if (/^https?:\/\//i.test(link)) {
    return link
  }
  const base = import.meta.env.BASE_URL || '/'
  const normalizedBase = base.endsWith('/') ? base : `${base}/`
  const path = link.startsWith('/') ? link.slice(1) : link
  if (typeof window === 'undefined') {
    return `${normalizedBase}${path}`
  }
  return `${window.location.origin}${normalizedBase}${path}`
}
