Skip to content

Commit

Permalink
fix(docs, route): 梨园添加功能 & 修复文档示例 (#7446)
Browse files Browse the repository at this point in the history
  • Loading branch information
WooMai authored May 8, 2021
1 parent b30fe4a commit 2edfbe3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/bbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ pageClass: routes

### 主题帖(板块)

<Route author="WooMai" example="/liyuan-forums/threads/forum/:forum_id" path="/liyuan-forums/threads/forum/1" :paramsDesc="['板块 ID']" />
<Route author="WooMai" example="/liyuan-forums/threads/forum/1" path="/liyuan-forums/threads/forum/:forum_id" :paramsDesc="['板块 ID, 支持多个, 使用英文逗号分隔']" />

### 主题帖(专题)

<Route author="WooMai" example="/liyuan-forums/threads/topic/:topic_id" path="/liyuan-forums/threads/topic/1" :paramsDesc="['专题 ID']" />
<Route author="WooMai" example="/liyuan-forums/threads/topic/1" path="/liyuan-forums/threads/topic/:topic_id" :paramsDesc="['专题 ID, 支持多个, 使用英文逗号分隔']" />

### 主题帖(用户)

<Route author="WooMai" example="/liyuan-forums/threads/user/:user_id" path="/liyuan-forums/threads/user/1" :paramsDesc="['用户 ID, 仅支持数字 ID']" />
<Route author="WooMai" example="/liyuan-forums/threads/user/1" path="/liyuan-forums/threads/user/:user_id" :paramsDesc="['用户 ID (仅支持数字 ID), 支持多个, 使用英文逗号分隔']" />

## 龙空

Expand Down
29 changes: 22 additions & 7 deletions lib/routes/liyuan-forums/threads.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,38 @@ module.exports = async (ctx) => {
const topic_id = ctx.params.topic_id || null;
const user_id = ctx.params.user_id || null;

const query = ['initial_post=1'];
const query = ['initial_post=1', `order_by=create_time`];

let link = 'https://forums.liyuans.com/recent';

if (forum_id) {
query.push(`forum_id=${encodeURIComponent(forum_id)}`);
link = `https://forums.liyuans.com/forum/${forum_id}`;
if (!isNaN(forum_id)) {
query.push(`forum_id=${encodeURIComponent(forum_id)}`);
link = `https://forums.liyuans.com/forum/${forum_id}`;
} else {
query.push(`forum_ids=${encodeURIComponent(forum_id)}`);
link = `https://forums.liyuans.com`;
}
}

if (topic_id) {
query.push(`topic_id=${encodeURIComponent(topic_id)}`);
link = `https://forums.liyuans.com/topic/${topic_id}`;
if (!isNaN(topic_id)) {
query.push(`topic_id=${encodeURIComponent(topic_id)}`);
link = `https://forums.liyuans.com/topic/${topic_id}`;
} else {
query.push(`topic_ids=${encodeURIComponent(topic_id)}`);
link = `https://forums.liyuans.com`;
}
}

if (user_id) {
query.push(`user_id=${encodeURIComponent(user_id)}`);
link = `https://forums.liyuans.com/user/${user_id}`;
if (!isNaN(user_id)) {
query.push(`user_id=${encodeURIComponent(user_id)}`);
link = `https://forums.liyuans.com/user/${user_id}`;
} else {
query.push(`user_ids=${encodeURIComponent(user_id)}`);
link = `https://forums.liyuans.com`;
}
}

let qstr = '';
Expand Down

1 comment on commit 2edfbe3

@vercel
Copy link

@vercel vercel bot commented on 2edfbe3 May 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.