2026-05-16 14:28:42 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="comments-page">
|
|
|
|
|
|
<header class="page-head">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<h2>评论管理</h2>
|
|
|
|
|
|
<p>查看作品评论与回复,删除不合规内容。</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<a-input-search v-model:value="keyword" class="search" allow-clear placeholder="搜索评论内容" @search="loadComments" />
|
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
|
|
<a-table
|
|
|
|
|
|
:columns="columns"
|
|
|
|
|
|
:data-source="comments"
|
|
|
|
|
|
:loading="loading"
|
|
|
|
|
|
:pagination="{ pageSize: 10 }"
|
|
|
|
|
|
row-key="id"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
|
|
|
<template v-if="column.key === 'commentContent'">
|
|
|
|
|
|
<div class="comment-cell">
|
|
|
|
|
|
<strong>{{ record.commentContent }}</strong>
|
|
|
|
|
|
<span v-if="record.parentCommentContent">回复:{{ record.parentCommentContent }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="column.key === 'action'">
|
|
|
|
|
|
<a-popconfirm title="确认删除这条评论?" ok-text="删除" cancel-text="取消" @confirm="deleteComment(record.id)">
|
|
|
|
|
|
<a-button danger type="link">删除</a-button>
|
|
|
|
|
|
</a-popconfirm>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</a-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* CommentsView page script.
|
|
|
|
|
|
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
|
|
|
|
|
*/
|
2026-05-16 14:28:42 +08:00
|
|
|
|
import { onMounted, ref } from 'vue'
|
|
|
|
|
|
import { message } from 'ant-design-vue'
|
|
|
|
|
|
import { adminCommentApi, type AdminCommentVO } from '@/api/admin'
|
|
|
|
|
|
import type { IdType } from '@/utils/id'
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** loading is a reactive state variable used by the template and event handlers. */
|
2026-05-16 14:28:42 +08:00
|
|
|
|
const loading = ref(false)
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** keyword is a reactive state variable used by the template and event handlers. */
|
2026-05-16 14:28:42 +08:00
|
|
|
|
const keyword = ref('')
|
|
|
|
|
|
const comments = ref<AdminCommentVO[]>([])
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
|
|
{ title: '评论内容', dataIndex: 'commentContent', key: 'commentContent' },
|
|
|
|
|
|
{ title: '用户', dataIndex: 'userNickname', key: 'userNickname', width: 140 },
|
|
|
|
|
|
{ title: '作品', dataIndex: 'productTitle', key: 'productTitle', width: 180 },
|
|
|
|
|
|
{ title: '门店', dataIndex: 'shopName', key: 'shopName', width: 160 },
|
|
|
|
|
|
{ title: '时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
|
|
|
|
|
|
{ title: '操作', key: 'action', width: 100 }
|
|
|
|
|
|
]
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** loadComments is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-05-16 14:28:42 +08:00
|
|
|
|
const loadComments = async () => {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
comments.value = await adminCommentApi.listComments({ keyword: keyword.value || undefined })
|
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
|
message.error(error?.message || '评论加载失败')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
|
/** deleteComment is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
2026-05-16 14:28:42 +08:00
|
|
|
|
const deleteComment = async (id: IdType) => {
|
|
|
|
|
|
await adminCommentApi.deleteComment(id)
|
|
|
|
|
|
message.success('评论已删除')
|
|
|
|
|
|
await loadComments()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(loadComments)
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.comments-page {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
gap: 18px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.page-head {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.page-head h2 {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
font-size: 22px;
|
|
|
|
|
|
color: #20232a;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.page-head p {
|
|
|
|
|
|
margin: 6px 0 0;
|
|
|
|
|
|
color: #687385;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search {
|
|
|
|
|
|
width: min(360px, 100%);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.comment-cell {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.comment-cell strong {
|
|
|
|
|
|
color: #20232a;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.comment-cell span {
|
|
|
|
|
|
color: #7b8494;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|