mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-21 18:07:28 +08:00
Preserve comment text on submission errors
This commit is contained in:
@@ -67,9 +67,11 @@ export default {
|
|||||||
if (!vditorInstance.value || isDisabled.value) return
|
if (!vditorInstance.value || isDisabled.value) return
|
||||||
const value = vditorInstance.value.getValue()
|
const value = vditorInstance.value.getValue()
|
||||||
console.debug('CommentEditor submit', value)
|
console.debug('CommentEditor submit', value)
|
||||||
emit('submit', value)
|
emit('submit', value, () => {
|
||||||
vditorInstance.value.setValue('')
|
if (!vditorInstance.value) return
|
||||||
text.value = ''
|
vditorInstance.value.setValue('')
|
||||||
|
text.value = ''
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ const CommentItem = {
|
|||||||
toast.error('操作失败')
|
toast.error('操作失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const submitReply = async (text) => {
|
const submitReply = async (text, clear) => {
|
||||||
if (!text.trim()) return
|
if (!text.trim()) return
|
||||||
isWaitingForReply.value = true
|
isWaitingForReply.value = true
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
@@ -201,6 +201,7 @@ const CommentItem = {
|
|||||||
src: data.author.avatar,
|
src: data.author.avatar,
|
||||||
iconClick: () => router.push(`/users/${data.author.id}`)
|
iconClick: () => router.push(`/users/${data.author.id}`)
|
||||||
})
|
})
|
||||||
|
clear()
|
||||||
showEditor.value = false
|
showEditor.value = false
|
||||||
toast.success('回复成功')
|
toast.success('回复成功')
|
||||||
} else if (res.status === 429) {
|
} else if (res.status === 429) {
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const postComment = async (text) => {
|
const postComment = async (text, clear) => {
|
||||||
if (!text.trim()) return
|
if (!text.trim()) return
|
||||||
console.debug('Posting comment', { postId, text })
|
console.debug('Posting comment', { postId, text })
|
||||||
isWaitingPostingComment.value = true
|
isWaitingPostingComment.value = true
|
||||||
@@ -385,6 +385,7 @@ export default {
|
|||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
console.debug('Post comment response data', data)
|
console.debug('Post comment response data', data)
|
||||||
await fetchComments()
|
await fetchComments()
|
||||||
|
clear()
|
||||||
if (data.reward && data.reward > 0) {
|
if (data.reward && data.reward > 0) {
|
||||||
toast.success(`评论成功,获得 ${data.reward} 经验值`)
|
toast.success(`评论成功,获得 ${data.reward} 经验值`)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user