diff --git a/public/icons/ifeng.png b/public/icons/ifeng.png new file mode 100644 index 0000000..79b837c Binary files /dev/null and b/public/icons/ifeng.png differ diff --git a/server/glob.d.ts b/server/glob.d.ts index a0c8cde..94311df 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -13,6 +13,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const ghxi: typeof import('./sources/ghxi') export const github: typeof import('./sources/github') export const hackernews: typeof import('./sources/hackernews') + export const ifeng: typeof import('./sources/ifeng') export const ithome: typeof import('./sources/ithome') export const jin10: typeof import('./sources/jin10') export const juejin: typeof import('./sources/juejin') diff --git a/server/sources/ifeng.ts b/server/sources/ifeng.ts new file mode 100644 index 0000000..7e11646 --- /dev/null +++ b/server/sources/ifeng.ts @@ -0,0 +1,27 @@ +import type { NewsItem } from "@shared/types" + +export default defineSource(async () => { + const html: string = await myFetch("https://www.ifeng.com/") + const regex = /var\s+allData\s*=\s*(\{[\s\S]*?\});/ + const match = regex.exec(html) + const news: NewsItem[] = [] + if (match) { + const realData = JSON.parse(match[1]) + const rawNews = realData.hotNews1 as { + url: string + title: string + newsTime: string + }[] + rawNews.forEach((hotNews) => { + news.push({ + id: hotNews.url, + url: hotNews.url, + title: hotNews.title, + extra: { + date: hotNews.newsTime, + }, + }) + }) + } + return news +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index 8a65106..153b23a 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -41,5 +41,6 @@ "smzdm": "shenmezhidemai", "nowcoder": "niuke", "sspai": "shaoshupai", - "juejin": "xitujuejin" + "juejin": "xitujuejin", + "ifeng": "fenghuangwang-redianzixun" } \ No newline at end of file diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index a5835ef..d7dddd9 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -371,6 +371,14 @@ export const originSources = { type: "hottest", home: "https://juejin.cn", }, + "ifeng": { + name: "凤凰网", + column: "china", + color: "red", + type: "hottest", + title: "热点资讯", + home: "https://www.ifeng.com", + }, } as const satisfies Record export function genSources() { diff --git a/shared/sources.json b/shared/sources.json index d5d45fd..0ffe8f4 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -466,5 +466,14 @@ "home": "https://juejin.cn", "color": "blue", "interval": 600000 + }, + "ifeng": { + "title": "热点资讯", + "name": "凤凰网", + "type": "hottest", + "column": "china", + "home": "https://www.ifeng.com", + "color": "red", + "interval": 600000 } } \ No newline at end of file