feat: 本地回复数据fixed

This commit is contained in:
tim
2025-08-10 12:26:22 +08:00
parent 8c1386a2d0
commit 2a5bff1086
4 changed files with 15 additions and 10 deletions

View File

@@ -47,6 +47,10 @@ export default {
showLoginOverlay: {
type: Boolean,
default: false
},
parentUserName: {
type: String,
default: ''
}
},
components: { LoginOverlay },
@@ -71,7 +75,7 @@ export default {
if (!vditorInstance.value || isDisabled.value) return
const value = vditorInstance.value.getValue()
console.debug('CommentEditor submit', value)
emit('submit', value, () => {
emit('submit', props.parentUserName, value, () => {
if (!vditorInstance.value) return
vditorInstance.value.setValue('')
text.value = ''

View File

@@ -44,7 +44,7 @@
</div>
<div class="comment-editor-wrapper">
<CommentEditor v-if="showEditor" @submit="submitReply" :loading="isWaitingForReply" :disabled="!loggedIn"
:show-login-overlay="!loggedIn" />
:show-login-overlay="!loggedIn" :parent-user-name="comment.userName" />
</div>
<div v-if="replyCount && level < 2" class="reply-toggle" @click="toggleReplies">
<i v-if="showReplies" class="fas fa-chevron-up reply-toggle-icon"></i>
@@ -164,7 +164,7 @@ const CommentItem = {
toast.error('操作失败')
}
}
const submitReply = async (text, clear) => {
const submitReply = async (parentUserName, text, clear) => {
if (!text.trim()) return
isWaitingForReply.value = true
const token = getToken()
@@ -190,7 +190,9 @@ const CommentItem = {
userName: data.author.username,
time: TimeManager.format(data.createdAt),
avatar: data.author.avatar,
medal: data.author.displayMedal,
text: data.content,
parentUserName: parentUserName,
reactions: [],
reply: (data.replies || []).map(r => ({
id: r.id,

View File

@@ -153,11 +153,6 @@ export default {
isLoadingTag.value = false
}
onMounted(() => {
// fetchCategoryData()
// fetchTagData()
})
const iconClass = computed(() => {
switch (themeState.mode) {
case ThemeMode.DARK:

View File

@@ -21,11 +21,15 @@
</div>
<div v-if="loggedIn && !isAuthor && !subscribed" class="article-subscribe-button" @click="subscribePost">
<i class="fas fa-user-plus"></i>
<div class="article-subscribe-button-text">订阅文章</div>
<div class="article-subscribe-button-text">
{{ isMobile ? '订阅' : '订阅文章' }}
</div>
</div>
<div v-if="loggedIn && !isAuthor && subscribed" class="article-unsubscribe-button" @click="unsubscribePost">
<i class="fas fa-user-minus"></i>
<div class="article-unsubscribe-button-text">取消订阅</div>
<div class="article-unsubscribe-button-text">
{{ isMobile ? '退订' : '取消订阅' }}
</div>
</div>
<DropdownMenu v-if="articleMenuItems.length > 0" :items="articleMenuItems">
<template #trigger>