diff --git a/docs/bbs.md b/docs/bbs.md
index 550b4eb8de..102baf2d40 100644
--- a/docs/bbs.md
+++ b/docs/bbs.md
@@ -611,22 +611,22 @@ pageClass: routes
## 一亩三分地
-### 主题帖
+### 帖子
+
+
+
+| 热门帖子 | 最新帖子 |
+| -------- | -------- |
+| hot | new |
+
+### 用户主题帖
-### 回帖
+### 用户回帖
-### 帖子 (手机端的最热与最新 Tab)
-
-
-
-| 最热帖子 | 最新帖子 |
-| -------- | -------- |
-| hot | new |
-
### 录取结果
diff --git a/lib/routes/1point3acres/post.js b/lib/routes/1point3acres/post.js
index a5009b3f73..bb818467ae 100644
--- a/lib/routes/1point3acres/post.js
+++ b/lib/routes/1point3acres/post.js
@@ -1,38 +1,50 @@
const got = require('@/utils/got');
+const bbcode = require('bbcodejs');
module.exports = async (ctx) => {
const category = ctx.params.category;
let url;
- let method;
- let description;
- let { title } = 'null';
- // eslint-disable-next-line eqeqeq
- if (title == 'null') {
- method = 'get';
+ let title;
+ if (category === 'new') {
+ url = 'https://api.1point3acres.com/api/threads?type=new&pg=1&ps=20&includes=summary';
+ title = '最新帖子';
+ } else {
+ url = 'https://api.1point3acres.com/api/threads?type=hot&pg=1&ps=20&includes=summary';
+ title = '热门帖子';
}
- // eslint-disable-next-line eqeqeq
- category == 'new'
- ? ((url = 'https://api.1point3acres.com/api/threads?type=new&pg=1&ps=20&includes=last_reply'), (title = '最新帖子'))
- : ((url = 'https://api.1point3acres.com/api/threads?type=hot&pg=1&ps=20&includes=last_reply'), (title = '最热帖子'));
const responseBasic = await got({
- method: method,
+ method: 'get',
url: url,
});
const data = responseBasic.data.threads;
- ctx.state.data = {
- title: `${title} - 一亩三分地`,
- link: `https://www.1point3acres.com/bbs/`,
- description: `${title} - 一亩三分地`,
- item: data.map((item) => {
- // eslint-disable-next-line eqeqeq
- item.last_reply.quote == '' ? (description = item.last_reply.message_bbcode) : (description = item.last_reply.quote);
- return {
+ const bbcodeParser = new bbcode.Parser();
+
+ const items = await Promise.all(
+ data.map(async (item) => {
+ const result = {
title: `${item.subject}`,
- // description: item.last_reply.message_bbcode,// + `楼主:` + item.author,
- description: description,
- // pubDate: new Date(item.submittime + ' GMT+8').toUTCString(),
+ description: `${item.summary}...
作者 ${item.author} · 回复 ${item.replies} · 查看 ${item.views}`,
link: `https://instant.1point3acres.com/thread/${item.tid}`,
};
- }),
+ try {
+ await ctx.cache.tryGet(item.link, async () => {
+ const detail = await got({
+ method: 'get',
+ url: `https://api.1point3acres.com/instant/threads/${item.tid}`,
+ referer: 'https://instant.1point3acres.com/',
+ });
+
+ result.description = `${bbcodeParser.toHTML(detail.data.thread.message_bbcode)}
作者 ${item.author} · 回复 ${item.replies} · 查看 ${item.views}`;
+ });
+ } catch (error) {
+ // nothing
+ }
+ return result;
+ })
+ );
+ ctx.state.data = {
+ title: `一亩三分地 - ${title}`,
+ link: `https://www.1point3acres.com/bbs/`,
+ item: items,
};
};
diff --git a/package.json b/package.json
index f2cec123b8..03cfe36ec6 100644
--- a/package.json
+++ b/package.json
@@ -69,6 +69,7 @@
"@sentry/node": "5.28.0",
"aes-js": "3.1.2",
"art-template": "4.13.2",
+ "bbcodejs": "0.0.4",
"cheerio": "1.0.0-rc.3",
"chrono-node": "2.1.10",
"co-redis": "2.1.1",
diff --git a/yarn.lock b/yarn.lock
index 9fe007c4f8..f3514bce5b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2822,6 +2822,11 @@ batch@0.6.1:
resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16"
integrity sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=
+bbcodejs@0.0.4:
+ version "0.0.4"
+ resolved "https://registry.yarnpkg.com/bbcodejs/-/bbcodejs-0.0.4.tgz#85f081738c9b6e71ec58a32a419734c987bf8305"
+ integrity sha1-hfCBc4ybbnHsWKMqQZc0yYe/gwU=
+
bcrypt-pbkdf@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e"