From 7e698e2320a94308ac34afc66e305194651cae93 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 11 Dec 2023 20:21:16 +0800 Subject: [PATCH] fix: radar.js with type errors --- lib/v2/cste/radar.js | 2 +- lib/v2/dahecube/radar.js | 42 ++++++++++++++++++++++++++++++++++--- lib/v2/fosshub/radar.js | 2 +- lib/v2/gov/radar.js | 4 ++-- lib/v2/mihoyo/radar.js | 2 +- lib/v2/nmtv/radar.js | 2 +- lib/v2/oo-software/radar.js | 2 +- lib/v2/thepaper/radar.js | 4 ++-- 8 files changed, 48 insertions(+), 12 deletions(-) diff --git a/lib/v2/cste/radar.js b/lib/v2/cste/radar.js index 7ff2dad62901f0..2792273572723c 100644 --- a/lib/v2/cste/radar.js +++ b/lib/v2/cste/radar.js @@ -6,7 +6,7 @@ module.exports = { title: '栏目', docs: 'https://docs.rsshub.app/routes/study#zhong-guo-ji-shu-jing-ji-xue-hui-lan-mu', source: ['/site/term', '/'], - target: (params, url) => `/cste/${new URL(url).match(/site\/term\/(\d+)\.html/)[1]}`, + target: (params, url) => `/cste/${url.match(/site\/term\/(\d+)\.html/)[1]}`, }, ], }, diff --git a/lib/v2/dahecube/radar.js b/lib/v2/dahecube/radar.js index 1c739b4c4b6a71..9bb1d54f62430f 100644 --- a/lib/v2/dahecube/radar.js +++ b/lib/v2/dahecube/radar.js @@ -1,5 +1,3 @@ -const utils = require('./utils'); - module.exports = { 'dahecube.com': { _name: '大河财立方', @@ -11,7 +9,45 @@ module.exports = { target: (_, url) => { const id = new URL(url).searchParams.get('recid'); let type = 'recommend'; - Object.entries(utils.TYPE).forEach(([key, value]) => { + const TypeMap = { + recommend: { + name: '推荐', + id: 1, + }, + history: { + name: '党史', + id: 37, + }, + stock: { + name: '豫股', + id: 2, + }, + business: { + name: '财经', + id: 4, + }, + education: { + name: '投教', + id: 36, + }, + finance: { + name: '金融', + id: 5, + }, + science: { + name: '科创', + id: 19, + }, + invest: { + name: '投融', + id: 29, + }, + column: { + name: '专栏', + id: 33, + }, + }; + Object.entries(TypeMap).forEach(([key, value]) => { if (value.id === id) { type = key; } diff --git a/lib/v2/fosshub/radar.js b/lib/v2/fosshub/radar.js index 9b88363b8c4007..26e437f7a63fed 100644 --- a/lib/v2/fosshub/radar.js +++ b/lib/v2/fosshub/radar.js @@ -6,7 +6,7 @@ module.exports = { title: 'Software Update', docs: 'https://docs.rsshub.app/routes/program-update#fosshub-software-update', source: ['/'], - target: (params, url) => `/fosshub/${new URL(url).match(/\/(.*?)\.html$/)[1]}`, + target: (params, url) => `/fosshub/${url.match(/\/(.*?)\.html$/)[1]}`, }, ], }, diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 0417214b63eee3..99ccc6807089d8 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -424,7 +424,7 @@ module.exports = { title: '新闻中心', docs: 'https://docs.rsshub.app/routes/government#zhong-guo-hu-lian-wang-luo-xin-xi-zhong-xin-xin-wen-zhong-xin', source: ['/'], - target: (params, url) => `/gov/cnnic/${new URL(url).match(/cnnic\.net\.cn\/(.*)/)[1]}`, + target: (params, url) => `/gov/cnnic/${url.match(/cnnic\.net\.cn\/(.*)/)[1]}`, }, ], }, @@ -1255,7 +1255,7 @@ module.exports = { title: '上海市药品监督管理局', docs: 'https://docs.rsshub.app/routes/government#shang-hai-shi-ren-min-zheng-fu-shang-hai-shi-yao-pin-jian-du-guan-li-ju', source: ['/'], - target: (params, url) => `/gov/shanghai/yjj/${new URL(url).match(/yjj\.sh\.gov\.cn\/(.*)\/index.html/)[1]}`, + target: (params, url) => `/gov/shanghai/yjj/${url.match(/yjj\.sh\.gov\.cn\/(.*)\/index.html/)[1]}`, }, ], 'wsbs.wgj': [ diff --git a/lib/v2/mihoyo/radar.js b/lib/v2/mihoyo/radar.js index 17dd1eac02a377..e7a61d00aa725d 100644 --- a/lib/v2/mihoyo/radar.js +++ b/lib/v2/mihoyo/radar.js @@ -45,7 +45,7 @@ module.exports = { if (!gids) { return ''; } - const { type = '2' } = new URL(url).searchParams; + const type = new URL(url).searchParams.get('type') || '1'; const page_size = '20'; const last_id = ''; return `/mihoyo/bbs/official/${gids}/${type}/${page_size}/${last_id}`; diff --git a/lib/v2/nmtv/radar.js b/lib/v2/nmtv/radar.js index c80a7853fdf151..a12b44da235eba 100644 --- a/lib/v2/nmtv/radar.js +++ b/lib/v2/nmtv/radar.js @@ -6,7 +6,7 @@ module.exports = { title: '点播', docs: 'https://docs.rsshub.app/routes/traditional-media#nei-meng-gu-guang-bo-dian-shi-tai-dian-bo', source: ['/'], - target: (params, url) => `/nmtv/column/${new URL(url).toString.split(/\/folder/).pop()}`, + target: (params, url) => `/nmtv/column/${url.split(/\/folder/).pop()}`, }, ], }, diff --git a/lib/v2/oo-software/radar.js b/lib/v2/oo-software/radar.js index f45c64fa4204a7..5a46eab78e6c73 100644 --- a/lib/v2/oo-software/radar.js +++ b/lib/v2/oo-software/radar.js @@ -6,7 +6,7 @@ module.exports = { title: 'Changelog', docs: 'https://docs.rsshub.app/routes/program-update#oo-software-changelog', source: ['/en/changelog'], - target: (params, url) => `/oo-software/changelog/${new URL(url).match(/\/en\/(.*?)\/changelog/)[1]}`, + target: (params, url) => `/oo-software/changelog/${url.match(/\/en\/(.*?)\/changelog/)[1]}`, }, ], }, diff --git a/lib/v2/thepaper/radar.js b/lib/v2/thepaper/radar.js index 32068ca371aa73..2f0b5230a1eadd 100644 --- a/lib/v2/thepaper/radar.js +++ b/lib/v2/thepaper/radar.js @@ -18,13 +18,13 @@ module.exports = { title: '频道', docs: 'https://docs.rsshub.app/routes/traditional-media#peng-pai-xin-wen-pin-dao', source: ['/'], - target: (params, url) => `/thepaper/channel/${new URL(url).search(/channel_(\d+)/)}`, + target: (params, url) => `/thepaper/channel/${url.match(/channel_(\d+)/)?.[1]}`, }, { title: '栏目', docs: 'https://docs.rsshub.app/routes/traditional-media#peng-pai-xin-wen-lie-biao', source: ['/'], - target: (params, url) => `/thepaper/list/${new URL(url).search(/list_(\d+)/)}`, + target: (params, url) => `/thepaper/list/${url.search(/list_(\d+)/)?.[1]}`, }, { title: '澎湃美数组作品集',