Skip to content

Commit 5119f0d

Browse files
committed
fix: 修复回复评论以及回复子评论没有字数限制的 bug
1 parent a582348 commit 5119f0d

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/client/view/comment.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
88
export let comments = []
99
export let replying = []
10+
export let wordLimit = {
11+
nick: 0,
12+
mail: 0,
13+
site: 0,
14+
content: 0
15+
}
1016
1117
let D = $options
1218
const dispatch = createEventDispatcher()
@@ -77,7 +83,7 @@
7783
<!-- 反之如果点击的是子评论的回复按钮,那么就将当前评论id传入,而(父评论id)pid为当前评论的(父评论id)pid -->
7884
<button class="D-reply" on:click={onReply(comment.id, comment.pid)}>{translate('reply')}</button>
7985
{#if replying === comment.id}
80-
<Submit cancel={true} {pid} {rid} on:onCancel={onReply} on:submitComment={submitComment} />
86+
<Submit cancel={true} {pid} {rid} {wordLimit} on:onCancel={onReply} on:submitComment={submitComment} />
8187
{/if}
8288
{#if comment.replys}
8389
<div class="D-comments-child">
@@ -89,7 +95,7 @@
8995
child: on:onReply -> comment.svelte -> comments.svelte
9096
-->
9197
<!-- 简而言之: 此处的 on:onReply 与上方<script>里面的 onReply 方法没有半毛钱关系(仅和回复按钮的 on:click=onReply 有关系) -->
92-
<svelte:self comments={comment.replys} {replying} on:onReply on:submitComment={submitComment} />
98+
<svelte:self comments={comment.replys} {replying} {wordLimit} on:onReply on:submitComment={submitComment} />
9399
</div>
94100
{/if}
95101
</div>

src/client/view/comments.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
pageCount = 1,
2121
showMore = false,
2222
loading = false,
23-
replying = ''
23+
replying = '',
24+
wordLimit
2425
2526
// 相当于vue中的watch
2627
$: {
@@ -47,6 +48,8 @@
4748
pageCount = data.pageCount
4849
comments = [...comments, ...data.comments]
4950
51+
wordLimit = data.wordNumber
52+
5053
dispatch('onComment', comments.length)
5154
dispatch('wordLimit', data.wordNumber)
5255
} catch (error) {
@@ -91,7 +94,13 @@
9194
{/if}
9295
</div>
9396
<div class="D-comments-list">
94-
<Comment {comments} {replying} on:onReply={({ detail }) => (replying = detail)} on:submitComment={submitComment} />
97+
<Comment
98+
{comments}
99+
{replying}
100+
{wordLimit}
101+
on:onReply={({ detail }) => (replying = detail)}
102+
on:submitComment={submitComment}
103+
/>
95104
</div>
96105
{#if showMore}
97106
<div class="D-more">

0 commit comments

Comments
 (0)