diff --git a/public/icons/jin10.png b/public/icons/jin10.png new file mode 100644 index 0000000..db6cb9f Binary files /dev/null and b/public/icons/jin10.png differ diff --git a/server/glob.d.ts b/server/glob.d.ts index 70be7f5..56748f9 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -12,6 +12,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const github: typeof import('./sources/github') export const hackernews: typeof import('./sources/hackernews') export const ithome: typeof import('./sources/ithome') + export const jin10: typeof import('./sources/jin10') export const kaopu: typeof import('./sources/kaopu') export const kuaishou: typeof import('./sources/kuaishou') export const producthunt: typeof import('./sources/producthunt') diff --git a/server/sources/jin10.ts b/server/sources/jin10.ts new file mode 100644 index 0000000..0814f26 --- /dev/null +++ b/server/sources/jin10.ts @@ -0,0 +1,46 @@ +interface Jin10Item { + id: string + time: string + type: number + data: { + pic?: string + title?: string + source?: string + content?: string + source_link?: string + vip_title?: string + lock?: boolean + vip_level?: number + vip_desc?: string + } + important: number + tags: string[] + channel: number[] + remark: any[] +} + +export default defineSource(async () => { + const timestamp = Date.now() + const url = `https://www.jin10.com/flash_newest.js?t=${timestamp}` + + const rawData: string = await $fetch(url) + + // eslint-disable-next-line no-new-func + const jsonStr = new Function(`${rawData}\nreturn newest;`) + const data: Jin10Item[] = jsonStr() + + return data.filter(k => (k.data.title || k.data.content) && !k.channel?.includes(5)).map((k) => { + const text = (k.data.title || k.data.content)!.replace(/<\/?b>/g, "") + const [,title, desc] = text.match(/^【([^】]*)】(.*)$/) ?? [] + return { + id: k.id, + title: title ?? text, + pubDate: parseRelativeDate(k.time, "Asia/Shanghai").valueOf(), + url: `https://flash.jin10.com/detail/${k.id}`, + extra: { + hover: desc, + info: !!k.important && "✰", + }, + } + }) +}) diff --git a/shared/sources.ts b/shared/sources.ts index 48f2a23..f5bbd1d 100644 --- a/shared/sources.ts +++ b/shared/sources.ts @@ -266,6 +266,12 @@ export const originSources = { desc: "不一定靠谱,多看多思考", home: "https://kaopu.news/", }, + "jin10": { + name: "金十数据", + column: "finance", + color: "red", + home: "https://www.jin10.com", + }, } as const satisfies Record export const sources = genSources()