mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 11:19:14 +08:00
34 lines
850 B
TypeScript
34 lines
850 B
TypeScript
interface Res {
|
|
data: {
|
|
items: {
|
|
uri: string
|
|
id: number
|
|
title?: string
|
|
content_text: string
|
|
display_time: number
|
|
}[]
|
|
}
|
|
}
|
|
|
|
// https://github.com/DIYgod/RSSHub/blob/master/lib/routes/wallstreetcn/live.ts
|
|
export default defineSource(async () => {
|
|
const category = "global"
|
|
const apiRootUrl = "https://api-one.wallstcn.com"
|
|
const apiUrl = `${apiRootUrl}/apiv1/content/lives?channel=${category}-channel&limit=30`
|
|
|
|
const res: Res = await $fetch(apiUrl)
|
|
if (!res?.data?.items || res.data.items.length === 0) throw new Error("Cannot fetch data")
|
|
return res.data.items
|
|
.slice(0, 30)
|
|
.map((k) => {
|
|
return {
|
|
id: k.id,
|
|
title: k.title || k.content_text,
|
|
extra: {
|
|
date: new Date(k.display_time * 1000).getTime(),
|
|
},
|
|
url: k.uri,
|
|
}
|
|
})
|
|
})
|