fix(route/bing): Replace `got` (#15237)
* fix(route/bing): Replace `got` * . * Update daily-wallpaper.ts
This commit is contained in:
parent
f71451dfc9
commit
5a566e6d72
|
|
@ -1,5 +1,7 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/',
|
||||
|
|
@ -9,25 +11,23 @@ export const route: Route = {
|
|||
target: '',
|
||||
},
|
||||
],
|
||||
name: 'Unknown',
|
||||
name: '每日壁纸',
|
||||
maintainers: ['FHYunCai'],
|
||||
handler,
|
||||
url: 'cn.bing.com/',
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
prefixUrl: 'https://cn.bing.com',
|
||||
url: 'HPImageArchive.aspx',
|
||||
searchParams: {
|
||||
const response = await ofetch('HPImageArchive.aspx', {
|
||||
baseURL: 'https://cn.bing.com',
|
||||
query: {
|
||||
format: 'js',
|
||||
idx: 0,
|
||||
n: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 7,
|
||||
mkt: 'zh-CN',
|
||||
},
|
||||
});
|
||||
const data = response.data;
|
||||
const data = response;
|
||||
return {
|
||||
title: 'Bing每日壁纸',
|
||||
link: 'https://cn.bing.com/',
|
||||
|
|
@ -35,6 +35,7 @@ async function handler(ctx) {
|
|||
title: item.copyright,
|
||||
description: `<img src="https://cn.bing.com${item.url}">`,
|
||||
link: item.copyrightlink,
|
||||
pubDate: timezone(parseDate(item.fullstartdate), 0),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue