diff --git a/public/icons/nowcoder.png b/public/icons/nowcoder.png new file mode 100644 index 0000000..91f68b8 Binary files /dev/null and b/public/icons/nowcoder.png differ 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",