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

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

@ -17,38 +17,38 @@
# accessKey: forely
# 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:
db:
host: localhost
password: 123456
host: 192.168.125.128
password: MySQL@5678
redis:
host: localhost
host: 192.168.125.128
port: 6379
password: 123456
password: Redis@9012
rabbitmq:
host: localhost
host: 192.168.125.128
port: 5672
username: guest
password: guest
username: rabbit_admin
password: Rabbit@3456
minio:
endpoint: http://localhost:9005
accessKey: leezt
secretKey: lzt264610
endpoint: http://192.168.125.128:9000
accessKey: minio_admin
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,
createTime
} = postRes.data;
console.log("获取帖子详情返回:", postRes.data);
// 主要帖子信息
this.post = {
postId: id,

@ -6,8 +6,8 @@
: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,

@ -34,6 +34,14 @@
</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">
<label>内容</label>

Loading…
Cancel
Save