forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add 少女前线新闻 & 公告 (DIYgod#6953)
Co-authored-by: NeverBehave <[email protected]>
- Loading branch information
1 parent
7320072
commit 11f7179
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const got = require('@/utils/got'); | ||
|
||
module.exports = async (ctx) => { | ||
const category = ctx.params.category || '1'; | ||
|
||
const rootUrl = 'https://gfcn-webserver.sunborngame.com'; | ||
const currentUrl = `${rootUrl}/website/news_list/${category}?page=0&limit=11`; | ||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const list = response.data.data.list.map((item) => ({ | ||
title: item.Title, | ||
link: `${rootUrl}/website/news/${item.Id}`, | ||
pubDate: new Date(item.Date).toUTCString(), | ||
})); | ||
|
||
const items = await Promise.all( | ||
list.map( | ||
async (item) => | ||
await ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
item.description = detailResponse.data.data.Content; | ||
item.link = item.link.replace(`${rootUrl}/website/news/`, `${rootUrl}/NewsInfo?id=`); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `少女前线 - ${category === '1' ? '新闻' : '公告'}`, | ||
link: currentUrl, | ||
item: items, | ||
}; | ||
}; |