Skip to content

Commit 9d980d7

Browse files
committed
feat: v3 migration - 16/n
1 parent 300d450 commit 9d980d7

File tree

18 files changed

+49
-41
lines changed

18 files changed

+49
-41
lines changed

lib/v2/aqara/region.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = (ctx) => {
2+
const types = {
3+
news: 'press-release',
4+
blog: 'article',
5+
};
6+
7+
const { region = 'en', type = 'news' } = ctx.req.param();
8+
const redirectTo = `/aqara/${region}/category/${types[type]}`;
9+
ctx.redirect(redirectTo);
10+
};

lib/v2/aqara/router.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
module.exports = function (router) {
22
router.get('/cn/news', './news');
33
router.get('/community/:id?/:keyword?', './community');
4-
router.get('/:region/:type?', (ctx) => {
5-
const types = {
6-
news: 'press-release',
7-
blog: 'article',
8-
};
9-
10-
const { region = 'en', type = 'news' } = ctx.req.param();
11-
const redirectTo = `/aqara/${region}/category/${types[type]}`;
12-
ctx.redirect(redirectTo);
13-
});
4+
router.get('/:region/:type?', './region');
145
router.get('*', './post');
156
};

lib/v2/buaa/sme.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
1616
// 源链接
1717
link: url,
1818
// 源文章
19-
item: await getItems(ctx, list),
19+
item: await getItems(list),
2020
});
2121
};
2222

@@ -46,7 +46,7 @@ async function getList(url) {
4646
};
4747
}
4848

49-
function getItems(ctx, list) {
49+
function getItems(list) {
5050
return Promise.all(
5151
list.map((item) =>
5252
cache.tryGet(item.link, async () => {

lib/v2/dongqiudi/daily.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = (ctx) => {
2+
ctx.redirect('/dongqiudi/special/48');
3+
};

lib/v2/dongqiudi/router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = (router) => {
2-
router.get('/daily', (c) => c.redirect('/dongqiudi/special/48'));
2+
router.get('/daily', './daily');
33
router.get('/player_news/:id', './player-news');
44
router.get('/result/:team', './result');
55
router.get('/special/:id', './special');

lib/v2/getitfree/router.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
module.exports = (router) => {
2-
router.get('/:filter*', (ctx) => {
3-
const { filter } = ctx.req.param();
4-
5-
if (filter && !filter.includes('/') && !filter.includes(',')) {
6-
ctx.redirect(`/getitfree/category/${filter}`);
7-
} else {
8-
return './'(ctx);
9-
}
10-
});
2+
router.get('/:filter*', './index');
113
};

lib/v2/hostmonit/cloudflareyesv6.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = (ctx) => {
2+
ctx.redirect('/hostmonit/cloudflareyes/v6');
3+
};

lib/v2/hostmonit/router.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
const redirectToV6 = (ctx) => ctx.redirect('/hostmonit/cloudflareyes/v6');
2-
31
module.exports = (router) => {
42
router.get('/cloudflareyes/:type?', './cloudflareyes');
5-
router.get('/cloudflareyesv6', (ctx) => redirectToV6(ctx));
6-
router.get('/CloudFlareYes/:type?', './cloudflareyes');
7-
router.get('/CloudFlareYesv6', (ctx) => redirectToV6(ctx));
3+
router.get('/cloudflareyesv6', './cloudflareyesv6');
84
};

lib/v2/jiemian/list.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = (ctx) => {
2+
const id = ctx.req.param('id');
3+
4+
const redirectTo = `/jiemian${id ? `/lists/${id}` : ''}`;
5+
ctx.redirect(redirectTo);
6+
};

lib/v2/jiemian/router.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
module.exports = function (router) {
2-
router.get('/list/:id', (ctx) => {
3-
const id = ctx.req.param('id');
4-
5-
const redirectTo = `/jiemian${id ? `/lists/${id}` : ''}`;
6-
ctx.redirect(redirectTo);
7-
});
2+
router.get('/list/:id', './list');
83
router.get('/:category*', './lists');
94
};

lib/v2/liulinblog/itnews.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = (ctx) => {
2+
const { channel } = ctx.req.param();
3+
const redirectTo = `/liulinblog/${channel}`;
4+
ctx.redirect(redirectTo);
5+
};

lib/v2/liulinblog/router.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
module.exports = (router) => {
2-
router.get('/itnews/:channel', (ctx) => {
3-
const { channel } = ctx.req.param();
4-
const redirectTo = `/liulinblog/${channel}`;
5-
ctx.redirect(redirectTo);
6-
});
2+
router.get('/itnews/:channel', './itnews');
73
router.get('/:params*', './');
84
};

lib/v2/nbd/daily.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = (ctx) => {
2+
ctx.redirect('/nbd/332');
3+
};

lib/v2/nbd/router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = (router) => {
2-
router.get('/daily', (c) => c.redirect('/nbd/332'));
2+
router.get('/daily', './daily');
33
router.get('/:id?', './index');
44
};

lib/v2/scmp/coronavirus.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = (ctx) => {
2+
ctx.redirect('/scmp/topics/coronavirus-pandemic-all-stories');
3+
};

lib/v2/scmp/router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = (router) => {
2-
router.get('/coronavirus', (c) => c.redirect('/scmp/topics/coronavirus-pandemic-all-stories'));
2+
router.get('/coronavirus', './coronavirus');
33
router.get('/:category_id', './index');
44
router.get('/topics/:topic', './topic');
55
};

lib/v2/telegram/channel.js

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ const mediaTagDict = {
5151
};
5252

5353
module.exports = async (ctx) => {
54+
const useWeb = ctx.req.param('routeParams') || !(config.telegram.session && config.feature.mediaProxyKey);
55+
if (!useWeb) {
56+
return require('./tglib/channel')(ctx);
57+
}
58+
5459
const username = ctx.req.param('username');
5560
let routeParams = ctx.req.param('routeParams');
5661
let showLinkPreview = true;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"build:all": "npm run build:radar && npm run build:maintainer",
2424
"build:maintainer": "node scripts/workflow/build-maintainer.js",
2525
"build:radar": "node scripts/workflow/build-radar.js",
26-
"dev": "cross-env NODE_ENV=dev tsx watch lib/index.ts",
26+
"dev": "cross-env NODE_ENV=dev tsx watch --no-cache lib/index.ts",
2727
"format": "eslint --cache --fix \"**/*.{ts,js,yml}\" && node website/docs/.format/format.mjs && prettier \"**/*.{ts,js,json}\" --write",
2828
"format:check": "eslint --cache \"**/*.{ts,js,yml}\" && prettier \"**/*.{ts,js,json}\" --check",
2929
"format:staged": "lint-staged",

0 commit comments

Comments
 (0)