feat: better image proxy

This commit is contained in:
Ou 2024-11-01 19:46:37 +08:00
parent ac4a7e5d20
commit d5053d1bcb
2 changed files with 4 additions and 3 deletions

View File

@ -22,7 +22,7 @@ export default defineSource(async () => {
title: k.Title, title: k.Title,
url: `https://www.toutiao.com/trending/${k.ClusterIdStr}/`, url: `https://www.toutiao.com/trending/${k.ClusterIdStr}/`,
extra: { extra: {
icon: k.LabelUri?.url && proxyPicture(k.LabelUri.url), icon: k.LabelUri?.url && proxyPicture(k.LabelUri.url, "encodeBase64URL"),
}, },
} }
}) })

View File

@ -1,3 +1,4 @@
export function proxyPicture(url: string) { export function proxyPicture(url: string, type: "encodeURIComponent" | "encodeBase64URL" = "encodeURIComponent") {
return `/api/proxy/img.png?url=${encodeBase64URL(url)}` const encoded = type === "encodeBase64URL" ? encodeBase64URL(url) : encodeURIComponent(url)
return `/api/proxy/img.png?url=${encoded}`
} }