newsnow/shared/sources.ts

341 lines
7.0 KiB
TypeScript
Raw Permalink Normal View History

2024-10-10 22:47:25 +08:00
import { Interval } from "./consts"
2024-10-08 20:49:19 +08:00
import { typeSafeObjectFromEntries } from "./type.util"
import type { OriginSource, Source, SourceID } from "./types"
2024-10-09 02:53:38 +08:00
const Time = {
2024-10-10 22:47:25 +08:00
Test: 1,
Realtime: 2 * 60 * 1000,
Fast: 5 * 60 * 1000,
Default: Interval, // 10min
Common: 30 * 60 * 1000,
Slow: 60 * 60 * 1000,
2024-10-09 02:53:38 +08:00
}
2024-10-08 20:49:19 +08:00
export const originSources = {
"v2ex": {
name: "V2EX",
2024-10-12 12:49:20 +08:00
color: "slate",
2024-10-08 20:49:19 +08:00
home: "https://v2ex.com/",
2024-10-20 20:28:49 +08:00
sub: {
share: {
title: "最新分享",
2024-10-26 00:00:33 +08:00
column: "tech",
2024-10-20 20:28:49 +08:00
},
},
2024-10-08 20:49:19 +08:00
},
2024-10-14 21:54:12 +08:00
"zhihu": {
name: "知乎",
type: "hottest",
2024-10-26 00:00:33 +08:00
column: "china",
color: "blue",
2024-10-14 21:54:12 +08:00
home: "https://www.zhihu.com",
},
"weibo": {
name: "微博",
title: "实时热搜",
type: "hottest",
2024-10-26 00:00:33 +08:00
column: "china",
2024-10-14 21:54:12 +08:00
color: "red",
interval: Time.Realtime,
home: "https://weibo.com",
},
"zaobao": {
name: "联合早报",
interval: Time.Common,
2024-10-19 13:15:48 +08:00
type: "realtime",
2024-10-26 00:00:33 +08:00
column: "world",
2024-10-14 21:54:12 +08:00
color: "red",
home: "https://www.zaobao.com",
},
2024-10-09 02:53:38 +08:00
"coolapk": {
name: "酷安",
2024-10-11 23:44:50 +08:00
type: "hottest",
2024-10-26 00:00:33 +08:00
column: "tech",
2024-10-12 12:49:20 +08:00
color: "green",
2024-10-12 15:50:44 +08:00
title: "今日最热",
2024-10-09 02:53:38 +08:00
home: "https://coolapk.com",
},
2024-10-08 20:49:19 +08:00
"wallstreetcn": {
name: "华尔街见闻",
color: "blue",
2024-10-26 00:00:33 +08:00
column: "finance",
2024-10-08 20:49:19 +08:00
home: "https://wallstreetcn.com/",
2024-10-21 01:38:58 +08:00
sub: {
quick: {
type: "realtime",
interval: Time.Fast,
title: "实时快讯",
},
news: {
title: "最新资讯",
interval: Time.Common,
},
hot: {
title: "最热文章",
type: "hottest",
interval: Time.Common,
},
},
2024-10-08 20:49:19 +08:00
},
"36kr": {
name: "36氪",
2024-10-14 21:54:12 +08:00
type: "realtime",
color: "blue",
// cloudflare pages cannot access
2024-10-21 01:38:58 +08:00
disable: true,
2024-10-08 20:49:19 +08:00
home: "https://36kr.com",
sub: {
quick: {
title: "快讯",
},
},
},
"douyin": {
name: "抖音",
2024-10-11 23:44:50 +08:00
type: "hottest",
2024-10-26 00:00:33 +08:00
column: "china",
2024-10-12 12:49:20 +08:00
color: "gray",
2024-10-08 20:49:19 +08:00
home: "https://www.douyin.com",
},
"hupu": {
name: "虎扑",
2024-10-17 15:33:33 +08:00
disable: true,
2024-10-08 20:49:19 +08:00
home: "https://hupu.com",
},
"tieba": {
name: "百度贴吧",
2024-10-21 17:00:51 +08:00
title: "热议",
2024-10-26 00:00:33 +08:00
column: "china",
2024-10-21 17:00:51 +08:00
type: "hottest",
color: "blue",
2024-10-08 20:49:19 +08:00
home: "https://tieba.baidu.com",
},
"toutiao": {
name: "今日头条",
2024-10-11 23:44:50 +08:00
type: "hottest",
2024-10-26 00:00:33 +08:00
column: "china",
2024-10-12 12:49:20 +08:00
color: "red",
2024-10-08 20:49:19 +08:00
home: "https://www.toutiao.com",
},
"ithome": {
name: "IT之家",
2024-10-12 12:49:20 +08:00
color: "red",
2024-10-26 00:00:33 +08:00
column: "tech",
2024-10-14 21:54:12 +08:00
type: "realtime",
2024-10-08 20:49:19 +08:00
home: "https://www.ithome.com",
},
2024-10-14 21:54:12 +08:00
"thepaper": {
name: "澎湃新闻",
interval: Time.Common,
2024-10-21 17:00:51 +08:00
type: "hottest",
2024-10-26 00:00:33 +08:00
column: "china",
2024-10-21 17:00:51 +08:00
title: "热榜",
color: "gray",
2024-10-14 21:54:12 +08:00
home: "https://www.thepaper.cn",
},
"sputniknewscn": {
name: "卫星通讯社",
color: "orange",
// cloudflare pages cannot access
2024-10-17 15:33:33 +08:00
disable: true,
2024-10-14 21:54:12 +08:00
home: "https://sputniknews.cn",
},
"cankaoxiaoxi": {
name: "参考消息",
color: "red",
2024-10-26 00:00:33 +08:00
column: "world",
2024-10-14 21:54:12 +08:00
interval: Time.Common,
home: "https://china.cankaoxiaoxi.com",
},
2024-10-21 01:38:58 +08:00
"cls": {
name: "财联社",
color: "red",
2024-10-26 00:00:33 +08:00
column: "finance",
2024-10-21 01:38:58 +08:00
home: "https://www.cls.cn",
sub: {
telegraph: {
title: "电报",
interval: Time.Fast,
type: "realtime",
},
depth: {
2024-11-22 00:45:32 +08:00
title: "深度",
},
hot: {
title: "热门",
type: "hottest",
2024-10-21 01:38:58 +08:00
},
},
},
2024-10-21 02:18:36 +08:00
"xueqiu": {
name: "雪球",
color: "blue",
home: "https://xueqiu.com",
2024-10-26 00:00:33 +08:00
column: "finance",
2024-10-21 02:18:36 +08:00
sub: {
hotstock: {
title: "热门股票",
interval: Time.Realtime,
type: "hottest",
},
},
},
2024-10-21 03:05:50 +08:00
"gelonghui": {
name: "格隆汇",
color: "blue",
title: "事件",
2024-10-26 00:00:33 +08:00
column: "finance",
type: "realtime",
2024-10-21 03:05:50 +08:00
interval: Time.Realtime,
home: "https://www.gelonghui.com",
},
2024-10-24 22:57:00 +08:00
"fastbull": {
name: "法布财经",
color: "emerald",
home: "https://www.fastbull.cn",
2024-10-26 00:00:33 +08:00
column: "finance",
2024-10-24 22:57:00 +08:00
sub: {
express: {
title: "快讯",
type: "realtime",
interval: Time.Realtime,
},
news: {
title: "头条",
interval: Time.Common,
},
},
},
2024-10-25 11:46:53 +08:00
"solidot": {
name: "Solidot",
2024-10-25 12:05:24 +08:00
color: "teal",
2024-10-26 00:00:33 +08:00
column: "tech",
2024-10-25 11:46:53 +08:00
home: "https://solidot.org",
interval: Time.Slow,
},
2024-10-25 12:05:24 +08:00
"hackernews": {
name: "Hacker News",
color: "orange",
2024-10-26 00:00:33 +08:00
column: "tech",
2024-10-25 12:05:24 +08:00
type: "hottest",
home: "https://news.ycombinator.com/",
},
"producthunt": {
name: "Product Hunt",
2024-10-25 14:14:11 +08:00
color: "red",
2024-10-26 00:00:33 +08:00
column: "tech",
type: "hottest",
home: "https://www.producthunt.com/",
},
"github": {
name: "Github",
color: "gray",
home: "https://github.com/",
2024-10-26 00:00:33 +08:00
column: "tech",
sub: {
"trending-today": {
title: "Today",
type: "hottest",
},
},
},
"bilibili": {
name: "哔哩哔哩",
color: "blue",
home: "https://www.bilibili.com",
sub: {
"hot-search": {
title: "热搜",
2024-10-26 00:00:33 +08:00
column: "china",
type: "hottest",
},
},
},
"kuaishou": {
name: "快手",
type: "hottest",
column: "china",
color: "orange",
// cloudflare pages cannot access
2024-10-27 23:32:50 +08:00
disable: true,
home: "https://www.kuaishou.com",
},
2024-10-25 22:08:02 +08:00
"kaopu": {
name: "靠谱新闻",
2024-10-26 00:00:33 +08:00
column: "world",
2024-10-25 22:08:02 +08:00
color: "gray",
2024-10-27 17:11:59 +08:00
interval: Time.Common,
desc: "不一定靠谱,多看多思考",
2024-10-25 22:08:02 +08:00
home: "https://kaopu.news/",
},
"jin10": {
name: "金十数据",
column: "finance",
color: "blue",
2024-10-27 17:11:59 +08:00
type: "realtime",
home: "https://www.jin10.com",
},
2024-10-27 23:32:50 +08:00
"baidu": {
name: "百度热搜",
column: "china",
color: "blue",
type: "hottest",
home: "https://www.baidu.com",
},
2024-12-01 13:01:58 +08:00
"linuxdo": {
name: "LINUX DO",
column: "tech",
color: "slate",
home: "https://linux.do/",
sub: {
latest: {
title: "最新",
home: "https://linux.do/latest",
},
hot: {
title: "今日最热",
type: "hottest",
interval: Time.Common,
home: "https://linux.do/hot",
},
},
},
2024-10-08 20:49:19 +08:00
} as const satisfies Record<string, OriginSource>
export const sources = genSources()
function genSources() {
const _: [SourceID, Source][] = []
Object.entries(originSources).forEach(([id, source]: [any, OriginSource]) => {
2024-10-14 21:54:12 +08:00
const parent = {
name: source.name,
type: source.type,
2024-10-17 15:33:33 +08:00
disable: source.disable,
desc: source.desc,
2024-10-26 00:00:33 +08:00
column: source.column,
home: source.home,
2024-10-25 03:06:28 +08:00
color: source.color ?? "primary",
2024-10-14 21:54:12 +08:00
interval: source.interval ?? Time.Default,
}
2024-10-08 20:49:19 +08:00
if (source.sub && Object.keys(source.sub).length) {
Object.entries(source.sub).forEach(([subId, subSource], i) => {
if (i === 0) {
_.push([id, {
redirect: `${id}-${subId}`,
2024-10-14 21:54:12 +08:00
...parent,
2024-10-08 20:49:19 +08:00
...subSource,
}] as [any, Source])
}
2024-10-14 21:54:12 +08:00
_.push([`${id}-${subId}`, { ...parent, ...subSource }] as [any, Source])
2024-10-08 20:49:19 +08:00
})
} else {
_.push([id, {
title: source.title,
2024-10-14 21:54:12 +08:00
...parent,
2024-10-08 20:49:19 +08:00
}])
}
})
2024-10-17 15:33:33 +08:00
return typeSafeObjectFromEntries(_.filter(([_, v]) => !v.disable))
2024-10-08 20:49:19 +08:00
}