Skip to content

Commit da65b95

Browse files
committed
add cursor time in comments response
1 parent 82824b1 commit da65b95

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

model/response.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type ArticleResponse struct {
6262
type CommentListResponse struct {
6363
ArticleID int64 `json:"article_id"`
6464
TotalNum int `json:"total_num"`
65+
Cursor int64 `json:"cursor"`
6566
CommentList []*CommentInfo `json:"comment_list"`
6667
}
6768

service/comments.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func (s *commentService) GetCommentList(articleID int64, cursorTime int64) (*mod
4545

4646
resp.ArticleID = articleID
4747
resp.TotalNum = len(comtList)
48+
resp.Cursor = cursorTime
4849
buildCommentList(comtList)
4950
return resp, nil
5051
}

site/components/CommentList.vue

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
v-slot="{ results }"
77
:init-data="commentsPage"
88
:params="{ entityType: entityType, entityId: entityId }"
9-
url="/api/comment/list"
9+
url="/api/comments"
1010
>
1111
<ul>
1212
<li
1313
v-for="(comment, index) in results"
14-
:key="comment.commentId"
14+
:key="comment.comment_id"
1515
class="comment"
1616
itemprop="comment"
1717
itemscope
@@ -33,18 +33,15 @@
3333
itemscope
3434
itemtype="http://schema.org/Person"
3535
>
36-
<a :href="'/user/' + comment.user.id" itemprop="name">
37-
{{ comment.user.nickname }}
38-
</a>
36+
<a :href="'/user/' + comment.user.id" itemprop="name">{{ comment.user.nickname }}</a>
3937
</span>
4038
<span class="comment-time">
4139
<time
4240
:datetime="
4341
comment.createTime | formatDate('yyyy-MM-ddTHH:mm:ss')
4442
"
4543
itemprop="datePublished"
46-
>{{ comment.createTime | prettyDate }}</time
47-
>
44+
>{{ comment.createTime | prettyDate }}</time>
4845
</span>
4946
<span class="comment-reply">
5047
<a @click="reply(comment)">回复</a>
@@ -55,20 +52,15 @@
5552
<div class="comment-quote-user">
5653
<avatar :user="comment.quote.user" size="20" />
5754
<a class="quote-nickname">{{ comment.quote.user.nickname }}</a>
58-
<span class="quote-time">
59-
{{ comment.quote.createTime | prettyDate }}
60-
</span>
55+
<span class="quote-time">{{ comment.quote.createTime | prettyDate }}</span>
6156
</div>
6257
<div
6358
v-lazy-container="{ selector: 'img' }"
6459
itemprop="text"
6560
v-html="comment.quote.content"
6661
/>
6762
</blockquote>
68-
<p
69-
v-lazy-container="{ selector: 'img' }"
70-
v-html="comment.content"
71-
/>
63+
<p v-lazy-container="{ selector: 'img' }" v-html="comment.content" />
7264
</div>
7365
</li>
7466
</ul>

site/pages/topic/_id.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,11 @@ export default {
205205
entityId: params.id,
206206
},
207207
}),
208-
$axios.get('/api/comments/list' + params.id),
208+
$axios.get('/api/comments', {
209+
params: {
210+
article_id: params.id,
211+
},
212+
}),
209213
$axios.get('/api/topic/recentlikes/' + params.id),
210214
])
211215

0 commit comments

Comments
 (0)