diff --git a/public/icons/ghxi.png b/public/icons/ghxi.png new file mode 100644 index 0000000..96aca61 Binary files /dev/null and b/public/icons/ghxi.png differ diff --git a/server/glob.d.ts b/server/glob.d.ts index 87779e6..8da10ab 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -10,6 +10,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const douyin: typeof import('./sources/douyin') export const fastbull: typeof import('./sources/fastbull') export const gelonghui: typeof import('./sources/gelonghui') + export const ghxi: typeof import('./sources/ghxi') export const github: typeof import('./sources/github') export const hackernews: typeof import('./sources/hackernews') export const ithome: typeof import('./sources/ithome') diff --git a/server/sources/ghxi.ts b/server/sources/ghxi.ts new file mode 100644 index 0000000..d30991c --- /dev/null +++ b/server/sources/ghxi.ts @@ -0,0 +1,57 @@ +import * as cheerio from "cheerio" +import type { NewsItem } from "@shared/types" + +const relativeTimeToDate = function (timeStr) { + const units = { + 秒: 1000, + 分钟: 60 * 1000, + 小时: 60 * 60 * 1000, + 天: 24 * 60 * 60 * 1000, + 周: 7 * 24 * 60 * 60 * 1000, + 月: 30 * 24 * 60 * 60 * 1000, + 年: 365 * 24 * 60 * 60 * 1000, + } + + const match = timeStr.match(/^(\d+)\s*([秒天周月年]|分钟|小时)/) + if (!match) { + return "" + } + + const num = Number.parseInt(match[1]) + const unit = match[2] + const msAgo = num * units[unit] + + return new Date(Date.now() - msAgo).valueOf() +} + +export default defineSource(async () => { + const html: any = await myFetch("https://www.ghxi.com/category/all") + const $ = cheerio.load(html) + const news: NewsItem[] = [] + $(".sec-panel .sec-panel-body .post-loop li").each((i, elem) => { + let summary_title = $(elem).find(".item-content .item-title").text() + if (summary_title) { + summary_title = summary_title.trim() + summary_title = summary_title.replaceAll("'", "''") + } + let summary_description = $(elem).find(".item-content .item-excerpt").text() + if (summary_description) { + summary_description = summary_description.trim() + summary_description = summary_description.replaceAll("'", "''") + } + const date = $(elem).find(".item-content .date").text() + console.log(date) + const url = $(elem).find(".item-content .item-title a").attr("href") + news.push({ + id: url, + url, + title: summary_title, + extra: { + hover: summary_description, + date: relativeTimeToDate(date), + }, + }) + }) + + return news +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index c4b1ea3..2a74178 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -7,11 +7,13 @@ "wallstreetcn-quick": "huaerjiejianwen-shishikuaixun", "wallstreetcn-news": "huaerjiejianwen-zuixinzixun", "wallstreetcn-hot": "huaerjiejianwen-zuirewenzhang", + "36kr-quick": "36ke-kuaixun", "douyin": "douyin", "tieba": "baidutieba-reyi", "toutiao": "jinritoutiao", "ithome": "ITzhijia", "thepaper": "pengpaixinwen-rebang", + "sputniknewscn": "weixingtongxunshe", "cankaoxiaoxi": "cankaoxiaoxi", "cls-telegraph": "cailianshe-dianbao", "cls-depth": "cailianshe-shendu", @@ -25,7 +27,11 @@ "producthunt": "Product Hunt", "github-trending-today": "Github-Today", "bilibili-hot-search": "bilibili-resou", + "kuaishou": "kuaishou", "kaopu": "kaopuxinwen", "jin10": "jinshishuju", - "baidu": "baiduresou" + "baidu": "baiduresou", + "linuxdo-latest": "LINUX DO-zuixin", + "linuxdo-hot": "LINUX DO-jinrizuire", + "ghxi": "guoheboke" } \ No newline at end of file diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index cb20b20..5bfcf21 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -305,6 +305,13 @@ export const originSources = { }, }, }, + "ghxi": { + name: "果核剥壳", + column: "china", + color: "green", + type: "realtime", + home: "https://www.ghxi.com/", + }, } as const satisfies Record export function genSources() { diff --git a/shared/sources.json b/shared/sources.json index af34e41..622453d 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -87,6 +87,27 @@ "interval": 1800000, "title": "最热文章" }, + "36kr": { + "redirect": "36kr-quick", + "name": "36氪", + "type": "realtime", + "disable": "cf", + "column": "tech", + "home": "https://36kr.com", + "color": "blue", + "interval": 600000, + "title": "快讯" + }, + "36kr-quick": { + "name": "36氪", + "type": "realtime", + "disable": "cf", + "column": "tech", + "home": "https://36kr.com", + "color": "blue", + "interval": 600000, + "title": "快讯" + }, "douyin": { "name": "抖音", "type": "hottest", @@ -129,6 +150,14 @@ "color": "gray", "interval": 1800000 }, + "sputniknewscn": { + "name": "卫星通讯社", + "disable": "cf", + "column": "world", + "home": "https://sputniknews.cn", + "color": "orange", + "interval": 600000 + }, "cankaoxiaoxi": { "name": "参考消息", "column": "world", @@ -288,6 +317,15 @@ "interval": 600000, "title": "热搜" }, + "kuaishou": { + "name": "快手", + "type": "hottest", + "disable": "cf", + "column": "china", + "home": "https://www.kuaishou.com", + "color": "orange", + "interval": 600000 + }, "kaopu": { "name": "靠谱新闻", "desc": "不一定靠谱,多看多思考", @@ -311,5 +349,42 @@ "home": "https://www.baidu.com", "color": "blue", "interval": 600000 + }, + "linuxdo": { + "redirect": "linuxdo-latest", + "name": "LINUX DO", + "disable": "cf", + "column": "tech", + "home": "https://linux.do/latest", + "color": "slate", + "interval": 600000, + "title": "最新" + }, + "linuxdo-latest": { + "name": "LINUX DO", + "disable": "cf", + "column": "tech", + "home": "https://linux.do/latest", + "color": "slate", + "interval": 600000, + "title": "最新" + }, + "linuxdo-hot": { + "name": "LINUX DO", + "type": "hottest", + "disable": "cf", + "column": "tech", + "home": "https://linux.do/hot", + "color": "slate", + "interval": 1800000, + "title": "今日最热" + }, + "ghxi": { + "name": "果核剥壳", + "type": "realtime", + "column": "china", + "home": "https://www.ghxi.com/", + "color": "green", + "interval": 600000 } } \ No newline at end of file