feat(server): proxy icon

This commit is contained in:
Ou 2024-10-25 18:00:37 +08:00
parent 7d6ebbb669
commit 7cdfb2ea9d
3 changed files with 16 additions and 2 deletions

14
server/api/proxy.ts Normal file
View File

@ -0,0 +1,14 @@
export default defineEventHandler(async (event) => {
const img = getQuery(event).img
if (img) {
const url = decodeURIComponent(img as string)
return sendProxy(event, url, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": "*",
"Access-Control-Allow-Methods": "GET, HEAD, POST, PUT, OPTIONS",
"Access-Control-Allow-Headers": "*",
},
})
}
})

View File

@ -36,7 +36,7 @@ export default defineSource(async () => {
id: k.num,
title: k.word,
extra: {
icon: k.icon,
icon: k.icon && `/api/proxy?img=${encodeURIComponent(k.icon)}`,
},
url: `https://s.weibo.com/weibo?q=${encodeURIComponent(keyword)}`,
mobileUrl: `https://m.weibo.cn/search?containerid=231522type%3D1%26q%3D${encodeURIComponent(keyword)}&_T_WM=16922097837&v_p=42`,

View File

@ -30,7 +30,7 @@ export default defineSource({
id: k.target.id,
title: k.target.title,
extra: {
icon: k.card_label?.night_icon,
icon: k.card_label?.night_icon && `/api/proxy?img=${encodeURIComponent(k.card_label?.night_icon)}`,
},
url: `https://www.zhihu.com/question/${k.target.id}`,
}