@@ -11,28 +11,30 @@ const props = defineProps<{
1111const galgame = inject <GalgameDetail >(' galgame' )
1212
1313const { commentToUid } = storeToRefs (useTempGalgameResourceStore ())
14- const { uid, roles } = usePersistUserStore ()
14+ const { id, role } = usePersistUserStore ()
1515
1616const isShowComment = ref (false )
1717const isShowDelete = computed (
18- () =>
19- props .comment .user ?.uid === uid || galgame ?.user .uid === uid || roles >= 2
18+ () => props .comment .user ?.id === id || galgame ?.user .id === id || role >= 2
2019)
2120
2221const handleClickComment = (uid : number ) => {
2322 isShowComment .value = ! isShowComment .value
2423 commentToUid .value = uid
2524}
2625
27- const handleDeleteComment = async (gid : number , gcid : number ) => {
26+ const handleDeleteComment = async (
27+ galgameId : number ,
28+ galgameCommentId : number
29+ ) => {
2830 const res = await useComponentMessageStore ().alert (' 您确定删除评论吗?' )
2931 if (! res ) {
3032 return
3133 }
3234
33- const result = await $fetch (` /api/galgame/${gid }/comment ` , {
35+ const result = await $fetch (` /api/galgame/${galgameId }/comment ` , {
3436 method: ' DELETE' ,
35- query: { gcid },
37+ query: { galgameCommentId },
3638 watch: false ,
3739 ... kungalgameResponseHandler
3840 })
@@ -51,10 +53,13 @@ const handleDeleteComment = async (gid: number, gcid: number) => {
5153 <div class =" flex w-full flex-col space-y-2" >
5254 <div class =" flex flex-wrap items-center" >
5355 <span class =" text-default-700" >{{ comment.user.name }}</span >
54- <div v-if =" comment.toUser " >
56+ <div v-if =" comment.targetUser " >
5557 <span class =" mx-2" >=></span >
56- <KunLink underline="hover" :to =" ` /user/${comment .toUser .uid }/info ` " >
57- {{ `${comment.toUser.name}` }}
58+ <KunLink
59+ underline="hover"
60+ :to =" ` /user/${comment .targetUser .id }/info ` "
61+ >
62+ {{ `${comment.targetUser.name}` }}
5863 </KunLink >
5964 </div >
6065 </div >
@@ -63,14 +68,14 @@ const handleDeleteComment = async (gid: number, gcid: number) => {
6368
6469 <div class =" flex items-end justify-between" >
6570 <span class =" text-default-500 text-sm" >
66- 发布于 {{ formatTimeDifference(comment.time ) }}
71+ 发布于 {{ formatTimeDifference(comment.created ) }}
6772 </span >
6873
6974 <div class =" flex items-center justify-end gap-1" >
7075 <KunButton
7176 variant="flat"
7277 class-name="gap-1"
73- @click =" handleClickComment (comment .user .uid )"
78+ @click =" handleClickComment (comment .user .id )"
7479 >
7580 回复
7681 </KunButton >
@@ -85,19 +90,28 @@ const handleDeleteComment = async (gid: number, gcid: number) => {
8590 color="danger"
8691 size="lg"
8792 class-name="gap-1"
88- @click =" handleDeleteComment (comment .gid , comment .gcid )"
93+ @click =" handleDeleteComment (comment .galgameId , comment .id )"
8994 >
9095 <KunIcon name="lucide:trash-2 " />
9196 </KunButton >
9297 </KunTooltip >
9398 </div >
9499 </div >
95100
96- <GalgameCommentPanel
97- v-if =" isShowComment "
98- :refresh =" refresh "
99- @close =" isShowComment = false "
100- />
101+ <Transition
102+ enter-active-class="transition-all duration-300 ease-out"
103+ enter-from-class="opacity-0 max-h-0"
104+ enter-to-class="opacity-100 max-h-96"
105+ leave-active-class="transition-all duration-300 ease-in"
106+ leave-from-class="opacity-100 max-h-96"
107+ leave-to-class="opacity-0 max-h-0"
108+ >
109+ <GalgameCommentPanel
110+ v-if =" isShowComment "
111+ :refresh =" refresh "
112+ @close =" isShowComment = false "
113+ />
114+ </Transition >
101115 </div >
102116 </KunCard >
103117</template >
0 commit comments