mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-02-07 22:10:03 +08:00
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
![]() |
interface Res {
|
||
|
code: number
|
||
|
message: string
|
||
|
ttl: number
|
||
|
data: {
|
||
|
trending: {
|
||
|
title: string
|
||
|
trackid: string
|
||
|
list: {
|
||
|
keyword: string
|
||
|
show_name: string
|
||
|
icon: string
|
||
|
uri: string
|
||
|
goto: string
|
||
|
heat_score: number
|
||
|
}[]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const hotSearch = defineSource(async () => {
|
||
|
const url = "https://api.bilibili.com/x/web-interface/wbi/search/square?limit=30"
|
||
|
|
||
|
const res: Res = await $fetch(url, {
|
||
|
headers: {
|
||
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
||
|
// "Cookie": "your_cookie_here"
|
||
|
},
|
||
|
})
|
||
|
|
||
|
return res.data.trending.list.map(k => ({
|
||
|
id: k.keyword,
|
||
|
title: k.show_name,
|
||
|
url: `https://search.bilibili.com/all?keyword=${encodeURIComponent(k.keyword)}`,
|
||
|
extra: {
|
||
|
icon: k.icon && `/api/proxy?img=${encodeURIComponent(k.icon)}`,
|
||
|
},
|
||
|
}))
|
||
|
})
|
||
|
|
||
|
export default defineSource({
|
||
|
"bilibili": hotSearch,
|
||
|
"bilibili-hot-search": hotSearch,
|
||
|
})
|