|
|
|
@ -2,12 +2,12 @@
|
|
|
|
|
<div class="post-detail-container">
|
|
|
|
|
<!-- 作者信息栏 -->
|
|
|
|
|
<div class="author-info" v-if="author && author.userName">
|
|
|
|
|
<img
|
|
|
|
|
<img
|
|
|
|
|
:src="author.userAvatar || require('@/assets/default-avatar/boy_1.png')"
|
|
|
|
|
alt="头像"
|
|
|
|
|
class="author-avatar"
|
|
|
|
|
@click="goUserHome(author.userId)"
|
|
|
|
|
style="cursor: pointer;"
|
|
|
|
|
:style="{ cursor: postDetailStore.post?.status === 1 ? 'not-allowed' : 'pointer' }"
|
|
|
|
|
@click="handleAuthorAvatarClick"
|
|
|
|
|
/>
|
|
|
|
|
<div class="author-details">
|
|
|
|
|
<h3 class="author-name">{{ author.userName || '匿名用户' }}</h3>
|
|
|
|
@ -142,7 +142,7 @@
|
|
|
|
|
<script setup lang="js" name="PostDetail">
|
|
|
|
|
import { ref, computed, onMounted , onUnmounted, watch } from 'vue';
|
|
|
|
|
import { useRoute,useRouter } from 'vue-router';
|
|
|
|
|
import { ElMessageBox } from 'element-plus';
|
|
|
|
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
|
|
|
|
import { usePostDetailStore } from '@/stores/postdetail.js';
|
|
|
|
|
import { useUserStore } from '@/stores/user.js';
|
|
|
|
|
|
|
|
|
@ -238,6 +238,19 @@ function handleDelete(comment) {
|
|
|
|
|
postDetailStore.deleteComment(comment);
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleAuthorAvatarClick() {
|
|
|
|
|
// 判断用户名为匿名用户且头像为空时不跳转
|
|
|
|
|
if (
|
|
|
|
|
(author.value.userName === '匿名用户' || postDetailStore.post?.status === 1) &&
|
|
|
|
|
(!author.value.userAvatar || author.value.userAvatar === '')
|
|
|
|
|
) {
|
|
|
|
|
ElMessage.info('该用户为匿名用户');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
goUserHome(author.value.userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 监听 postDetailStore.post 加载完成后再允许滚动加载评论
|
|
|
|
|
watch(
|
|
|
|
|
() => postDetailStore.post,
|
|
|
|
|