From 9efda2ab67227ab0b2600c5d6373e924b5ce2b40 Mon Sep 17 00:00:00 2001 From: urlyy Date: Mon, 7 Apr 2025 00:15:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20source=20=E4=BB=80=E4=B9=88?= =?UTF-8?q?=E5=80=BC=E5=BE=97=E4=B9=B0=20(#117)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add source 什么值得买 * 恢复sources.json的缩进 --- public/icons/smzdm.png | Bin 0 -> 2262 bytes server/glob.d.ts | 1 + server/sources/smzdm.ts | 21 +++++++++++++++++++++ shared/pinyin.json | 5 +++-- shared/pre-sources.ts | 21 ++++++++++++++------- shared/sources.json | 24 ++++++++++++++++-------- 6 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 public/icons/smzdm.png create mode 100644 server/sources/smzdm.ts diff --git a/public/icons/smzdm.png b/public/icons/smzdm.png new file mode 100644 index 0000000000000000000000000000000000000000..b074991f2849e6e5c1adac71c0ef2bd87715483a GIT binary patch literal 2262 zcmZ`*Wl+=&6aS->geRqhgm{Dj9C5@QNF5~zM;zUC2OJQo6Z*nVifj;QK80COc&&bjjLzl4}HVsF`e6H9s4m2L^85?u;G|1D=`agsc@IskAMt5mXmViYF%ZCYLnv( zr4?{|(^+u8UJk(15ROf6|1y&IJpy^9G1reAWT!i>7|Za<_fnJLraL(+3$mAjE2xHk z>EqgA+gOqL`L!sLd6|ZjW=~34$dgYerCHa_N*`(7`w{G5_!|kOSOcDLG8dQf1xiG{ z?cs=4IzbXr&SQ|%e3C27iXS_NL`h~(VTU`S{PnXViDg`Wc7&a$*{4E2&aZZdoL8T> z7RgLAaNaQ5%n8FU8jM~GWQTUqopYDTSzh^BTI|aRp#OHfN=`V>E-JQ1Hc{gCIM`F{ z=89s#ls%|;B#DUNTaIS z@@24Tx>$b(AxDzNQ3Fzt^V!UmR;Kcb;kRcs?W(d@C&hmw=p`zL)O0B^NVOD1>T7M zIPB9%ihJis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q_6`Id)#5+xy2|QNY=PhQ>g#v$aH`{Wns!A}f`}i3uZ1(z`*F z()I{&nX~?t1y7ywkz8tAf7MH_grOzq3DVM;Pt2<94|_FN?b@u03-yVOonRpM<|9xa z#$;rr`0aFH7QXn?J-5C{s>im578b$FKY7ihDf$2cp?m7{AZRIFXGFB5A|L)7`)Wi1 z?tpp9x+v>dR-7qS(?H(em^k$?J{ez;&&E3|+R9=F84*2LrhqOa=yjgfa6xa)PrIvP z7;!I8B4y{OW_J3IKhz?^(t&I}+0k%EdrWX{+`QW7R91%pCw zK_D;)WG=8P^Zx*z-p+2W!T$|Nz7=}*XaJ)BtKjeE>Eh?_;CcVQG3|Hk4$d%uj)p#> IT+Kf6U*~Qk!~g&Q literal 0 HcmV?d00001 diff --git a/server/glob.d.ts b/server/glob.d.ts index 7e06641..5e4ba07 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -21,6 +21,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const nowcoder: typeof import('./sources/nowcoder') export const pcbeta: typeof import('./sources/pcbeta') export const producthunt: typeof import('./sources/producthunt') + export const smzdm: typeof import('./sources/smzdm') export const solidot: typeof import('./sources/solidot') export const sputniknewscn: typeof import('./sources/sputniknewscn') export const thepaper: typeof import('./sources/thepaper') diff --git a/server/sources/smzdm.ts b/server/sources/smzdm.ts new file mode 100644 index 0000000..403fb41 --- /dev/null +++ b/server/sources/smzdm.ts @@ -0,0 +1,21 @@ +import * as cheerio from "cheerio" +import type { NewsItem } from "@shared/types" + +export default defineSource(async () => { + const baseURL = "https://post.smzdm.com/hot_1/" + const html: any = await myFetch(baseURL) + const $ = cheerio.load(html) + const $main = $("#feed-main-list .z-feed-title") + const news: NewsItem[] = [] + $main.each((_, el) => { + const a = $(el).find("a") + const url = a.attr("href")! + const title = a.text() + news.push({ + url, + title, + id: url, + }) + }) + return news +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index 7905315..00f7177 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -33,8 +33,9 @@ "kaopu": "kaopuxinwen", "jin10": "jinshishuju", "baidu": "baiduresou", - "nowcoder": "niuke", "linuxdo-latest": "LINUX DO-zuixin", "linuxdo-hot": "LINUX DO-jinrizuire", - "ghxi": "guoheboke" + "ghxi": "guoheboke", + "smzdm": "shenmezhidemai", + "nowcoder": "niuke" } \ No newline at end of file diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index de3cddb..79ccd63 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -304,13 +304,6 @@ export const originSources = { type: "hottest", home: "https://www.baidu.com", }, - "nowcoder": { - name: "牛客", - column: "china", - color: "blue", - type: "hottest", - home: "https://www.nowcoder.com", - }, "linuxdo": { name: "LINUX DO", column: "tech", @@ -337,6 +330,20 @@ export const originSources = { disable: "cf", home: "https://www.ghxi.com/", }, + "smzdm": { + name: "什么值得买", + column: "china", + color: "red", + type: "hottest", + home: "https://www.smzdm.com", + }, + "nowcoder": { + name: "牛客", + column: "china", + color: "blue", + type: "hottest", + home: "https://www.nowcoder.com", + }, } as const satisfies Record export function genSources() { diff --git a/shared/sources.json b/shared/sources.json index 1f18884..e2edf60 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -378,14 +378,6 @@ "color": "blue", "interval": 600000 }, - "nowcoder": { - "name": "牛客", - "type": "hottest", - "column": "china", - "home": "https://www.nowcoder.com", - "color": "blue", - "interval": 600000 - }, "linuxdo": { "redirect": "linuxdo-latest", "name": "LINUX DO", @@ -422,5 +414,21 @@ "home": "https://www.ghxi.com/", "color": "yellow", "interval": 600000 + }, + "smzdm": { + "name": "什么值得买", + "type": "hottest", + "column": "china", + "home": "https://www.smzdm.com", + "color": "red", + "interval": 600000 + }, + "nowcoder": { + "name": "牛客", + "type": "hottest", + "column": "china", + "home": "https://www.nowcoder.com", + "color": "blue", + "interval": 600000 } } \ No newline at end of file