feat(route): add qoo-app (#11624)
* feat(route): qoo-add * docs: add docs * refactor: combine extractNotes
This commit is contained in:
@@ -436,6 +436,56 @@ Sources
|
||||
|
||||
</Route>
|
||||
|
||||
## QooApp
|
||||
|
||||
### 遊戲庫 - 評論
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/apps/comment/7675" path="/qoo-app/apps/:lang?/comment/:id" :paramsDesc="['語言,見下表,留空為中文', '遊戲 ID,可在 URL 找到']" radar="1">
|
||||
|
||||
| 中文 | English | 한국어 | Español | 日本語 | ไทย | Tiếng Việt |
|
||||
| -- | ------- | --- | ------- | --- | --- | ---------- |
|
||||
| | en | ko | es | ja | th | vi |
|
||||
|
||||
</Route>
|
||||
|
||||
### 遊戲庫 - 情報
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/apps/post/7675" path="/qoo-app/apps/:lang?/post/:id" :paramsDesc="['語言,見上表,留空為中文', '遊戲 ID,可在 URL 找到']" radar="1"/>
|
||||
|
||||
### 遊戲庫 - 筆記
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/apps/note/7675" path="/qoo-app/apps/:lang?/note/:id" :paramsDesc="['語言,見上表,留空為中文', '遊戲 ID,可在 URL 找到']" radar="1"/>
|
||||
|
||||
### 遊戲庫 - 曬卡
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/apps/card/7675" path="/qoo-app/apps/:lang?/card/:id" :paramsDesc="['語言,見上表,留空為中文', '遊戲 ID,可在 URL 找到']" radar="1"/>
|
||||
|
||||
### 資訊
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/news" path="/qoo-app/news/:lang?" :paramsDesc="['語言,見下表,留空為中文']" radar="1">
|
||||
|
||||
| 中文 | English |
|
||||
| -- | ------- |
|
||||
| | en |
|
||||
|
||||
</Route>
|
||||
|
||||
### 筆記留言
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/notes/note/2320205" path="/qoo-app/notes/:lang?/note/:id" :paramsDesc="['語言,見上表,留空為中文', '遊戲 ID,可在 URL 找到']" radar="1"/>
|
||||
|
||||
### 熱門話題
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/notes/topic/QooApp轉蛋" path="/qoo-app/notes/:lang?/topic/:id" :paramsDesc="['語言,見上表,留空為中文', '話題名,不需要 `#`']" radar="1"/>
|
||||
|
||||
### 用户遊戲評論
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/user/appComment/23266114" path="/qoo-app/user/:lang?/appComment/:uid" :paramsDesc="['語言,見上表,留空為中文', '用户 ID,可在 URL 找到']" radar="1"/>
|
||||
|
||||
### 用户筆記
|
||||
|
||||
<Route author="TonyRL" example="/qoo-app/notes/user/23266114" path="/qoo-app/notes/:lang?/user/:uid" :paramsDesc="['語言,見上表,留空為中文', '用户 ID,可在 URL 找到']" radar="1"/>
|
||||
|
||||
## say 花火
|
||||
|
||||
### 文章
|
||||
|
||||
@@ -120,6 +120,56 @@ The RSS routing has not been rigorously tested and the information provided cann
|
||||
|
||||
<RouteEn author="vzz64" example="/mangadex/58be6aa6-06cb-4ca5-bd20-f1392ce451fb/en" path="/:id/:lang?" :paramsDesc="['manga ID', 'language code']" radar="1" />
|
||||
|
||||
## QooApp
|
||||
|
||||
### Game Store - Review
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/apps/en/comment/7675" path="/qoo-app/apps/:lang?/comment/:id" :paramsDesc="['Language, see the table below, empty means `中文`', 'Game ID, can be found in URL']" radar="1">
|
||||
|
||||
| 中文 | English | 한국어 | Español | 日本語 | ไทย | Tiếng Việt |
|
||||
| -- | ------- | --- | ------- | --- | --- | ---------- |
|
||||
| | en | ko | es | ja | th | vi |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
### Game Store - Article
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/apps/en/post/7675" path="/qoo-app/apps/:lang?/post/:id" :paramsDesc="['Language, see the table above, empty means `中文`', 'Game ID, can be found in URL']" radar="1"/>
|
||||
|
||||
### Game Store - Notes
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/apps/en/note/7675" path="/qoo-app/apps/:lang?/note/:id" :paramsDesc="['Language, see the table above, empty means `中文`', 'Game ID, can be found in URL']" radar="1"/>
|
||||
|
||||
### Game Store - Cards
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/apps/en/card/7675" path="/qoo-app/apps/:lang?/card/:id" :paramsDesc="['Language, see the table above, empty means `中文`', 'Game ID, can be found in URL']" radar="1"/>
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/news/en" path="/qoo-app/news/:lang?" :paramsDesc="['Language, see the table below, empty means `中文`']" radar="1">
|
||||
|
||||
| 中文 | English |
|
||||
| -- | ------- |
|
||||
| | en |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
### Note Comments
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/notes/en/note/2329113" path="/qoo-app/notes/:lang?/note/:id" :paramsDesc="['Language, see the table above, empty means `中文`', 'Note ID, can be found in URL']" radar="1"/>
|
||||
|
||||
### Hot Hashtags
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/notes/en/topic/QooAppGacha" path="/qoo-app/notes/:lang?/topic/:id" :paramsDesc="['Language, see the table above, empty means `中文`', 'Hashtag name without `#`']" radar="1"/>
|
||||
|
||||
### User Game Comments
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/user/en/appComment/35399143" path="/qoo-app/user/:lang?/appComment/:uid" :paramsDesc="['Language, see the table above, empty means `中文`', 'User ID, can be found in URL']" radar="1"/>
|
||||
|
||||
### User Notes
|
||||
|
||||
<RouteEn author="TonyRL" example="/qoo-app/notes/en/user/35399143" path="/qoo-app/notes/:lang?/user/:uid" :paramsDesc="['Language, see the table above, empty means `中文`', 'User ID, can be found in URL']" radar="1"/>
|
||||
|
||||
## THBWiki
|
||||
|
||||
### Calendar
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { appsUrl } = require('../utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id, lang = '' } = ctx.params;
|
||||
const link = `${appsUrl}${lang ? `/${lang}` : ''}/app-card/${id}`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const items = $('.qoo-post-item')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const name = item.find('.qoo-clearfix .name a');
|
||||
const author = name.eq(0).text();
|
||||
const pubDate = timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm:ss'), 8);
|
||||
item.find('a.icon, .qoo-clearfix, footer, article.qoo-comment-panel, div.slot').remove();
|
||||
item.find('.img-list').attr('data-target', '');
|
||||
return {
|
||||
title: `${author} ▶ ${name.eq(1).text()}`,
|
||||
description: item.html(),
|
||||
pubDate,
|
||||
author,
|
||||
guid: `qoo-app:apps:card:7675:${item.attr('data-id')}`,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
language: $('html').attr('lang'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { appsUrl } = require('../utils');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id, lang = '' } = ctx.params;
|
||||
const link = `${appsUrl}${lang ? `/${lang}` : ''}/app-comment/${id}`;
|
||||
|
||||
const { data: response } = await got(link, {
|
||||
searchParams: {
|
||||
sort: 'create',
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const items = $('.qoo-post-item')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const author = item.find('.qoo-clearfix .name a').eq(0).text();
|
||||
return {
|
||||
title: `${author} ▶ ${item.find('.qoo-clearfix .name a').eq(1).text()}`,
|
||||
link: item.find('a.bg-click-wrap').attr('href'),
|
||||
description: art(path.join(__dirname, '../templates/comment.art'), {
|
||||
rating: item.find('.qoo-rating-bar').text().trim(),
|
||||
text: item.find('.text-view').html(),
|
||||
}),
|
||||
pubDate: timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm:ss'), 8),
|
||||
author,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
language: $('html').attr('lang'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { appsUrl } = require('../utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id, lang = '' } = ctx.params;
|
||||
const link = `${appsUrl}${lang ? `/${lang}` : ''}/app-note/${id}`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = $('.qoo-note-wrap')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('.content-title').text() || item.find('.description').text(),
|
||||
link: item.find('a.link-wrap').attr('href'),
|
||||
description: item.find('.description').text(),
|
||||
pubDate: timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm'), 8),
|
||||
author: item.find('cite.name').text(),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
$('footer').remove();
|
||||
item.description = $('article .content').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
language: $('html').attr('lang'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { appsUrl, newsUrl, fixImg } = require('../utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id, lang = '' } = ctx.params;
|
||||
const link = `${appsUrl}${lang ? `/${lang}` : ''}/app-post/${id}`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = $('.qoo-post-item')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
return {
|
||||
title: a.attr('title'),
|
||||
link: a.attr('href'),
|
||||
// description: item.find('.img-list').html() + item.find('.text-view').html(),
|
||||
pubDate: timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm'), 8),
|
||||
author: item.find('cite.name').text(),
|
||||
postId: a.attr('href').split('/').pop(),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data } = await got(`${newsUrl}${lang ? `/${lang}` : ''}/wp-json/wp/v2/posts/${item.postId}`);
|
||||
const $ = cheerio.load(data.content.rendered, null, false);
|
||||
|
||||
fixImg($);
|
||||
|
||||
item.description = $.html();
|
||||
item.pubDate = parseDate(data.date_gmt);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
language: $('html').attr('lang'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
'/apps/:lang?/card/:id': ['TonyRL'],
|
||||
'/apps/:lang?/comment/:id': ['TonyRL'],
|
||||
'/apps/:lang?/note/:id': ['TonyRL'],
|
||||
'/apps/:lang?/post/:id': ['TonyRL'],
|
||||
'/notes/:lang?/note/:id': ['TonyRL'],
|
||||
'/notes/:lang?/topic/:topic': ['TonyRL'],
|
||||
'/notes/:lang?/user/:uid': ['TonyRL'],
|
||||
'/news/:lang?': ['TonyRL'],
|
||||
'/user/:lang?/appComment/:uid': ['TonyRL'],
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const { newsUrl, siteIcon, fixImg } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { lang = '' } = ctx.params;
|
||||
const apiUrl = `${newsUrl}${lang ? `/${lang}` : ''}/wp-json/wp/v2/posts`;
|
||||
|
||||
const { data } = await got(apiUrl, {
|
||||
searchParams: {
|
||||
per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 100,
|
||||
},
|
||||
});
|
||||
|
||||
const items = data.map((item) => {
|
||||
const $ = cheerio.load(item.content.rendered, null, false);
|
||||
|
||||
fixImg($);
|
||||
|
||||
return {
|
||||
title: item.title.rendered,
|
||||
link: item.link.substring(0, item.link.lastIndexOf('/')),
|
||||
description: $.html(),
|
||||
pubDate: parseDate(item.date_gmt),
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'QooApp : Anime Game Platform',
|
||||
description:
|
||||
lang !== 'en'
|
||||
? 'QooApp 是專注二次元的專業平台,旨在聚集世界各地熱愛ACG的用戶,為他們創造有價值的服務和產品。從遊戲商店、新聞資訊、玩家社群,到線下聚會、漫畫閱讀、遊戲發行——QooApp不斷進化中,拓展突破次元的遊玩體驗。'
|
||||
: 'QooApp is a professional platform specialising in Anime, Comics and Games (ACG) culture. We aim to unite ACG fans around the globe and help them as thoroughly as we can.',
|
||||
image: siteIcon,
|
||||
link: `${newsUrl}${lang ? `/${lang}` : ''}`,
|
||||
language: lang !== 'en' ? 'zh' : 'en',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { ssoUrl, notesUrl } = require('../utils');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const api = `${ssoUrl}/api/v1/comments`;
|
||||
const link = `${notesUrl}/note/${id}`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const { data } = await got(api, {
|
||||
searchParams: {
|
||||
sort: 'newest',
|
||||
for: 'web',
|
||||
limit: ctx.query.limit ? parseInt(ctx.query.limit) : 100,
|
||||
type: 'note',
|
||||
object_id: id,
|
||||
},
|
||||
});
|
||||
|
||||
const items = data.data.map((item) => ({
|
||||
title: item.content,
|
||||
description: art(path.join(__dirname, '../templates/note.art'), {
|
||||
content: item.content,
|
||||
picture: item.picture,
|
||||
}),
|
||||
pubDate: parseDate(item.created_timestamp),
|
||||
author: item.user.name,
|
||||
guid: `qoo-app:notes:note:${id}:${item.id}`,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
language: $('html').attr('lang'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { notesUrl, extractNotes } = require('../utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { topic, lang } = ctx.params;
|
||||
const link = `${notesUrl}${lang ? `/${lang}` : ''}/topic/${topic}`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const items = extractNotes($);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
language: $('html').attr('lang'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { notesUrl, extractNotes } = require('../utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { uid, lang } = ctx.params;
|
||||
const link = `${notesUrl}${lang ? `/${lang}` : ''}/user/${uid}`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const items = extractNotes($);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
language: $('html').attr('lang'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
module.exports = {
|
||||
'qoo-app.com': {
|
||||
_name: 'QooApp',
|
||||
apps: [
|
||||
{
|
||||
title: '遊戲庫 - 評論',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/app-comment/:id', '/app-comment/:id', '/app/:id'],
|
||||
target: (params) => `/qoo-app/apps${params.lang ? `/${params.lang}` : ''}/comment/:id`,
|
||||
},
|
||||
{
|
||||
title: '遊戲庫 - 情報',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/app-post/:id', '/app-post/:id', '/app/:id'],
|
||||
target: (params) => `/qoo-app/apps${params.lang ? `/${params.lang}` : ''}/post/:id`,
|
||||
},
|
||||
{
|
||||
title: '遊戲庫 - 筆記',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/app-note/:id', '/app-note/:id', '/app/:id'],
|
||||
target: (params) => `/qoo-app/apps${params.lang ? `/${params.lang}` : ''}/note/:id`,
|
||||
},
|
||||
{
|
||||
title: '遊戲庫 - 曬卡',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/app-card/:id', '/app-card/:id', '/app/:id'],
|
||||
target: (params) => `/qoo-app/apps${params.lang ? `/${params.lang}` : ''}/card/:id`,
|
||||
},
|
||||
],
|
||||
news: [
|
||||
{
|
||||
title: '資訊',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang', '/'],
|
||||
target: (params) => `/qoo-app/news${params.lang ? `/${params.lang}` : ''}`,
|
||||
},
|
||||
],
|
||||
notes: [
|
||||
{
|
||||
title: '筆記留言',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/note/:id', '/note/:id'],
|
||||
target: (params) => `/qoo-app/notes${params.lang ? `/${params.lang}` : ''}/note/:id`,
|
||||
},
|
||||
{
|
||||
title: '熱門話題',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/topic/:topic', '/topic/:topic'],
|
||||
target: (params) => `/qoo-app/notes${params.lang ? `/${params.lang}` : ''}/topic/:topic`,
|
||||
},
|
||||
{
|
||||
title: '用户筆記',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/user/:uid', '/user/:uid'],
|
||||
target: (params) => `/qoo-app/notes${params.lang ? `/${params.lang}` : ''}/user/:uid`,
|
||||
},
|
||||
],
|
||||
user: [
|
||||
{
|
||||
title: '遊戲評論',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/:uid', '/:uid'],
|
||||
target: (params) => `/qoo-app/user${params.lang ? `/${params.lang}` : ''}/appComment/:uid`,
|
||||
},
|
||||
{
|
||||
title: '用户筆記',
|
||||
docs: 'https://docs.rsshub.app/anime.html#qooapp',
|
||||
source: ['/:lang/:uid', '/:uid'],
|
||||
target: (params) => `/qoo-app/notes${params.lang ? `/${params.lang}` : ''}/user/:uid`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/apps/:lang?/card/:id', require('./apps/card'));
|
||||
router.get('/apps/:lang?/comment/:id', require('./apps/comment'));
|
||||
router.get('/apps/:lang?/note/:id', require('./apps/note'));
|
||||
router.get('/apps/:lang?/post/:id', require('./apps/post'));
|
||||
router.get('/news/:lang?', require('./news'));
|
||||
router.get('/notes/:lang?/note/:id', require('./notes/note'));
|
||||
router.get('/notes/:lang?/topic/:topic', require('./notes/topic'));
|
||||
router.get('/notes/:lang?/user/:uid', require('./notes/user'));
|
||||
router.get('/user/:lang?/appComment/:uid', require('./user/appComment'));
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
{{ rating }}/5.0
|
||||
<br>
|
||||
{{@ text }}
|
||||
@@ -0,0 +1,5 @@
|
||||
{{ content }}
|
||||
{{ if picture }}
|
||||
<br>
|
||||
<img src="{{ picture }}">
|
||||
{{ /if }}
|
||||
@@ -0,0 +1,41 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { userUrl, appsUrl } = require('../utils');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { uid, lang = '' } = ctx.params;
|
||||
const link = `${userUrl}${lang ? `/${lang}` : ''}/${uid}`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const { data } = await got(`${userUrl}/getUserAppCommentList`, {
|
||||
searchParams: {
|
||||
fid: uid,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
const username = $('.person .name').text();
|
||||
|
||||
const items = data.list.map((item) => ({
|
||||
title: `${username} ▶ ${item.app.name}`,
|
||||
link: `${appsUrl}/comment-detail/${item.comment.id}`,
|
||||
description: art(path.join(__dirname, '../templates/comment.art'), {
|
||||
rating: item.score,
|
||||
text: item.comment.content,
|
||||
}),
|
||||
pubDate: timezone(parseDate(item.comment.created_at, 'YYYY-MM-DD'), 8),
|
||||
author: username,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
image: decodeURIComponent($('.person div.slot').attr('data-args')).replace('avatar=', '').split('?')[0],
|
||||
language: $('html').attr('lang'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const appsUrl = 'https://apps.qoo-app.com';
|
||||
const newsUrl = 'https://news.qoo-app.com';
|
||||
const notesUrl = 'https://notes.qoo-app.com';
|
||||
const ssoUrl = 'https://sso.qoo-app.com';
|
||||
const userUrl = 'https://user.qoo-app.com';
|
||||
|
||||
const siteIcon = 'https://o.qoo-img.com/statics.qoo-app.com/cdn/img/QooApp_512.v-0d0fd2.png';
|
||||
|
||||
const fixImg = ($) => {
|
||||
$('img').each((_, img) => {
|
||||
if (img.attribs['data-orig-file']) {
|
||||
img.attribs.src = img.attribs['data-orig-file'].replace('i0.wp.com/', '').split('?')[0];
|
||||
delete img.attribs['data-orig-file'];
|
||||
delete img.attribs['data-orig-size'];
|
||||
delete img.attribs['data-image-meta'];
|
||||
delete img.attribs['data-comments-opened'];
|
||||
delete img.attribs['data-full-url'];
|
||||
delete img.attribs['data-medium-file'];
|
||||
delete img.attribs['data-large-file'];
|
||||
}
|
||||
img.attribs.src = img.attribs.src.replace('i0.wp.com/', '').split('?')[0];
|
||||
delete img.attribs.srcset;
|
||||
});
|
||||
};
|
||||
|
||||
const extractNotes = ($) => {
|
||||
$('.qoo-note-wrap')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const title = item.find('.qoo-note-view .content-title').text();
|
||||
const author = item.find('cite.name').text();
|
||||
const pubDate = timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm'), 8);
|
||||
item.find('cite.name, time, footer').remove();
|
||||
return {
|
||||
title,
|
||||
description: item.find('.qoo-note-view').html(),
|
||||
link: item.find('a.link-wrap').attr('href'),
|
||||
pubDate,
|
||||
author,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
appsUrl,
|
||||
newsUrl,
|
||||
notesUrl,
|
||||
ssoUrl,
|
||||
userUrl,
|
||||
siteIcon,
|
||||
fixImg,
|
||||
extractNotes,
|
||||
};
|
||||
Reference in New Issue
Block a user