Skip to content

Commit

Permalink
fix(route/bing): Replace got (#15237)
Browse files Browse the repository at this point in the history
* fix(route/bing): Replace `got`

* .

* Update daily-wallpaper.ts
  • Loading branch information
dzx-dzx authored Apr 16, 2024
1 parent f71451d commit 5a566e6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/routes/bing/daily-wallpaper.ts
Original file line number Diff line number Diff line change
@@ -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: '/',
Expand All @@ -9,32 +11,31 @@ 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/',
item: data.images.map((item) => ({
title: item.copyright,
description: `<img src="https://cn.bing.com${item.url}">`,
link: item.copyrightlink,
pubDate: timezone(parseDate(item.fullstartdate), 0),
})),
};
}

0 comments on commit 5a566e6

Please sign in to comment.