fix(route/bing): Replace `got` (#15237)

* fix(route/bing): Replace `got`

* .

* Update daily-wallpaper.ts
This commit is contained in:
Andvari 2024-04-17 02:39:50 +08:00 committed by GitHub
parent f71451dfc9
commit 5a566e6d72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 8 deletions

View File

@ -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),
})),
};
}