feat: add profile click

This commit is contained in:
tim
2025-07-09 17:54:16 +08:00
parent ef08bf32bd
commit 5554594123
4 changed files with 23 additions and 10 deletions

View File

@@ -13,7 +13,7 @@
</div>
<div class="info-content-container author-info-container">
<div class="user-avatar-container">
<div class="user-avatar-container" @click="gotoProfile">
<div class="user-avatar-item">
<img class="user-avatar-item-img" :src="author.avatar" alt="avatar">
</div>
@@ -102,6 +102,7 @@ import { renderMarkdown } from '../utils/markdown'
import { API_BASE_URL, toast } from '../main'
import { getToken } from '../utils/auth'
import { hatch } from 'ldrs'
import { useRouter } from 'vue-router'
hatch.register()
export default {
@@ -110,6 +111,7 @@ export default {
setup() {
const route = useRoute()
const postId = route.params.id
const router = useRouter()
const title = ref('')
const author = ref('')
@@ -293,6 +295,10 @@ export default {
}
}
const gotoProfile = () => {
router.push(`/users/${author.value.id}`)
}
onMounted(async () => {
const hash = location.hash
const id = hash.startsWith('#comment-') ? hash.substring('#comment-'.length) : null
@@ -322,7 +328,8 @@ export default {
copyPostLink,
renderMarkdown,
isWaitingFetchingPost,
isWaitingPostingComment
isWaitingPostingComment,
gotoProfile
}
}
}
@@ -451,7 +458,9 @@ export default {
border-bottom: 1px solid #e2e2e2;
}
.user-avatar-container {}
.user-avatar-container {
cursor: pointer;
}
.user-avatar-item {
width: 50px;

View File

@@ -66,7 +66,7 @@
<div class="summary-divider">
<div class="hot-reply">
<div class="summary-title">热门回复</div>
<div v-if="hotReplies.length > 0">
<div class="summary-content" v-if="hotReplies.length > 0">
<BaseTimeline :items="hotReplies">
<template #item="{ item }">
@@ -107,7 +107,7 @@
</div>
<div class="hot-topic">
<div class="summary-title">热门话题</div>
<div v-if="hotPosts.length > 0">
<div class="summary-content" v-if="hotPosts.length > 0">
<BaseTimeline :items="hotPosts">
<template #item="{ item }">
<router-link
@@ -413,4 +413,8 @@ export default {
opacity: 0.5;
}
.summary-content {
margin-top: 10px;
}
</style>