|
|
|
@ -103,9 +103,10 @@
|
|
|
|
|
</div>
|
|
|
|
|
<p class="post-summary">{{ post.summary }}</p>
|
|
|
|
|
<div class="post-stats">
|
|
|
|
|
<span><i class="icon-view"></i> {{ post.viewCount || 0 }}</span>
|
|
|
|
|
<span><i class="icon-like"></i> {{ post.likeCount || 0 }}</span>
|
|
|
|
|
<span><i class="icon-comment"></i> {{ post.commentCount || 0 }}</span>
|
|
|
|
|
<span><i class="icon-view"></i> 热度 {{ post.viewCount || 0 }}</span>
|
|
|
|
|
<span><i class="icon-comment"></i> 评论 {{ post.commentCount || 0 }}</span>
|
|
|
|
|
<span><i class="icon-like"></i> 赞 {{ post.likeCount || 0 }}</span>
|
|
|
|
|
<span v-if="isCurrentUser" class="delete-btn" @click.stop="deletePost(post.id)">删除</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -306,6 +307,26 @@ const loadUserPosts = async () => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除帖子
|
|
|
|
|
const deletePost = async (postId) => {
|
|
|
|
|
if (!postId) return;
|
|
|
|
|
if (!confirm('确定要删除这条帖子吗?')) return;
|
|
|
|
|
try {
|
|
|
|
|
const res = await request.delete('/post', { params: { id: postId } });
|
|
|
|
|
if (res && res.code === 200) {
|
|
|
|
|
// 删除本地列表中的帖子
|
|
|
|
|
userPosts.value = userPosts.value.filter(post => post.id !== postId);
|
|
|
|
|
ElMessage.success('删除成功');
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error(res.message || '删除失败');
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
ElMessage.error(e.response?.message || '删除失败');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 加载更多帖子
|
|
|
|
|
const loadMorePosts = () => {
|
|
|
|
|
loadUserPosts();
|
|
|
|
@ -752,4 +773,16 @@ onUnmounted(() => {
|
|
|
|
|
color: #999;
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.delete-btn {
|
|
|
|
|
right: 16px;
|
|
|
|
|
bottom: 12px;
|
|
|
|
|
color: #fff;
|
|
|
|
|
background: #f56c6c;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
padding: 4px 12px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|