实现匿名发帖,只修改了postpublish.vue,postdetail.vue两个页面

main
Hacker-00001 4 weeks ago
parent 5280af67db
commit 6641070b5c

@ -17,38 +17,38 @@
# accessKey: forely # accessKey: forely
# secretKey: Forely123! # secretKey: Forely123!
#lj:
# db:
# host: 192.168.125.128
# password: MySQL@5678
# redis:
# host: 192.168.125.128
# port: 6379
# password: Redis@9012
# rabbitmq:
# host: 192.168.125.128
# port: 5672
# username: rabbit_admin
# password: Rabbit@3456
# minio:
# endpoint: http://192.168.125.128:9000
# accessKey: minio_admin
# secretKey: Minio@1234
lj: lj:
db: db:
host: localhost host: 192.168.125.128
password: 123456 password: MySQL@5678
redis: redis:
host: localhost host: 192.168.125.128
port: 6379 port: 6379
password: 123456 password: Redis@9012
rabbitmq: rabbitmq:
host: localhost host: 192.168.125.128
port: 5672 port: 5672
username: guest username: rabbit_admin
password: guest password: Rabbit@3456
minio: minio:
endpoint: http://localhost:9005 endpoint: http://192.168.125.128:9000
accessKey: leezt accessKey: minio_admin
secretKey: lzt264610 secretKey: Minio@1234
#lj:
# db:
# host: localhost
# password: 123456
# redis:
# host: localhost
# port: 6379
# password: 123456
# rabbitmq:
# host: localhost
# port: 5672
# username: guest
# password: guest
# minio:
# endpoint: http://localhost:9005
# accessKey: leezt
# secretKey: lzt264610

@ -131,7 +131,7 @@ export const usePostDetailStore = defineStore("postDetail", {
userAvatar, userAvatar,
createTime createTime
} = postRes.data; } = postRes.data;
console.log("获取帖子详情返回:", postRes.data);
// 主要帖子信息 // 主要帖子信息
this.post = { this.post = {
postId: id, postId: id,

@ -2,12 +2,12 @@
<div class="post-detail-container"> <div class="post-detail-container">
<!-- 作者信息栏 --> <!-- 作者信息栏 -->
<div class="author-info" v-if="author && author.userName"> <div class="author-info" v-if="author && author.userName">
<img <img
:src="author.userAvatar || require('@/assets/default-avatar/boy_1.png')" :src="author.userAvatar || require('@/assets/default-avatar/boy_1.png')"
alt="头像" alt="头像"
class="author-avatar" class="author-avatar"
@click="goUserHome(author.userId)" :style="{ cursor: postDetailStore.post?.status === 1 ? 'not-allowed' : 'pointer' }"
style="cursor: pointer;" @click="handleAuthorAvatarClick"
/> />
<div class="author-details"> <div class="author-details">
<h3 class="author-name">{{ author.userName || '匿名用户' }}</h3> <h3 class="author-name">{{ author.userName || '匿名用户' }}</h3>
@ -142,7 +142,7 @@
<script setup lang="js" name="PostDetail"> <script setup lang="js" name="PostDetail">
import { ref, computed, onMounted , onUnmounted, watch } from 'vue'; import { ref, computed, onMounted , onUnmounted, watch } from 'vue';
import { useRoute,useRouter } from 'vue-router'; import { useRoute,useRouter } from 'vue-router';
import { ElMessageBox } from 'element-plus'; import { ElMessageBox, ElMessage } from 'element-plus';
import { usePostDetailStore } from '@/stores/postdetail.js'; import { usePostDetailStore } from '@/stores/postdetail.js';
import { useUserStore } from '@/stores/user.js'; import { useUserStore } from '@/stores/user.js';
@ -238,6 +238,19 @@ function handleDelete(comment) {
postDetailStore.deleteComment(comment); postDetailStore.deleteComment(comment);
}).catch(() => {}); }).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 // postDetailStore.post
watch( watch(
() => postDetailStore.post, () => postDetailStore.post,

@ -34,6 +34,14 @@
</div> </div>
</div> </div>
<!-- 匿名发布选项放在内容编辑器下方或合适位置 -->
<div class="form-row">
<label>
<input type="checkbox" v-model="form.status" true-value="1" false-value="0" />
匿名发布
</label>
</div>
<!-- 内容编辑器 --> <!-- 内容编辑器 -->
<div class="form-row"> <div class="form-row">
<label>内容</label> <label>内容</label>

Loading…
Cancel
Save