mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
207 lines
4.3 KiB
TypeScript
207 lines
4.3 KiB
TypeScript
import { Interval } from "./consts"
|
|
import { typeSafeObjectFromEntries } from "./type.util"
|
|
import type { OriginSource, Source, SourceID } from "./types"
|
|
|
|
const Time = {
|
|
Test: 1,
|
|
Realtime: 2 * 60 * 1000,
|
|
Fast: 5 * 60 * 1000,
|
|
Default: Interval, // 10min
|
|
Common: 30 * 60 * 1000,
|
|
Slow: 60 * 60 * 1000,
|
|
}
|
|
|
|
export const originSources = {
|
|
"v2ex": {
|
|
name: "V2EX",
|
|
color: "slate",
|
|
home: "https://v2ex.com/",
|
|
sub: {
|
|
share: {
|
|
title: "最新分享",
|
|
},
|
|
},
|
|
},
|
|
"zhihu": {
|
|
name: "知乎",
|
|
type: "hottest",
|
|
color: "blue",
|
|
home: "https://www.zhihu.com",
|
|
},
|
|
"weibo": {
|
|
name: "微博",
|
|
title: "实时热搜",
|
|
type: "hottest",
|
|
color: "red",
|
|
interval: Time.Realtime,
|
|
home: "https://weibo.com",
|
|
},
|
|
"zaobao": {
|
|
name: "联合早报",
|
|
interval: Time.Common,
|
|
type: "realtime",
|
|
color: "red",
|
|
home: "https://www.zaobao.com",
|
|
},
|
|
"coolapk": {
|
|
name: "酷安",
|
|
type: "hottest",
|
|
color: "green",
|
|
title: "今日最热",
|
|
home: "https://coolapk.com",
|
|
},
|
|
"wallstreetcn": {
|
|
name: "华尔街见闻",
|
|
color: "blue",
|
|
home: "https://wallstreetcn.com/",
|
|
sub: {
|
|
quick: {
|
|
type: "realtime",
|
|
interval: Time.Fast,
|
|
title: "实时快讯",
|
|
},
|
|
news: {
|
|
title: "最新资讯",
|
|
interval: Time.Common,
|
|
},
|
|
hot: {
|
|
title: "最热文章",
|
|
type: "hottest",
|
|
interval: Time.Common,
|
|
},
|
|
},
|
|
},
|
|
"36kr": {
|
|
name: "36氪",
|
|
type: "realtime",
|
|
color: "blue",
|
|
disable: true,
|
|
home: "https://36kr.com",
|
|
sub: {
|
|
quick: {
|
|
title: "快讯",
|
|
},
|
|
},
|
|
},
|
|
"douyin": {
|
|
name: "抖音",
|
|
type: "hottest",
|
|
color: "gray",
|
|
home: "https://www.douyin.com",
|
|
},
|
|
"hupu": {
|
|
name: "虎扑",
|
|
disable: true,
|
|
home: "https://hupu.com",
|
|
},
|
|
"tieba": {
|
|
name: "百度贴吧",
|
|
title: "热议",
|
|
type: "hottest",
|
|
color: "blue",
|
|
home: "https://tieba.baidu.com",
|
|
},
|
|
"toutiao": {
|
|
name: "今日头条",
|
|
type: "hottest",
|
|
color: "red",
|
|
home: "https://www.toutiao.com",
|
|
},
|
|
"ithome": {
|
|
name: "IT之家",
|
|
color: "red",
|
|
type: "realtime",
|
|
home: "https://www.ithome.com",
|
|
},
|
|
"thepaper": {
|
|
name: "澎湃新闻",
|
|
interval: Time.Common,
|
|
type: "hottest",
|
|
title: "热榜",
|
|
color: "gray",
|
|
home: "https://www.thepaper.cn",
|
|
},
|
|
"sputniknewscn": {
|
|
name: "卫星通讯社",
|
|
color: "orange",
|
|
disable: true,
|
|
home: "https://sputniknews.cn",
|
|
},
|
|
"cankaoxiaoxi": {
|
|
name: "参考消息",
|
|
color: "red",
|
|
interval: Time.Common,
|
|
home: "https://china.cankaoxiaoxi.com",
|
|
},
|
|
"cls": {
|
|
name: "财联社",
|
|
color: "red",
|
|
home: "https://www.cls.cn",
|
|
sub: {
|
|
telegraph: {
|
|
title: "电报",
|
|
interval: Time.Fast,
|
|
type: "realtime",
|
|
},
|
|
depth: {
|
|
title: "深度头条",
|
|
interval: Time.Common,
|
|
},
|
|
},
|
|
},
|
|
"xueqiu": {
|
|
name: "雪球",
|
|
color: "blue",
|
|
home: "https://xueqiu.com",
|
|
sub: {
|
|
hotstock: {
|
|
title: "热门股票",
|
|
interval: Time.Realtime,
|
|
type: "hottest",
|
|
},
|
|
},
|
|
},
|
|
"gelonghui": {
|
|
name: "格隆汇",
|
|
color: "blue",
|
|
title: "事件",
|
|
type: "realtime",
|
|
interval: Time.Realtime,
|
|
home: "https://www.gelonghui.com",
|
|
},
|
|
} as const satisfies Record<string, OriginSource>
|
|
|
|
export const sources = genSources()
|
|
function genSources() {
|
|
const _: [SourceID, Source][] = []
|
|
|
|
Object.entries(originSources).forEach(([id, source]: [any, OriginSource]) => {
|
|
const parent = {
|
|
name: source.name,
|
|
type: source.type,
|
|
disable: source.disable,
|
|
color: source.color ?? "red",
|
|
interval: source.interval ?? Time.Default,
|
|
}
|
|
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}-${subId}`, { ...parent, ...subSource }] as [any, Source])
|
|
})
|
|
} else {
|
|
_.push([id, {
|
|
title: source.title,
|
|
...parent,
|
|
}])
|
|
}
|
|
})
|
|
|
|
return typeSafeObjectFromEntries(_.filter(([_, v]) => !v.disable))
|
|
}
|