mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-07-06 07:01:23 +08:00
feat(extension): popup 改紧凑视图,markdown 详情挪到侧边栏
之前 popup 直接在 400px 宽里渲染 markdown,看起来很挤。改成: - popup:标题 + 封面缩略图 + 进度条 + 「在侧边栏查看」按钮,不再渲染 markdown - 提交「生成笔记」后自动调 chrome.sidePanel.open 把侧边栏拉起来 - 最近任务列表显示标题(拿到时)而非 URL - 新增 logic/api.resolveImageUrl:相对 /static 路径拼后端域名;hdslb / byteimg / kpcdn / ytimg 等带 referer 校验的封面走后端 /api/image_proxy 转发,避免 CORS / 防盗链问题 - 侧边栏顶部同样展示封面 + 标题 + 跳原片链接,方便用户辨识当前任务 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -213,3 +213,16 @@ export function absolutizeMarkdownImages(md: string): string {
|
||||
const base = backendUrl()
|
||||
return md.replace(/!\[([^\]]*)\]\((\/static\/[^)]+)\)/g, (_, alt, path) => ``)
|
||||
}
|
||||
|
||||
// 单个图片 URL 的处理:相对路径 → 拼后端域名;B 站等带防盗链的封面 → 走后端 image_proxy
|
||||
export function resolveImageUrl(url: string | undefined | null): string {
|
||||
if (!url)
|
||||
return ''
|
||||
const base = backendUrl()
|
||||
if (url.startsWith('/'))
|
||||
return `${base}${url}`
|
||||
// B 站封面、抖音封面等会做 referer 校验;走后端代理
|
||||
if (/(hdslb|byteimg|kpcdn|akamaized|ytimg)\.com/i.test(url))
|
||||
return `${base}/api/image_proxy?url=${encodeURIComponent(url)}`
|
||||
return url
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user