fix: GitHub 系包 logo 改用组织头像,替代全站相同的章鱼猫 favicon
- 实测 vuejs.org/favicon.ico 返回 404(vue 回退字母,本就不是章鱼猫)
- 章鱼猫仅出现在 homepage 指向 github.com 仓库的包(github 全站 favicon 唯一)
- 改进:github.com/{owner}/{repo} 主页 → 加载 github.com/{owner}.png 组织/用户头像
(vuejs 组织头像即 Vue logo、antvis 即 antv 图标),失败仍回退首字母
This commit is contained in:
@@ -27,12 +27,21 @@ const style = computed(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// favicon 来源:主页域名根路径 /favicon.ico(不依赖第三方服务,站点没有时回退徽标)
|
// favicon 来源:
|
||||||
|
// - GitHub 仓库主页 → 组织/用户头像 {owner}.png(GitHub 全站 favicon 是章鱼猫无区分度,头像才是该项目的 logo)
|
||||||
|
// - 其他主页 → 域名根路径 /favicon.ico
|
||||||
|
// 加载失败一律回退首字母徽标
|
||||||
const imgOk = ref(false)
|
const imgOk = ref(false)
|
||||||
const faviconUrl = computed(() => {
|
const faviconUrl = computed(() => {
|
||||||
if (!props.homepage) return ''
|
const hp = props.homepage
|
||||||
|
if (!hp) return ''
|
||||||
try {
|
try {
|
||||||
return new URL(props.homepage).origin + '/favicon.ico'
|
const u = new URL(hp)
|
||||||
|
if (u.hostname === 'github.com' || u.hostname === 'www.github.com') {
|
||||||
|
const m = hp.match(/^https?:\/\/(?:www\.)?github\.com\/([^/?#]+)\/[^/?#]+/)
|
||||||
|
if (m) return `https://github.com/${m[1]}.png`
|
||||||
|
}
|
||||||
|
return u.origin + '/favicon.ico'
|
||||||
} catch {
|
} catch {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user