feat(route/thepaper): update sidebar sections (#21664)
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import type { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
|
||||
import utils from './utils';
|
||||
|
||||
const sections = {
|
||||
hotNews: '澎湃热榜',
|
||||
financialInformationNews: '澎湃财讯',
|
||||
financialInformationNews: '澎湃快讯',
|
||||
morningEveningNews: '早晚报',
|
||||
editorHandpicked: '要闻精选',
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
@@ -20,7 +21,12 @@ export const route: Route = {
|
||||
name: '侧边栏',
|
||||
categories: ['new-media'],
|
||||
example: '/thepaper/sidebar',
|
||||
parameters: { sec: '侧边栏 id,可选 `hotNews` 即 澎湃热榜、`financialInformationNews` 即 澎湃财讯、`morningEveningNews` 即 早晚报,默认为 `hotNews`' },
|
||||
parameters: {
|
||||
sec: {
|
||||
description: '侧边栏 id',
|
||||
options: Object.entries(sections).map(([key, value]) => ({ label: value, value: key })),
|
||||
},
|
||||
},
|
||||
maintainers: ['bigfei'],
|
||||
handler,
|
||||
url: 'thepaper.cn/',
|
||||
@@ -29,14 +35,13 @@ export const route: Route = {
|
||||
async function handler(ctx) {
|
||||
const { sec = 'hotNews' } = ctx.req.param();
|
||||
|
||||
const sidebar_url = `https://cache.thepaper.cn/contentapi/wwwIndex/rightSidebar`;
|
||||
const sidebar_url_resp = await got(sidebar_url);
|
||||
const sidebar_url_data = sidebar_url_resp.data;
|
||||
const list = sidebar_url_data.data[sec];
|
||||
const sidebarUrl = 'https://cache.thepaper.cn/contentapi/wwwIndex/rightSidebar';
|
||||
const sidebarUrlData = await ofetch(sidebarUrl);
|
||||
const list = sidebarUrlData.data[sec];
|
||||
|
||||
const items = await Promise.all(list.filter((item) => item.contId).map((item) => utils.ProcessItem(item, ctx)));
|
||||
return {
|
||||
title: `澎湃新闻 - ${sections[sec]}`,
|
||||
title: `澎湃新闻 - ${sections[sec] ?? sec}`,
|
||||
item: items,
|
||||
link: 'https://www.thepaper.cn',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user