feat(api): 升级 HaveADrink 依赖并实现用户头像上传功能

- 将 HaveADrink 依赖从 1.0.15 升级至 1.0.16 版本
- 新增 UpdateUserAvatar API 接口用于更新用户头像
- 添加 isValidAvatar 工具函数验证头像 URL 有效性
- 在登录流程中集成头像上传逻辑,支持微信头像选择
- 更新多个组件中的头像显示逻辑,过滤无效头像地址
- 优化 tabBar 主题应用逻辑,修复异步错误处理问题
- 修复微信新规范下头像选择的临时路径处理机制
This commit is contained in:
cg
2026-08-16 22:19:10 +08:00
parent 81e7a3afa5
commit 019262289c
15 changed files with 269 additions and 39 deletions
+4 -3
View File
@@ -13,7 +13,7 @@
</button>
<view class="hero-content">
<view class="avatar-ring">
<image v-if="user.avatar" class="hero-avatar" :src="user.avatar" mode="aspectFill"></image>
<image v-if="isValidAvatar(user.avatar)" class="hero-avatar" :src="user.avatar" mode="aspectFill"></image>
<view v-else class="hero-avatar hero-avatar-placeholder">
<text class="hero-avatar-icon">👤</text>
</view>
@@ -174,7 +174,7 @@
<script>
import AchievementBadge from '../../components/AchievementBadge.vue'
import client, { clearAuth } from '../../common/api'
import { checkAchievements, getCatIcon, isIconPath, calcLocalStreak } from '../../common/utils'
import { checkAchievements, getCatIcon, isIconPath, calcLocalStreak, isValidAvatar } from '../../common/utils'
import { ACHIEVEMENTS, DRINK_CATEGORIES } from '../../common/constants'
import themeMixin from '../../common/theme-mixin'
@@ -271,11 +271,12 @@ export default {
}
},
methods: {
isValidAvatar,
isIconPath,
// 构建分享名片的 query 参数(携带公开档案数据)
buildShareQuery() {
const parts = [`nick=${encodeURIComponent(this.user.nickname || '酒友')}`]
if (this.user.avatar) parts.push(`avatar=${encodeURIComponent(this.user.avatar)}`)
if (isValidAvatar(this.user.avatar)) parts.push(`avatar=${encodeURIComponent(this.user.avatar)}`)
parts.push(`days=${this.stats.totalDays || 0}`)
parts.push(`records=${this.stats.totalRecords || 0}`)
parts.push(`cups=${this.stats.totalCups || 0}`)