From aca476dd8ff6d29dff7c800a8964b6549b285235 Mon Sep 17 00:00:00 2001 From: dxxxxxxx <31104430+d380025303@users.noreply.github.com> Date: Fri, 4 Apr 2025 19:20:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=AE=9E=E6=97=B6new?= =?UTF-8?q?s-=E6=9E=9C=E6=A0=B8=E5=89=A5=E5=A3=B3=20(#106)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: daixin --- public/icons/ghxi.png | Bin 0 -> 5143 bytes server/glob.d.ts | 1 + server/sources/ghxi.ts | 57 +++++++++++++++++++++++++++++++ shared/pinyin.json | 8 ++++- shared/pre-sources.ts | 7 ++++ shared/sources.json | 75 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 public/icons/ghxi.png create mode 100644 server/sources/ghxi.ts diff --git a/public/icons/ghxi.png b/public/icons/ghxi.png new file mode 100644 index 0000000000000000000000000000000000000000..96aca61cece97497db884f2f8799f444262ecaeb GIT binary patch literal 5143 zcmV+y6zJ=TP)(RCt`_oOyH{#hu5$Rn^^dU%DmR@_k@zV`3bzjSUzZaDbPP z3wCW|4hJ@Q>`Q<^Hk+{7>_S2w$!0n2uz@77g((A|4haZ*-a%9M-J{kbYTCn z`nvkskD41B+FDv1C)?*|oO9E({K4Re$}uA#6oHu>O*a?#i(;Onl0InUcU>*U%Avm)PFrc8QX!5j~*8TOhT~(Wj$Wh2jO4y_bWf9>w5wI|+%q$Et!C-LW44NP{ zY!}T*UE8J-8FV^yETI`g$iw^|?z6boG=26Zv*ygbWZr^cI6NqR;_R8zovAlod-<)u zyb?chSQ3&MBy1h=^AS;g!AN6t0h?A~lt;PAsUX0876SlAU;qIGrD10&nI+prJVATn zvbG&N>g3T@-ICHFFAIBN3FZriu2^#2q9xatR8*W}=GR~T(~B=W*WTKqG@6r2N}5t; zTs+>GH{O^~%*(>uu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.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