fix(route): Fix afdian (#14892)
* 迁移爱发电 * Update lib/routes/afdian/explore.ts ---------
This commit is contained in:
parent
2158895f01
commit
a9f06f453d
|
|
@ -756,8 +756,8 @@ router.get('/nosetime/home', lazyloadRouteHandler('./routes/nosetime/home'));
|
|||
router.get('/daxiaamu/home', lazyloadRouteHandler('./routes/daxiaamu/home'));
|
||||
|
||||
// 爱发电
|
||||
router.get('/afdian/explore/:type?/:category?', lazyloadRouteHandler('./routes/afdian/explore'));
|
||||
router.get('/afdian/dynamic/:uid', lazyloadRouteHandler('./routes/afdian/dynamic'));
|
||||
// router.get('/afdian/explore/:type?/:category?', lazyloadRouteHandler('./routes/afdian/explore'));
|
||||
// router.get('/afdian/dynamic/:uid', lazyloadRouteHandler('./routes/afdian/dynamic'));
|
||||
|
||||
// Simons Foundation
|
||||
router.get('/simonsfoundation/articles', lazyloadRouteHandler('./routes/simonsfoundation/articles'));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,17 @@
|
|||
const got = require('@/utils/got');
|
||||
import got from '@/utils/got';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url_slug = ctx.params.uid.replace('@', '');
|
||||
export const route: Route = {
|
||||
path: '/dynamic/:uid?',
|
||||
categories: ['other'],
|
||||
example: '/afdian/dynamic/@afdian',
|
||||
parameters: { uid: '用户id,用户动态页面url里可找到' },
|
||||
name: '用户动态',
|
||||
maintainers: ['sanmmm'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const url_slug = ctx.req.param('uid').replace('@', '');
|
||||
const baseUrl = 'https://afdian.net';
|
||||
const userInfoRes = await got(`${baseUrl}/api/user/get-profile-by-slug`, {
|
||||
searchParams: {
|
||||
|
|
@ -26,7 +36,7 @@ module.exports = async (ctx) => {
|
|||
pubDate: new Date(Number(publish_time) * 1000).toUTCString(),
|
||||
};
|
||||
});
|
||||
ctx.state.data = {
|
||||
return {
|
||||
title: `${name}的爱发电动态`,
|
||||
description: `${name}的爱发电动态`,
|
||||
image: avatar,
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
const got = require('@/utils/got');
|
||||
import got from '@/utils/got';
|
||||
|
||||
const categoryMap = {
|
||||
所有: '',
|
||||
|
|
@ -26,8 +26,29 @@ const typeToLabel = {
|
|||
hot: '人气',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type = 'rec', category = '所有' } = ctx.params;
|
||||
export const route: Route = {
|
||||
path: '/explore/:type/:category?',
|
||||
categories: ['other'],
|
||||
example: '/afdian/explore/hot/所有',
|
||||
parameters: { type: '分类', category: '目录类型,默认为 `所有`' },
|
||||
name: '发现用户',
|
||||
maintainers: ['sanmmm'],
|
||||
description: `分类
|
||||
|
||||
| 推荐 | 最热 |
|
||||
| ---- | ---- |
|
||||
| rec | hot |
|
||||
|
||||
目录类型
|
||||
|
||||
| 所有 | 绘画 | 视频 | 写作 | 游戏 | 音乐 | 播客 | 摄影 | 技术 | Vtuber | 舞蹈 | 体育 | 旅游 | 美食 | 时尚 | 数码 | 动画 | 其他 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ------ | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| 所有 | 绘画 | 视频 | 写作 | 游戏 | 音乐 | 播客 | 摄影 | 技术 | Vtuber | 舞蹈 | 体育 | 旅游 | 美食 | 时尚 | 数码 | 动画 | 其他 |`,
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { type = 'rec', category = '所有' } = ctx.req.param();
|
||||
const baseUrl = 'https://afdian.net';
|
||||
const link = `${baseUrl}/api/creator/list`;
|
||||
const res = await got(link, {
|
||||
|
|
@ -48,7 +69,7 @@ module.exports = async (ctx) => {
|
|||
link: `${baseUrl}/@${item.url_slug}`,
|
||||
};
|
||||
});
|
||||
ctx.state.data = {
|
||||
return {
|
||||
title: `爱发电-创作者 (按 ${category}/${typeToLabel[type]})`,
|
||||
description: `爱发电-发现创作者 (按 ${category}/${typeToLabel[type]})`,
|
||||
link: `${baseUrl}/explore`,
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: '爱发电',
|
||||
url: 'afdian.net',
|
||||
};
|
||||
Loading…
Reference in New Issue