From 4daeb0edd423971d62b2417020b41394100ca45b Mon Sep 17 00:00:00 2001 From: Ou Date: Sun, 27 Oct 2024 00:06:01 +0800 Subject: [PATCH] feat(source): add jin10 * feat(source): add jin10 * chore: update source jin10 --------- Co-authored-by: onlylhf <542182964@qq.com> --- public/icons/jin10.png | Bin 0 -> 4286 bytes server/glob.d.ts | 1 + server/sources/jin10.ts | 46 ++++++++++++++++++++++++++++++++++++++++ shared/sources.ts | 6 ++++++ 4 files changed, 53 insertions(+) create mode 100644 public/icons/jin10.png create mode 100644 server/sources/jin10.ts diff --git a/public/icons/jin10.png b/public/icons/jin10.png new file mode 100644 index 0000000000000000000000000000000000000000..db6cb9f08da28adb673244a713a7f62f57a2c965 GIT binary patch literal 4286 zcmc&&%}-N75MS{h@Z_0`iATM8^ytc4p@{J2N};79sZVUu&ztuZZmv zV!sgLAa|Y;N4aBOHm13?rNMUbV<2=OJrIg;pXHw7zQ(=Cof_;|3mK3FnIpgemc6C> zLoG}@$KBxGC|1yQ2J3J()!)$q9iU4E+iU{1($RztHk&tN-wIoeu!Hiqnrrqr!Zt@- zG#gjpsW?~ffyT^m7iA}UX(e`(R=H=Ry_CM*>A3c5_!KRKdmL%JZ*|7p=vDK-?p~t8 zT$0Sc>qM4Gs%;rL$_#Z?@xG5-q`v#F=-87KK?fHb<7}2(XnIX1e1eSR6j@ta3bJY} ze*dC*UyOyRa-@fz-M*o*f#1n?@RIFE z%d)>Mvutx{zelxQ(l^Q7tkTAK$Tl ze7uCAr~y?ezUbb}7CgQFbI4~SVbG~6A zJk+0Yi6i}8u{jt~v#{1pu5CV8{pC8OYC%O4#{oP>G7%IT^%vg&LG+aIfS8nd+4lW` zJc&8b5HmsLRj~05RL>edPu;Q>BCp8rFOE5x=j)WixawX~7k<6^dhp}>6Zfs%!e{Ju z+yQp&{;@RJwk!89-ZS67+T=CVcK=*&f-hieeg9PV;IbX0FKX}KzWKpJXRNi~zooy` UzJWb0#NKQ87eSL7FsB*&KSc(2ZU6uP literal 0 HcmV?d00001 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()