fix(route): gameapps (#17207)

This commit is contained in:
Tony
2024-10-21 05:52:41 +08:00
committed by GitHub
parent f7347d9f02
commit 1a6986f2db
2 changed files with 8 additions and 8 deletions
+8 -7
View File
@@ -3,7 +3,7 @@ import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
import cache from '@/utils/cache';
import got from '@/utils/got';
import ofetch from '@/utils/ofetch';
import parser from '@/utils/rss-parser';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -12,13 +12,13 @@ import path from 'node:path';
export const route: Route = {
path: '/',
example: '/gameapps',
radar: [
{
source: ['gameapps.hk/'],
target: '',
},
],
name: 'Unknown',
name: '最新消息',
maintainers: ['TonyRL'],
handler,
url: 'gameapps.hk/',
@@ -31,7 +31,7 @@ async function handler() {
const items = await Promise.all(
feed.items.map((item) =>
cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
const response = await ofetch(item.link, {
headers: {
Referer: baseUrl,
},
@@ -71,12 +71,13 @@ async function handler() {
}
item.description = art(path.join(__dirname, 'templates/description.art'), {
src: $('div.introduction.media.news-intro div.media-left').find('img').attr('src'),
intro: $('div.introduction.media.news-intro div.media-body').html().trim(),
desc: content.html().trim(),
intro: $('div.introduction.media.news-intro div.media-body').html()?.trim(),
desc: content.html()?.trim(),
});
item.guid = item.guid.substring(0, item.link.lastIndexOf('/'));
item.pubDate = parseDate(item.pubDate);
item.enclosure_url = $('div.introduction.media.news-intro div.media-left').find('img').attr('src');
item.enclosure_type = 'image/jpeg';
return item;
})
@@ -1,3 +1,2 @@
<img src="{{ src }}"><br>
{{@ intro }}
{{@ desc }}