diff --git a/docs/game.md b/docs/game.md
index f2b2fd158..15b751d8d 100644
--- a/docs/game.md
+++ b/docs/game.md
@@ -106,12 +106,16 @@ pageClass: routes
### eShop 新发售游戏
-
+
### 首页资讯(香港)
+### 首页资讯(中国)
+
+
+
### 直面会
diff --git a/lib/router.js b/lib/router.js
index fe126902f..b3589994b 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -1431,7 +1431,9 @@ router.get('/quantamagazine/archive', require('./routes/quantamagazine/archive')
router.get('/nintendo/eshop/jp', require('./routes/nintendo/eshop_jp'));
router.get('/nintendo/eshop/hk', require('./routes/nintendo/eshop_hk'));
router.get('/nintendo/eshop/us', require('./routes/nintendo/eshop_us'));
+router.get('/nintendo/eshop/cn', require('./routes/nintendo/eshop_cn'));
router.get('/nintendo/news', require('./routes/nintendo/news'));
+router.get('/nintendo/news/china', require('./routes/nintendo/news_china'));
router.get('/nintendo/direct', require('./routes/nintendo/direct'));
router.get('/nintendo/system-update', require('./routes/nintendo/system-update'));
diff --git a/lib/routes/nintendo/eshop_cn.js b/lib/routes/nintendo/eshop_cn.js
new file mode 100644
index 000000000..a3779dd4c
--- /dev/null
+++ b/lib/routes/nintendo/eshop_cn.js
@@ -0,0 +1,51 @@
+const got = require('@/utils/got');
+const util = require('./utils');
+const software_url = 'https://www.nintendoswitch.com.cn/software/';
+
+module.exports = async (ctx) => {
+ const response = await got({
+ method: 'get',
+ url: software_url,
+ });
+
+ // 获取Nuxt对象
+ const result = await util.nuxtReader(response.data);
+
+ /* expectedReleaseNS[]
+ coverImageUrl: "//switch-cn.gtgres.com/global-images/c50e3390-14e5-11ea-9b40-236e671bca9e.png"
+ expectedReleaseDate: 0
+ expectedReleaseDateFuzzy: ""
+ gameName: "Mario Tennis Aces"
+ id: 1852
+ newsPageUrl: ""
+ softwareData[]
+ gameProductCode: "HAC-P-ADALB"
+ image: "//switch-cn.gtgres.com/global-images/c247f0e0-1654-11ea-9b40-236e671bca9e.png"
+ name: "新 超级马力欧兄弟U 豪华版"
+ nsUid: "70010000027088"
+ publisher: "任天堂"
+ releaseDatetime: 1575907200000
+ softcardType: (2)[]
+ */
+ if (!result.softwareData) {
+ throw new Error('软件信息不存在,请报告这个问题');
+ }
+
+ let data = result.softwareData.map((item) => ({
+ title: item.name,
+ author: item.publisher,
+ description: util.generateImageLink(`https${item.image}`),
+ category: item.softcardType,
+ link: `${software_url}${item.nsUid}`,
+ pubDate: new Date(parseInt(item.releaseTime)).toUTCString(),
+ }));
+
+ data = await util.ProcessItemChina(data, ctx.cache);
+
+ ctx.state.data = {
+ title: `Nintendo eShop (国服) 新游戏`,
+ link: `https://www.nintendo.com.hk/topics`,
+ description: `Nintendo (国服) 新上架的游戏`,
+ item: data,
+ };
+};
diff --git a/lib/routes/nintendo/news_china.js b/lib/routes/nintendo/news_china.js
new file mode 100644
index 000000000..65089f989
--- /dev/null
+++ b/lib/routes/nintendo/news_china.js
@@ -0,0 +1,41 @@
+const got = require('@/utils/got');
+const util = require('./utils');
+const news_url = 'https://www.nintendoswitch.com.cn/topics/';
+
+module.exports = async (ctx) => {
+ const response = await got({
+ method: 'get',
+ url: news_url,
+ });
+
+ // 获取Nuxt对象
+ const result = await util.nuxtReader(response.data);
+
+ /* newsData[]
+ category: "Nintendo Switch"
+ id: "7341a73c-b4f8-4fa2-ae26-33c670743293"
+ imgUrl: "//switch-cn.gtgres.com/global-images/05b83870-31cc-11ea-8066-7beee849b0db.png"
+ releaseTime: 1578456319000
+ title: "《新 超级马力欧兄弟U 豪华版》1月15日实体游戏卡带发售"
+ */
+ if (!result.newsData) {
+ throw new Error('新闻信息不存在,请报告这个问题');
+ }
+
+ let data = result.newsData.map((item) => ({
+ title: item.title,
+ description: util.generateImageLink(`https${item.imgUrl}`),
+ category: item.category,
+ link: `${news_url}${item.id}`,
+ pubDate: new Date(parseInt(item.releaseTime)).toUTCString(),
+ }));
+
+ data = await util.ProcessNewsChina(data, ctx.cache);
+
+ ctx.state.data = {
+ title: `Nintendo (中国大陆) 主页资讯`,
+ link: `https://www.nintendo.com.hk/topics`,
+ description: `Nintendo 中国大陆官网刊登的资讯`,
+ item: data,
+ };
+};
diff --git a/lib/routes/nintendo/utils.js b/lib/routes/nintendo/utils.js
index 7c4552eb0..4b5fc355e 100644
--- a/lib/routes/nintendo/utils.js
+++ b/lib/routes/nintendo/utils.js
@@ -1,5 +1,25 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
+const jsdom = require('jsdom');
+const { JSDOM } = jsdom;
+
+async function nuxtReader(data) {
+ let nuxt = {};
+ try {
+ const dom = new JSDOM(data, {
+ runScripts: 'dangerously',
+ });
+ nuxt = dom.window.__NUXT__.data[0];
+ } catch (e) {
+ throw new Error('Nuxt 框架信息提取失败,请报告这个问题');
+ }
+
+ return nuxt;
+}
+
+function generateImageLink(link) {
+ return `
`;
+}
async function load(link) {
const response = await got({
@@ -12,7 +32,9 @@ async function load(link) {
const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML
const description = $('.description').html();
- return { content: description };
+ return {
+ content: description,
+ };
}
async function loadNews(link) {
@@ -49,7 +71,121 @@ const ProcessNews = async (list, caches) =>
})
);
+/*
+ Software Item Example
+{
+ "nsUid": "70010000027088",
+ "gameProductCode": "HAC-P-ADALB",
+ "name": "新 超级马力欧兄弟U 豪华版",
+ "price": "299",
+ "currency": "CNY",
+ "images": ["//switch-cn.gtgres.com/global-images/c247f0e0-1654-11ea-9b40-236e671bca9e.png", "//switch-cn.gtgres.com/global-images/c62e52d0-1654-11ea-9b40-236e671bca9e.jpg", "//switch-cn.gtgres.com/global-images/c8ec6160-1654-11ea-9b40-236e671bca9e.jpg", "//switch-cn.gtgres.com/global-images/cb84e690-1654-11ea-9b40-236e671bca9e.jpg", "//switch-cn.gtgres.com/global-images/cdc1b730-1654-11ea-9b40-236e671bca9e.jpg", "//switch-cn.gtgres.com/global-images/cfd57c00-1654-11ea-9b40-236e671bca9e.jpg", "//switch-cn.gtgres.com/global-images/d1fe4f70-1654-11ea-9b40-236e671bca9e.jpg"],
+ "movies": [],
+ "purchaseUrls": [{
+ "key": "JD",
+ "url": "https://item.jd.com/100010400326.html"
+ }, {
+ "key": "TM",
+ "url": "https://detail.tmall.com/item.htm?id=608916438547"
+ }],
+ "descriptionTitle": "2D超级马力欧全新体验,同享欢乐时光",
+ "descriptionContent": "《新 超级马力欧兄弟U 豪华版》是2D超级马力欧横版卷轴动作游戏。\\n\\n游戏包括《新 超级路易吉U》和《新 超级马力欧兄弟U》共164个关卡,马力欧一行需要前往被酷霸王占领的桃花公主城堡,利用多种新奇的能力强化,与可靠有趣的伙伴,在丰富多彩的世界中展开冒险。在《新 超级路易吉U》中,关卡难度更高,限时更短,角色跳跃能力更强但也更易打滑,非常适合喜欢挑战的玩家。\\n\\n游戏中有“马力欧”、“路易吉”、“奇诺比奥”、“偷天兔”和“奇诺比珂”5个角色供你选择,其中“奇诺比珂”与“偷天兔”拥有非常适合新手的特殊能力,即使不擅长动作游戏,也可以轻松游玩。\\n\\n除了故事模式外,游戏还提供课题模式、加倍模式和金币对战多种丰富的玩法。游戏支持最多4人一起游玩,快与伙伴分享Joy-Con™,一起趣玩吧!",
+ "sizeNum": "2.1",
+ "sizeUnit": "GB",
+ "playMode": ["tv", "tabletop", "handheld"],
+ "normalPlayersNum": {
+ "min": 1,
+ "max": 4
+ },
+ "localPlayersNum": {
+ "min": 0,
+ "max": 0
+ },
+ "internatPlayersNum": {
+ "min": 0,
+ "max": 0
+ },
+ "handleSupport": "Nintendo Switch专业手柄",
+ "platform": "Nintendo Switch",
+ "developer": "Nintendo",
+ "publisher": "任天堂",
+ "genre": ["动作", "冒险", "家庭", "多人"],
+ "releaseDatetime": 1575907200000,
+ "supportLanguages": ["简体中文"],
+ "colors": {
+ "words": "3c3c3c",
+ "entrance": "e60012",
+ "background": "e8ebef"
+ },
+ "copyright": {
+ "publishCompany": "上海电子出版有限公司",
+ "operateCompany": "深圳市腾讯计算机系统有限公司",
+ "copyrightNotice": "© 2012-2019 Nintendo",
+ "isbn": "978-7-498-06914-6",
+ "gapp": "国新出审[2019]2990号",
+ "copyrightNumber": "电出字09-2019-031"
+ }
+}
+*/
+const ProcessItemChina = async (list, cache) =>
+ await Promise.all(
+ list.map(async (item) => {
+ const n = await cache.tryGet(
+ item.link,
+ async () =>
+ await nuxtReader(
+ (
+ await got({
+ url: item.link,
+ method: 'get',
+ })
+ ).data
+ )
+ );
+ const software = n.data;
+ return Promise.resolve(
+ Object.assign({}, item, {
+ category: [...item.category, ...software.supportLanguages, ...software.genre, ...software.playMode],
+ description: `
+ ${item.description}
+ 价格: ${software.price} ${software.currency}
+ 大小:${software.sizeNum} ${software.sizeUnit}
+
+ ${software.descriptionContent}
+ `,
+ })
+ );
+ })
+ );
+
+const ProcessNewsChina = async (list, cache) =>
+ await Promise.all(
+ list.map(async (item) => {
+ const n = await cache.tryGet(
+ item.link,
+ async () =>
+ await nuxtReader(
+ (
+ await got({
+ url: item.link,
+ method: 'get',
+ })
+ ).data
+ )
+ );
+ return Promise.resolve(
+ Object.assign({}, item, {
+ description: item.description + n.newsData.content,
+ })
+ );
+ })
+ );
+
module.exports = {
ProcessItem,
ProcessNews,
+ ProcessNewsChina,
+ ProcessItemChina,
+ nuxtReader,
+ generateImageLink,
};