BUG fix: PublishComment
This commit is contained in:
parent
93d2ce395c
commit
1f33d3b765
|
@ -102,16 +102,6 @@ export const useKUNGalgameTopicStore = defineStore({
|
||||||
|
|
||||||
isReplyRewriting: false,
|
isReplyRewriting: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
commentDraft: {
|
|
||||||
tid: 0,
|
|
||||||
rid: 0,
|
|
||||||
c_uid: 0,
|
|
||||||
to_uid: 0,
|
|
||||||
content: '',
|
|
||||||
|
|
||||||
isShowCommentPanelRid: 0,
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
// 左侧相同标签下的其它话题
|
// 左侧相同标签下的其它话题
|
||||||
|
@ -265,12 +255,17 @@ export const useKUNGalgameTopicStore = defineStore({
|
||||||
},
|
},
|
||||||
|
|
||||||
// 创建一个评论
|
// 创建一个评论
|
||||||
async postNewComment(): Promise<TopicCreateCommentResponseData> {
|
async postNewComment(
|
||||||
|
tid: number,
|
||||||
|
rid: number,
|
||||||
|
toUid: number,
|
||||||
|
content: string
|
||||||
|
): Promise<TopicCreateCommentResponseData> {
|
||||||
const requestData: TopicCreateCommentRequestData = {
|
const requestData: TopicCreateCommentRequestData = {
|
||||||
tid: this.commentDraft.tid,
|
tid: tid,
|
||||||
rid: this.commentDraft.rid,
|
rid: rid,
|
||||||
to_uid: this.commentDraft.to_uid,
|
to_uid: toUid,
|
||||||
content: this.commentDraft.content,
|
content: content,
|
||||||
}
|
}
|
||||||
return await postCommentByPidAndRidApi(requestData)
|
return await postCommentByPidAndRidApi(requestData)
|
||||||
},
|
},
|
||||||
|
@ -291,16 +286,6 @@ export const useKUNGalgameTopicStore = defineStore({
|
||||||
this.replyRequest.page = 1
|
this.replyRequest.page = 1
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
},
|
},
|
||||||
// 设置评论草稿为原始值,用于评论发布按钮
|
|
||||||
resetCommentDraft() {
|
|
||||||
this.commentDraft.tid = 0
|
|
||||||
this.commentDraft.rid = 0
|
|
||||||
this.commentDraft.c_uid = 0
|
|
||||||
this.commentDraft.to_uid = 0
|
|
||||||
this.commentDraft.content = ''
|
|
||||||
|
|
||||||
this.commentDraft.isShowCommentPanelRid = 0
|
|
||||||
},
|
|
||||||
// 重置重新编辑回复数据,用于重新编辑回复
|
// 重置重新编辑回复数据,用于重新编辑回复
|
||||||
resetRewriteTopicData() {
|
resetRewriteTopicData() {
|
||||||
this.replyDraft.textCount = 0
|
this.replyDraft.textCount = 0
|
||||||
|
|
20
src/store/temp/comment.ts
Normal file
20
src/store/temp/comment.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// 评论的临时数据,用于组件间传输
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useTempCommentStore = defineStore({
|
||||||
|
id: 'tempComment',
|
||||||
|
// 不持久
|
||||||
|
persist: false,
|
||||||
|
state: () => ({
|
||||||
|
tid: 0,
|
||||||
|
rid: 0,
|
||||||
|
toUid: 0,
|
||||||
|
toUsername: '',
|
||||||
|
content: '',
|
||||||
|
|
||||||
|
// 要展示哪个回复底下的评论面板
|
||||||
|
isShowCommentPanelRid: 0,
|
||||||
|
}),
|
||||||
|
getters: {},
|
||||||
|
actions: {},
|
||||||
|
})
|
16
src/store/types/topic.d.ts
vendored
16
src/store/types/topic.d.ts
vendored
|
@ -36,19 +36,6 @@ interface ReplyRequest {
|
||||||
sortOrder: 'asc' | 'desc'
|
sortOrder: 'asc' | 'desc'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 评论的缓存
|
|
||||||
interface CommentDraft {
|
|
||||||
// 评论的内容
|
|
||||||
tid: number
|
|
||||||
rid: number
|
|
||||||
c_uid: number
|
|
||||||
to_uid: number
|
|
||||||
content: string
|
|
||||||
|
|
||||||
// 显示哪个评论的评论面板
|
|
||||||
isShowCommentPanelRid: number
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新评论的缓存
|
// 更新评论的缓存
|
||||||
interface ReplyRewrite {
|
interface ReplyRewrite {
|
||||||
tid: number
|
tid: number
|
||||||
|
@ -83,7 +70,4 @@ export interface TopicStore {
|
||||||
replyRequest: ReplyRequest
|
replyRequest: ReplyRequest
|
||||||
// 更新评论的缓存
|
// 更新评论的缓存
|
||||||
replyRewrite: ReplyRewrite
|
replyRewrite: ReplyRewrite
|
||||||
|
|
||||||
// 评论的缓存
|
|
||||||
commentDraft: CommentDraft
|
|
||||||
}
|
}
|
||||||
|
|
18
src/utils/toggle.ts
Normal file
18
src/utils/toggle.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const toggleStatus = (initState: boolean, delay: number) => {
|
||||||
|
const on = ref(initState ?? false)
|
||||||
|
|
||||||
|
const toggle = (value: boolean) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
on.value = value ?? !on.value
|
||||||
|
}, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
on,
|
||||||
|
toggle,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default toggleStatus
|
|
@ -32,6 +32,8 @@ import { useKUNGalgameTopicStore } from '@/store/modules/topic'
|
||||||
import { useTempReplyStore } from '@/store/temp/reply'
|
import { useTempReplyStore } from '@/store/temp/reply'
|
||||||
// 回复重新编辑响应的临时数据
|
// 回复重新编辑响应的临时数据
|
||||||
import { useTempReplyRewriteStore } from '@/store/temp/replyRewrite'
|
import { useTempReplyRewriteStore } from '@/store/temp/replyRewrite'
|
||||||
|
// 使用不持久的评论 store
|
||||||
|
import { useTempCommentStore } from '@/store/temp/comment'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
// 当前的路由
|
// 当前的路由
|
||||||
|
@ -42,7 +44,6 @@ const {
|
||||||
isShowAdvance,
|
isShowAdvance,
|
||||||
isEdit,
|
isEdit,
|
||||||
replyRequest,
|
replyRequest,
|
||||||
commentDraft,
|
|
||||||
isScrollToTop,
|
isScrollToTop,
|
||||||
isLoading,
|
isLoading,
|
||||||
scrollToReplyId,
|
scrollToReplyId,
|
||||||
|
@ -51,6 +52,7 @@ const { tempReply } = storeToRefs(useTempReplyStore())
|
||||||
const { rid, replyContent, tags, edited } = storeToRefs(
|
const { rid, replyContent, tags, edited } = storeToRefs(
|
||||||
useTempReplyRewriteStore()
|
useTempReplyRewriteStore()
|
||||||
)
|
)
|
||||||
|
const { isShowCommentPanelRid } = storeToRefs(useTempCommentStore())
|
||||||
|
|
||||||
const tid = computed(() => {
|
const tid = computed(() => {
|
||||||
return Number(route.params.tid)
|
return Number(route.params.tid)
|
||||||
|
@ -227,7 +229,7 @@ const topicPageWidth = computed(() => {
|
||||||
|
|
||||||
// 在页面跳转和刷新时关闭回复面板和评论面板
|
// 在页面跳转和刷新时关闭回复面板和评论面板
|
||||||
const resetPanelStatus = () => {
|
const resetPanelStatus = () => {
|
||||||
commentDraft.value.isShowCommentPanelRid = 0
|
isShowCommentPanelRid.value = 0
|
||||||
isShowAdvance.value = false
|
isShowAdvance.value = false
|
||||||
isEdit.value = false
|
isEdit.value = false
|
||||||
// 重置重新编辑回复的数据
|
// 重置重新编辑回复的数据
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
// 全局消息组件(顶部)
|
// 全局消息组件(顶部)
|
||||||
import message from '@/components/alert/Message'
|
import message from '@/components/alert/Message'
|
||||||
import { debounce } from '@/utils/debounce'
|
import { debounce } from '@/utils/debounce'
|
||||||
|
@ -10,28 +10,20 @@ import { TopicComment } from '@/api/index'
|
||||||
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
|
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
|
||||||
// 导入话题页面 store
|
// 导入话题页面 store
|
||||||
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
|
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
|
||||||
|
// 使用不持久的评论 store
|
||||||
|
import { useTempCommentStore } from '@/store/temp/comment'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
const { name, uid } = storeToRefs(useKUNGalgameUserStore())
|
const { name } = storeToRefs(useKUNGalgameUserStore())
|
||||||
|
|
||||||
// 定于父组件 props
|
const { tid, rid, toUid, toUsername, content, isShowCommentPanelRid } =
|
||||||
const props = defineProps<{
|
storeToRefs(useTempCommentStore())
|
||||||
tid: number
|
|
||||||
rid: number
|
|
||||||
to_user: {
|
|
||||||
uid: number
|
|
||||||
name: string
|
|
||||||
}
|
|
||||||
}>()
|
|
||||||
|
|
||||||
// 定义父组件 emits
|
// 定义父组件 emits
|
||||||
const emits = defineEmits<{
|
const emits = defineEmits<{
|
||||||
getCommentEmits: [newComment: TopicComment]
|
getCommentEmits: [newComment: TopicComment]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// 使用评论的 store
|
|
||||||
const { commentDraft } = storeToRefs(useKUNGalgameTopicStore())
|
|
||||||
|
|
||||||
// 评论的内容
|
// 评论的内容
|
||||||
const commentValue = ref('')
|
const commentValue = ref('')
|
||||||
|
|
||||||
|
@ -39,32 +31,23 @@ const commentValue = ref('')
|
||||||
const handleInputComment = () => {
|
const handleInputComment = () => {
|
||||||
// 创建一个防抖处理函数
|
// 创建一个防抖处理函数
|
||||||
const debouncedUpdateContent = debounce(() => {
|
const debouncedUpdateContent = debounce(() => {
|
||||||
commentDraft.value.content = commentValue.value
|
content.value = commentValue.value
|
||||||
}, 1007)
|
}, 1007)
|
||||||
|
|
||||||
// 调用防抖处理函数,会在延迟时间内只执行一次更新操作
|
// 调用防抖处理函数,会在延迟时间内只执行一次更新操作
|
||||||
debouncedUpdateContent()
|
debouncedUpdateContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存评论信息
|
|
||||||
const saveComment = () => {
|
|
||||||
commentDraft.value.tid = props.tid
|
|
||||||
commentDraft.value.rid = props.rid
|
|
||||||
commentDraft.value.c_uid = uid.value
|
|
||||||
commentDraft.value.to_uid = props.to_user.uid
|
|
||||||
commentDraft.value.content = commentValue.value
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查评论是否合法
|
// 检查评论是否合法
|
||||||
const isValidComment = () => {
|
const isValidComment = () => {
|
||||||
// 评论内容为空警告
|
// 评论内容为空警告
|
||||||
if (!commentDraft.value.content.trim()) {
|
if (!content.value.trim()) {
|
||||||
message('Comment content cannot be empty!', '评论内容不能为空!', 'warn')
|
message('Comment content cannot be empty!', '评论内容不能为空!', 'warn')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 评论内容超出限制警告
|
// 评论内容超出限制警告
|
||||||
if (commentDraft.value.content.trim().length > 1007) {
|
if (content.value.trim().length > 1007) {
|
||||||
message(
|
message(
|
||||||
'The maximum length for comments should not exceed 1007 characters.',
|
'The maximum length for comments should not exceed 1007 characters.',
|
||||||
'评论最大长度不可超过1007个字符',
|
'评论最大长度不可超过1007个字符',
|
||||||
|
@ -76,45 +59,44 @@ const isValidComment = () => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 挂载时初始化评论信息
|
|
||||||
onMounted(() => {
|
|
||||||
// 首先重置评论内容
|
|
||||||
useKUNGalgameTopicStore().resetCommentDraft()
|
|
||||||
})
|
|
||||||
|
|
||||||
// 发布评论
|
// 发布评论
|
||||||
const handlePublishComment = async () => {
|
const handlePublishComment = async () => {
|
||||||
// 保存当前的回复内容
|
|
||||||
saveComment()
|
|
||||||
|
|
||||||
if (isValidComment()) {
|
if (isValidComment()) {
|
||||||
// 获取新评论
|
// 获取新评论
|
||||||
const newComment = (await useKUNGalgameTopicStore().postNewComment()).data
|
const newComment = (
|
||||||
|
await useKUNGalgameTopicStore().postNewComment(
|
||||||
// 发表完毕还原回复内容
|
tid.value,
|
||||||
useKUNGalgameTopicStore().resetCommentDraft()
|
rid.value,
|
||||||
|
toUid.value,
|
||||||
|
content.value
|
||||||
|
)
|
||||||
|
).data
|
||||||
|
|
||||||
// 将新的评论内容给父组件
|
// 将新的评论内容给父组件
|
||||||
emits('getCommentEmits', newComment)
|
emits('getCommentEmits', newComment)
|
||||||
|
|
||||||
// 提醒用户
|
// 提醒用户
|
||||||
message('Comment publish successfully!', '评论发布成功', 'success')
|
message('Comment publish successfully!', '评论发布成功', 'success')
|
||||||
|
|
||||||
|
handleCloseCommentPanel()
|
||||||
|
} else {
|
||||||
|
message('Comment publish failed!', '评论发布失败', 'success')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭评论面板
|
// 关闭评论面板
|
||||||
const handleCloseCommentPanel = () => {
|
const handleCloseCommentPanel = () => {
|
||||||
commentDraft.value.isShowCommentPanelRid = 0
|
isShowCommentPanelRid.value = 0
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="panel" v-if="commentDraft.isShowCommentPanelRid === rid">
|
<div class="panel">
|
||||||
<div class="top">
|
<div class="top">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<span>{{ name }}</span>
|
<span>{{ name }}</span>
|
||||||
<span>{{ $tm('topic.content.comment') }}</span>
|
<span>{{ $tm('topic.content.comment') }}</span>
|
||||||
<span>{{ to_user.name }}</span>
|
<span>{{ toUsername }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="confirm">
|
<div class="confirm">
|
||||||
<button @click="handlePublishComment">
|
<button @click="handlePublishComment">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
这是回复话题下方的评论区,包含了所有的评论,是一个单独的组件,它的子组件是单个评论
|
这是回复话题下方的评论区,包含了所有的评论,是一个单独的组件,它的子组件是单个评论
|
||||||
-->
|
-->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineAsyncComponent, onMounted, reactive, ref, toRaw } from 'vue'
|
import { defineAsyncComponent, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { Icon } from '@iconify/vue'
|
import { Icon } from '@iconify/vue'
|
||||||
const CommentPanel = defineAsyncComponent(() => import('./CommentPanel.vue'))
|
const CommentPanel = defineAsyncComponent(() => import('./CommentPanel.vue'))
|
||||||
|
|
||||||
|
@ -10,8 +10,14 @@ import { TopicComment } from '@/api/index'
|
||||||
|
|
||||||
// 导入话题页面 store
|
// 导入话题页面 store
|
||||||
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
|
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
|
||||||
|
|
||||||
|
// 使用不持久的评论 store
|
||||||
|
import { useTempCommentStore } from '@/store/temp/comment'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
const { commentDraft } = storeToRefs(useKUNGalgameTopicStore())
|
|
||||||
|
const { tid, rid, toUid, toUsername, isShowCommentPanelRid } = storeToRefs(
|
||||||
|
useTempCommentStore()
|
||||||
|
)
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
tid: number
|
tid: number
|
||||||
|
@ -22,16 +28,25 @@ const props = defineProps<{
|
||||||
}
|
}
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// 评论的数据
|
const tidRef = ref(props.tid)
|
||||||
const commentsData = ref<TopicComment[]>()
|
const ridRef = ref(props.rid)
|
||||||
// 评论给谁
|
const toUser = ref(props.toUser)
|
||||||
const toUserInfo = reactive({
|
|
||||||
uid: 0,
|
|
||||||
name: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
const getComments = async (tid: number, rid: number) => {
|
// 响应式
|
||||||
return (await useKUNGalgameTopicStore().getComments(tid, rid)).data
|
watch(
|
||||||
|
() => props.rid,
|
||||||
|
async () => {
|
||||||
|
ridRef.value = props.rid
|
||||||
|
toUser.value = props.toUser
|
||||||
|
commentsData.value = await getComments(tidRef.value, ridRef.value)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// 评论的数据
|
||||||
|
const commentsData = ref<TopicComment[]>([])
|
||||||
|
|
||||||
|
const getComments = async (topicId: number, replyId: number) => {
|
||||||
|
return (await useKUNGalgameTopicStore().getComments(topicId, replyId)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拿到新发布的评论并 push 到原来的数据里,无需重新获取
|
// 拿到新发布的评论并 push 到原来的数据里,无需重新获取
|
||||||
|
@ -40,21 +55,22 @@ const getCommentEmits = (newComment: TopicComment) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 将用户信息给回复面板
|
commentsData.value = await getComments(tidRef.value, ridRef.value)
|
||||||
toUserInfo.name = props.toUser.name
|
|
||||||
toUserInfo.uid = props.toUser.uid
|
|
||||||
|
|
||||||
commentsData.value = await getComments(props.tid, props.rid)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 点击回复
|
// 点击回复
|
||||||
const handleClickReply = (uid: number, name: string) => {
|
const handleClickComment = (
|
||||||
// 将当前回复的信息给回复面板
|
topicId: number,
|
||||||
toUserInfo.name = name
|
replyId: number,
|
||||||
toUserInfo.uid = uid
|
uid: number,
|
||||||
|
name: string
|
||||||
|
) => {
|
||||||
|
tid.value = topicId
|
||||||
|
rid.value = replyId
|
||||||
|
toUid.value = uid
|
||||||
|
toUsername.value = name
|
||||||
// 打开回复面板
|
// 打开回复面板
|
||||||
commentDraft.value.isShowCommentPanelRid = props.rid
|
isShowCommentPanelRid.value = ridRef.value
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -64,9 +80,7 @@ const handleClickReply = (uid: number, name: string) => {
|
||||||
<!-- 评论的弹出面板 -->
|
<!-- 评论的弹出面板 -->
|
||||||
<CommentPanel
|
<CommentPanel
|
||||||
@getCommentEmits="getCommentEmits"
|
@getCommentEmits="getCommentEmits"
|
||||||
:tid="tid"
|
v-if="isShowCommentPanelRid === ridRef"
|
||||||
:rid="rid"
|
|
||||||
:to_user="toUserInfo"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 评论的展示区域 -->
|
<!-- 评论的展示区域 -->
|
||||||
|
@ -107,7 +121,12 @@ const handleClickReply = (uid: number, name: string) => {
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
@click="
|
@click="
|
||||||
handleClickReply(comment.c_user.uid, comment.c_user.name)
|
handleClickComment(
|
||||||
|
comment.tid,
|
||||||
|
comment.rid,
|
||||||
|
comment.c_user.uid,
|
||||||
|
comment.c_user.name
|
||||||
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<Icon class="icon" icon="fa-regular:comment-dots" />
|
<Icon class="icon" icon="fa-regular:comment-dots" />
|
||||||
|
|
|
@ -105,7 +105,7 @@ const currUserUid = useKUNGalgameUserStore().uid
|
||||||
<!-- 分享 -->
|
<!-- 分享 -->
|
||||||
<span class="icon"><Icon icon="majesticons:share-line" /></span>
|
<span class="icon"><Icon icon="majesticons:share-line" /></span>
|
||||||
|
|
||||||
<!-- 只看 -->
|
<!-- 只看 TODO: -->
|
||||||
<!-- <span class="icon"><Icon icon="ph:user-focus-duotone" /></span> -->
|
<!-- <span class="icon"><Icon icon="ph:user-focus-duotone" /></span> -->
|
||||||
|
|
||||||
<!-- 编辑 -->
|
<!-- 编辑 -->
|
||||||
|
|
|
@ -28,9 +28,16 @@ import { TopicReply } from '@/api/index'
|
||||||
|
|
||||||
// 导入话题页面 store
|
// 导入话题页面 store
|
||||||
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
|
import { useKUNGalgameTopicStore } from '@/store/modules/topic'
|
||||||
|
|
||||||
|
// 使用不持久的评论 store
|
||||||
|
import { useTempCommentStore } from '@/store/temp/comment'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
const { scrollToReplyId, commentDraft } = storeToRefs(useKUNGalgameTopicStore())
|
const { scrollToReplyId } = storeToRefs(useKUNGalgameTopicStore())
|
||||||
|
|
||||||
|
const { tid, rid, toUid, toUsername, isShowCommentPanelRid } = storeToRefs(
|
||||||
|
useTempCommentStore()
|
||||||
|
)
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
repliesData: TopicReply[]
|
repliesData: TopicReply[]
|
||||||
|
@ -42,12 +49,21 @@ const replies = computed(() => props.repliesData)
|
||||||
// 控制面板关闭的值
|
// 控制面板关闭的值
|
||||||
const isCommentPanelOpen = ref(false)
|
const isCommentPanelOpen = ref(false)
|
||||||
// 切换面板的状态
|
// 切换面板的状态
|
||||||
const handleClickComment = (rid: number) => {
|
const handleClickComment = (
|
||||||
|
topicId: number,
|
||||||
|
replyIid: number,
|
||||||
|
uid: number,
|
||||||
|
name: string
|
||||||
|
) => {
|
||||||
isCommentPanelOpen.value = !isCommentPanelOpen.value
|
isCommentPanelOpen.value = !isCommentPanelOpen.value
|
||||||
if (isCommentPanelOpen.value) {
|
if (isCommentPanelOpen.value) {
|
||||||
commentDraft.value.isShowCommentPanelRid = rid
|
tid.value = topicId
|
||||||
|
rid.value = replyIid
|
||||||
|
toUid.value = uid
|
||||||
|
toUsername.value = name
|
||||||
|
isShowCommentPanelRid.value = replyIid
|
||||||
} else {
|
} else {
|
||||||
commentDraft.value.isShowCommentPanelRid = 0
|
isShowCommentPanelRid.value = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -132,7 +148,17 @@ const handleClickComment = (rid: number) => {
|
||||||
:to-floor="reply.floor"
|
:to-floor="reply.floor"
|
||||||
>
|
>
|
||||||
<template #comment>
|
<template #comment>
|
||||||
<span @click="handleClickComment(reply.rid)" class="icon">
|
<span
|
||||||
|
@click="
|
||||||
|
handleClickComment(
|
||||||
|
reply.tid,
|
||||||
|
reply.rid,
|
||||||
|
reply.r_user.uid,
|
||||||
|
reply.r_user.name
|
||||||
|
)
|
||||||
|
"
|
||||||
|
class="icon"
|
||||||
|
>
|
||||||
<Icon icon="fa-regular:comment-dots" />
|
<Icon icon="fa-regular:comment-dots" />
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
@ -273,7 +299,7 @@ const handleClickComment = (rid: number) => {
|
||||||
|
|
||||||
/* 回复被推的样式 */
|
/* 回复被推的样式 */
|
||||||
.active-upvote .container {
|
.active-upvote .container {
|
||||||
border: 2px solid var(--kungalgame-pink-3);
|
border: 1px solid var(--kungalgame-red-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 滚动到指定话题激活后的样式 */
|
/* 滚动到指定话题激活后的样式 */
|
||||||
|
|
Loading…
Reference in a new issue