From 72f0c02f84fbf7f71b04e2c894d6482743d36efb Mon Sep 17 00:00:00 2001 From: urlyy Date: Fri, 4 Apr 2025 19:22:23 +0800 Subject: [PATCH] feat: add source nowcoder (#116) Co-authored-by: Ou --- public/icons/nowcoder.png | Bin 0 -> 1560 bytes server/glob.d.ts | 1 + server/sources/nowcoder.ts | 33 +++++++++++++++++++++++++++++++++ shared/pinyin.json | 1 + shared/pre-sources.ts | 7 +++++++ shared/sources.json | 8 ++++++++ 6 files changed, 50 insertions(+) create mode 100644 public/icons/nowcoder.png create mode 100644 server/sources/nowcoder.ts diff --git a/public/icons/nowcoder.png b/public/icons/nowcoder.png new file mode 100644 index 0000000000000000000000000000000000000000..91f68b85ab4185f03237c029955c3c6864a9a82c GIT binary patch literal 1560 zcma)5S5T7)5dLXWMnnft@YLfTET=Lip(l~z0TLrE(mX{G0V#4)qJSbMK$Ie)o;Q?) z6q+JZqIiHv2J}RM(3DfSLy#hnAdo^5YWCvG&D?`Cx3jz7?CyN??Za-Sm&aj!y{&o( zg6I?6oJlG)`x-hLs_a~v)%LYG>qc@%kjuLegp!UR%c>S-8bL0i5JVV+AlQ5a*%HHe z=8Z=X^%1Y5J}&V8OfHuzl}d$Tv8%hch+VR}x>{0R(e|c8AQT1!22*L75{b0Cw~yb| z)78^EFB09z&OH`zYGUGZWmT=Y1@>H2j7%nfRL!+H=xl{MWQB7oWUv>PmSV_B`_Q)R zlJfM7oBJ_#kL&8`%;E!9_{3ytVG%o@&bpkEYHo>3yOG`4)Qoj>O{S#NGIRE#ZQ~P? zB~ob-tE985=fl9DE76iJQMM`6>owduPu~;l(u&!6F@ssWva&ibG%S`# zMUsW`${KIKljRR8Wpc&TCXuJj#Q;64qdpPLl0<1Au#r*DGg+lSBgWvMv4_?cQ z=e*XJZSA7*LEs#NSOkjwVBrf4G(esckToI27@j7<+z51+L)Km(YrriG$iB?Z%~e*{ zj;WR}_JvqAkk13Z81C3W=5FX@fl>)E2wc*J`eay`sc&quuybUvOF<@t5`TzO12zdH zQy`y%=QK#rgYrOFT?VNDXl8K7x|!G7(8LoA_k(15O{tuk7QnI``W`_;3JBiA<2WF% z1C}R9CK#+zco+&CUl4!(d*~y{Kd|KfLy*lt+0SrM8q+}CxX&%WIt=- z5xx9fi6j@IH^IYaWo2b@YI<5ASYBREd50sbeqcSBySn3v*I6UM4s@`Pg=z4GIbg4jXON3&<}pF*OMo z97u{$zhv#VZiB}TJmuFkYPR-)Pr;wsYAAHILsAK+QzZT=-AqqYlZGD zF^#`JN`0EcsVZtN)ZnKa-hFP%K7X5p2HhRZQ^R=sND@kmm!ib0QJq?2w0_{68QpXz zQr)``%|*wG@w%CW_8%)E1Sl=jg5!gBjY*M9n! zbKJYkBdelkw-*I|JlK47%@DK8qYxh|w7i`vun6ncV|8he(^|IWHcAt-rVdPdB9Va& z;bQ(yVjjBR$NV%m&e*`sNh!3t9`&JWq&C)Ypn_h1K9CoU)9ATnjw2?xd#)=m<6h|* zmR*%9W*t7gh!=T{^Rr&+n%V5f#gRL>TIIpwG%{j6r=txwmK7pswDmsp{@amETwGMH6Ywp zH*qA177A*1nJi`n`EIDFjnR$OO^YeQCN&M z7KPr2LSa!TBUh>6e+bbRLL$PFzD)@Ij`&q!&%X-fi0IIG@|ozEZ*wpkB4bn>gy7=g JTzx1g^&cn~L`MJs literal 0 HcmV?d00001 diff --git a/server/glob.d.ts b/server/glob.d.ts index 8da10ab..ab010ba 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -18,6 +18,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const kaopu: typeof import('./sources/kaopu') export const kuaishou: typeof import('./sources/kuaishou') export const linuxdo: typeof import('./sources/linuxdo') + export const nowcoder: typeof import('./sources/nowcoder') export const producthunt: typeof import('./sources/producthunt') export const solidot: typeof import('./sources/solidot') export const sputniknewscn: typeof import('./sources/sputniknewscn') diff --git a/server/sources/nowcoder.ts b/server/sources/nowcoder.ts new file mode 100644 index 0000000..a131d7a --- /dev/null +++ b/server/sources/nowcoder.ts @@ -0,0 +1,33 @@ +interface Res { + data: { + result: { + id: string + title: string + type: number + uuid: string + hotValueFromDolphin: number + } + } +} + +export default defineSource(async () => { + const timestamp = Date.now() + const url = `https://gw-c.nowcoder.com/api/sparta/hot-search/top-hot-pc?size=20&_=${timestamp}&t=` + const res: Res = await myFetch(url) + return res.data.result + .map((k) => { + let url, id + if (k.type === 74) { + url = `https://www.nowcoder.com/feed/main/detail/${k.uuid}` + id = k.uuid + } else if (k.type === 0) { + url = `https://www.nowcoder.com/discuss/${k.id}` + id = k.id + } + return { + id, + title: k.title, + url, + } + }) +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index 2a74178..99776d6 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -31,6 +31,7 @@ "kaopu": "kaopuxinwen", "jin10": "jinshishuju", "baidu": "baiduresou", + "nowcoder": "niuke", "linuxdo-latest": "LINUX DO-zuixin", "linuxdo-hot": "LINUX DO-jinrizuire", "ghxi": "guoheboke" diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index 5bfcf21..33e2c27 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -286,6 +286,13 @@ 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", diff --git a/shared/sources.json b/shared/sources.json index 622453d..7906c84 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -350,6 +350,14 @@ "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",