feat: add BaseUserAvatar and unify avatar usage

This commit is contained in:
Tim
2025-09-24 00:26:51 +08:00
parent 26d1db79f4
commit efbb83924b
15 changed files with 263 additions and 91 deletions
@@ -24,10 +24,13 @@
</template>
<template #option="{ option }">
<div class="search-option-item">
<BaseImage
:src="option.avatar || '/default-avatar.svg'"
<BaseUserAvatar
class="avatar"
@error="handleAvatarError"
:user-id="option.id"
:avatar="option.avatar"
:username="option.username"
:width="32"
:link="false"
/>
<div class="result-body">
<div class="result-main" v-html="highlight(option.username)"></div>
@@ -87,10 +90,6 @@ const highlight = (text) => {
return text.replace(reg, (m) => `<span class="highlight">${m}</span>`)
}
const handleAvatarError = (e) => {
e.target.src = '/default-avatar.svg'
}
watch(selected, async (val) => {
if (!val) return
const user = results.value.find((u) => u.id === val)
@@ -178,8 +177,6 @@ defineExpose({
.avatar {
width: 32px;
height: 32px;
border-radius: 50%;
object-fit: cover;
}
.result-body {