1.新增描述文档

This commit is contained in:
2026-06-03 13:53:45 +08:00
parent 37b0ee134e
commit 9fb98dee3f
12 changed files with 1044 additions and 3 deletions

View File

@@ -16,10 +16,11 @@
*/
import { AppRouteRecord } from '@/types/router'
import { router } from '@/router'
import { resolveAppAssetUrl } from '@/utils/navigation/resolveAppAssetUrl'
// 打开外部链接
// 打开外部链接(含站内静态页,自动拼接部署 base
export const openExternalLink = (link: string) => {
window.open(link, '_blank')
window.open(resolveAppAssetUrl(link), '_blank', 'noopener,noreferrer')
}
/**

View File

@@ -0,0 +1,19 @@
/**
* 解析菜单外链 / 静态资源路径(兼容 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}`
}