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/coolapk/index.ts b/server/sources/coolapk/index.ts index b00250f..18bd344 100644 --- a/server/sources/coolapk/index.ts +++ b/server/sources/coolapk/index.ts @@ -8,7 +8,7 @@ interface Res { message: string // 起的标题 editor_title: string - shareUrl: string + url: string entityType: string pubDate: string // dayjs(dateline, 'X') @@ -27,10 +27,11 @@ export default defineSource({ headers: await genHeaders(), }) if (!r.data.length) throw new Error("Failed to fetch") + console.log(r.data[0]) return r.data.filter(k => k.id).map(i => ({ id: i.id, title: i.editor_title || load(i.message).text().split("\n")[0], - url: i.shareUrl, + url: `https://www.coolapk.com${i.url}`, extra: { info: i.targetRow?.subTitle, // date: new Date(i.dateline * 1000).getTime(), diff --git a/server/sources/ifeng.ts b/server/sources/ifeng.ts new file mode 100644 index 0000000..28fafc9 --- /dev/null +++ b/server/sources/ifeng.ts @@ -0,0 +1,23 @@ +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*(\{[^]*?\});/g; + const match = regex.exec(html); + const news: NewsItem[] = [] + if (match) { + const realData = JSON.parse(match[1]) + realData.hotNews1.forEach((hotNews, i) => { + news.push({ + id: hotNews.url, + url: hotNews.url, + title: hotNews.title, + extra: { + hover: hotNews.title, + date: hotNews.newsTime, + }, + }) + }) + } + return news +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index 8a65106..55cc6ad 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" } \ No newline at end of file diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index a5835ef..f33643f 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -371,6 +371,13 @@ export const originSources = { type: "hottest", home: "https://juejin.cn", }, + "ifeng": { + name: "凤凰网", + column: "china", + color: "red", + type: "hottest", + home: "https://www.ifeng.com", + }, } as const satisfies Record export function genSources() { diff --git a/shared/sources.json b/shared/sources.json index d5d45fd..27fcbf6 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -466,5 +466,13 @@ "home": "https://juejin.cn", "color": "blue", "interval": 600000 + }, + "ifeng": { + "name": "凤凰网", + "type": "hottest", + "column": "china", + "home": "https://www.ifeng.com", + "color": "red", + "interval": 600000 } } \ No newline at end of file