diff --git a/server/glob.d.ts b/server/glob.d.ts index 4c65b4c..152feb4 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -22,6 +22,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const kaopu: typeof import('./sources/kaopu') export const kuaishou: typeof import('./sources/kuaishou') export const linuxdo: typeof import('./sources/linuxdo') + export const mktnews: typeof import('./sources/mktnews') export const nowcoder: typeof import('./sources/nowcoder') export const pcbeta: typeof import('./sources/pcbeta') export const producthunt: typeof import('./sources/producthunt') diff --git a/server/sources/mktnews.ts b/server/sources/mktnews.ts new file mode 100644 index 0000000..8fbb6bc --- /dev/null +++ b/server/sources/mktnews.ts @@ -0,0 +1,83 @@ +interface Report { + id: string + type: number + time: string + important: number + data: { + content: string + pic: string + title: string + } + remark: string[] + hot: boolean + hot_start: string + hot_end: string + classify: { + id: number + pid: number + name: string + parent: string + }[] +} + +interface Child { + id: number + name: string + pid: number + flash_list: Report[] +} + +interface Res { + data: { + id: number + name: string + pid: number + child: Child[] + } +} + +const policy = defineSource(async () => { + const res: Res = await myFetch("https://api.mktnews.net/api/flash/host") + const flashList = res.data.child.filter(item => item.id === 1000)[0]?.flash_list || [] + return flashList.map((item) => { + const url = `https://mktnews.net/flashDetail.html?id=${item.id}` + return { + id: item.id, + title: item.data.title || item.data.content, + url, + } + }) +}) + +const AI = defineSource(async () => { + const res: Res = await myFetch("https://api.mktnews.net/api/flash/host") + const flashList = res.data.child.filter(item => item.id === 2000)[0]?.flash_list || [] + return flashList.map((item) => { + const url = `https://mktnews.net/flashDetail.html?id=${item.id}` + return { + id: item.id, + title: item.data.title || item.data.content, + url, + } + }) +}) + +const financial = defineSource(async () => { + const res: Res = await myFetch("https://api.mktnews.net/api/flash/host") + const flashList = res.data.child.filter(item => item.id === 3000)[0]?.flash_list || [] + return flashList.map((item) => { + const url = `https://mktnews.net/flashDetail.html?id=${item.id}` + return { + id: item.id, + title: item.data.title || item.data.content, + url, + } + }) +}) + +export default defineSource({ + "mktnews": policy, + "mktnews-policy": policy, + "mktnews-AI": AI, + "mktnews-financial": financial, +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index d511ca6..6aec8e7 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -45,5 +45,8 @@ "juejin": "xitujuejin", "ifeng": "fenghuangwang-redianzixun", "chongbuluo-latest": "chongbuluo-zuixin", - "chongbuluo-hot": "chongbuluo-zuire" + "chongbuluo-hot": "chongbuluo-zuire", + "mktnews-policy": "mkt-xinwen", + "mktnews-AI": "mkt-xinwen", + "mktnews-financial": "mkt-xinwen" } \ No newline at end of file diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index badee07..a5144ae 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -57,6 +57,22 @@ export const originSources = { title: "今日最热", home: "https://coolapk.com", }, + "mktnews": { + name: "MKTNews.com", + column: "world", + home: "https://mktnews.net", + sub: { + policy: { + title: "政策快讯", + }, + AI: { + title: "AI快讯", + }, + financial: { + title: "金融快讯", + }, + }, + }, "wallstreetcn": { name: "华尔街见闻", color: "blue", @@ -417,29 +433,40 @@ export function genSources() { if (source.sub && Object.keys(source.sub).length) { Object.entries(source.sub).forEach(([subId, subSource], i) => { if (i === 0) { - _.push([id, { - redirect: `${id}-${subId}`, - ...parent, - ...subSource, - }] as [any, Source]) + _.push([ + id, + { + redirect: `${id}-${subId}`, + ...parent, + ...subSource, + }, + ] as [any, Source]) } - _.push([`${id}-${subId}`, { ...parent, ...subSource }] as [any, Source]) + _.push([`${id}-${subId}`, { ...parent, ...subSource }] as [ + any, + Source, + ]) }) } else { - _.push([id, { - title: source.title, - ...parent, - }]) + _.push([ + id, + { + title: source.title, + ...parent, + }, + ]) } }) - return typeSafeObjectFromEntries(_.filter(([_, v]) => { - if (v.disable === "cf" && process.env.CF_PAGES) { - return false - } else if (v.disable === true) { - return false - } else { - return true - } - })) + return typeSafeObjectFromEntries( + _.filter(([_, v]) => { + if (v.disable === "cf" && process.env.CF_PAGES) { + return false + } else if (v.disable === true) { + return false + } else { + return true + } + }), + ) } diff --git a/shared/sources.json b/shared/sources.json index 77ea5b0..746f0c1 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -87,6 +87,39 @@ "interval": 1800000, "title": "最热文章" }, + "mktnews": { + "redirect": "mktnews-policy", + "name": "MKTNews", + "column": "world", + "home": "https://mktnews.net", + "color": "red", + "interval": 6000000, + "title": "最热文章" + }, + "mktnews-policy": { + "name": "MKTNews", + "column": "world", + "home": "https://mktnews.net", + "color": "red", + "interval": 6000000, + "title": "最热文章" + }, + "mktnews-AI": { + "name": "MKTNews", + "column": "world", + "home": "https://mktnews.net", + "color": "red", + "interval": 6000000, + "title": "AI热点" + }, + "mktnews-financial": { + "name": "MKTNews", + "column": "world", + "home": "https://mktnews.net", + "color": "red", + "interval": 6000000, + "title": "金融热点" + }, "36kr": { "redirect": "36kr-quick", "name": "36氪",