feat: 头像更细

This commit is contained in:
2026-06-04 14:20:44 +08:00
parent aa672194ea
commit 437b191b12
2 changed files with 8 additions and 6 deletions

View File

@@ -52,7 +52,7 @@
<img src="@/assets/images/profile-content-bg.jpg" alt="" /> <img src="@/assets/images/profile-content-bg.jpg" alt="" />
<div class="content"> <div class="content">
<div class="profile"> <div class="profile">
<img class="profile-avatar" :src="userInfoStore.state.userInfo.avatarUrl" alt="" /> <img class="profile-avatar" :src="userInfo.avatarUrl" alt="" />
</div> </div>
<div class="name"> <div class="name">
{{ $t('MainHeader.HiName', { name: userInfo.username }) }} {{ $t('MainHeader.HiName', { name: userInfo.username }) }}
@@ -288,7 +288,7 @@
width: 5rem; width: 5rem;
height: 5rem; height: 5rem;
border-radius: 50%; border-radius: 50%;
.profile-avatar{ .profile-avatar {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 50%; border-radius: 50%;

View File

@@ -16,7 +16,7 @@
<input <input
type="file" type="file"
ref="fileInput" ref="fileInput"
style="display:none" style="display: none"
accept="image/*" accept="image/*"
@change="handleFileChange" @change="handleFileChange"
/> />
@@ -95,6 +95,7 @@
import AvatarCropDialog from './AvatarCropDialog.vue' import AvatarCropDialog from './AvatarCropDialog.vue'
import type { RoleOption, RoleValue, SettingsData } from '../types' import type { RoleOption, RoleValue, SettingsData } from '../types'
import { uploadFile, updateUserAvatar } from '@/api/user' import { uploadFile, updateUserAvatar } from '@/api/user'
import { useUserInfoStore } from '@/stores'
const props = defineProps<{ const props = defineProps<{
displayData: SettingsData displayData: SettingsData
@@ -178,6 +179,7 @@
} }
await updateUserAvatar({ avatarUrl: url }) await updateUserAvatar({ avatarUrl: url })
useUserInfoStore().setAvatarUrl(url)
ElMessage.success(t('Settings.messages.avatarUpdated')) ElMessage.success(t('Settings.messages.avatarUpdated'))
emit('avatar-updated', url) emit('avatar-updated', url)
} catch (err) { } catch (err) {
@@ -205,9 +207,9 @@
isAvatarCropDialogVisible.value = true isAvatarCropDialogVisible.value = true
} }
const handleAvatarCropConfirm = async (file: File) => { const handleAvatarCropConfirm = (file: File) => {
closeAvatarCropDialog() closeAvatarCropDialog()
await uploadAvatarFile(file) uploadAvatarFile(file)
} }
onBeforeUnmount(() => { onBeforeUnmount(() => {