From 87b2e9b19e855dd61adee7bcb996a5ad46a574f6 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 7 Jul 2025 01:46:11 +0800 Subject: [PATCH] feat: fix avatar problem --- open-isle-cli/src/components/CommentItem.vue | 8 ++++---- open-isle-cli/src/components/HeaderComponent.vue | 6 ++---- open-isle-cli/src/views/PostPageView.vue | 9 ++++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/open-isle-cli/src/components/CommentItem.vue b/open-isle-cli/src/components/CommentItem.vue index cf3656aaa..40c67f775 100644 --- a/open-isle-cli/src/components/CommentItem.vue +++ b/open-isle-cli/src/components/CommentItem.vue @@ -104,15 +104,15 @@ const CommentItem = { const replyList = props.comment.reply || (props.comment.reply = []) replyList.push({ id: data.id, - userName: data.author, + userName: data.author.username, time: new Date(data.createdAt).toLocaleDateString('zh-CN', { month: 'numeric', day: 'numeric' }), - avatar: 'https://picsum.photos/200/200', + avatar: data.avatar.username, text: data.content, reply: (data.replies || []).map(r => ({ id: r.id, - userName: r.author, + userName: r.author.username, time: new Date(r.createdAt).toLocaleDateString('zh-CN', { month: 'numeric', day: 'numeric' }), - avatar: 'https://picsum.photos/200/200', + avatar: r.avatar, text: r.content, reply: [] })) diff --git a/open-isle-cli/src/components/HeaderComponent.vue b/open-isle-cli/src/components/HeaderComponent.vue index 1ff80eeba..574ee4346 100644 --- a/open-isle-cli/src/components/HeaderComponent.vue +++ b/open-isle-cli/src/components/HeaderComponent.vue @@ -46,7 +46,7 @@ export default { data() { return { dropdownVisible: false, - avatar: 'https://picsum.photos/40' + avatar: '' } }, computed: { @@ -61,9 +61,7 @@ export default { if (user && user.avatar) { this.avatar = user.avatar } - } else { - this.avatar = 'https://picsum.photos/40' - } + } } await updateAvatar() diff --git a/open-isle-cli/src/views/PostPageView.vue b/open-isle-cli/src/views/PostPageView.vue index 845806095..6966ea5a5 100644 --- a/open-isle-cli/src/views/PostPageView.vue +++ b/open-isle-cli/src/views/PostPageView.vue @@ -24,7 +24,7 @@
- avatar + avatar
@@ -107,6 +107,7 @@ export default { const postId = route.params.id const title = ref('') + const author = ref('') const postContent = ref('') const category = ref('') const tags = ref([]) @@ -120,9 +121,9 @@ export default { const mapComment = c => ({ id: c.id, - userName: c.author, + userName: c.author.username, time: new Date(c.createdAt).toLocaleDateString('zh-CN', { month: 'numeric', day: 'numeric' }), - avatar: 'https://picsum.photos/200/200', + avatar: c.author.avatar, text: c.content, reply: (c.replies || []).map(mapComment) }) @@ -135,6 +136,7 @@ export default { if (!res.ok) return const data = await res.json() postContent.value = data.content + author.value = data.author title.value = data.title category.value = data.category tags.value = data.tags || [] @@ -218,6 +220,7 @@ export default { return { postContent, + author, title, category, tags,