chore: clean code

This commit is contained in:
ourongxing
2025-04-23 13:31:29 +08:00
parent 0bbcfec50f
commit bda93fd204
5 changed files with 12 additions and 7 deletions
-1
View File
@@ -27,7 +27,6 @@ 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],
+9 -5
View File
@@ -2,18 +2,22 @@ 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 regex = /var\s+allData\s*=\s*(\{[\s\S]*?\});/
const match = regex.exec(html)
const news: NewsItem[] = []
if (match) {
const realData = JSON.parse(match[1])
realData.hotNews1.forEach((hotNews, i) => {
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: {
hover: hotNews.title,
date: hotNews.newsTime,
},
})
+1 -1
View File
@@ -42,5 +42,5 @@
"nowcoder": "niuke",
"sspai": "shaoshupai",
"juejin": "xitujuejin",
"ifeng": "fenghuangwang"
"ifeng": "fenghuangwang-redianzixun"
}
+1
View File
@@ -376,6 +376,7 @@ export const originSources = {
column: "china",
color: "red",
type: "hottest",
title: "热点资讯",
home: "https://www.ifeng.com",
},
} as const satisfies Record<string, OriginSource>
+1
View File
@@ -468,6 +468,7 @@
"interval": 600000
},
"ifeng": {
"title": "热点资讯",
"name": "凤凰网",
"type": "hottest",
"column": "china",