From 5a566e6d727754dd2e2321e64d73fca04581edd3 Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Wed, 17 Apr 2024 02:39:50 +0800 Subject: [PATCH] fix(route/bing): Replace `got` (#15237) * fix(route/bing): Replace `got` * . * Update daily-wallpaper.ts --- lib/routes/bing/daily-wallpaper.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/routes/bing/daily-wallpaper.ts b/lib/routes/bing/daily-wallpaper.ts index a949e2ee165c9e..10b1460ac643f8 100644 --- a/lib/routes/bing/daily-wallpaper.ts +++ b/lib/routes/bing/daily-wallpaper.ts @@ -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: ``, link: item.copyrightlink, + pubDate: timezone(parseDate(item.fullstartdate), 0), })), }; }