chore: clean code
This commit is contained in:
@@ -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],
|
||||
|
||||
@@ -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
@@ -42,5 +42,5 @@
|
||||
"nowcoder": "niuke",
|
||||
"sspai": "shaoshupai",
|
||||
"juejin": "xitujuejin",
|
||||
"ifeng": "fenghuangwang"
|
||||
"ifeng": "fenghuangwang-redianzixun"
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -468,6 +468,7 @@
|
||||
"interval": 600000
|
||||
},
|
||||
"ifeng": {
|
||||
"title": "热点资讯",
|
||||
"name": "凤凰网",
|
||||
"type": "hottest",
|
||||
"column": "china",
|
||||
|
||||
Reference in New Issue
Block a user