fix: auto-copy avatars on build, show masked user ID on profile page

This commit is contained in:
yuzhiran
2026-06-18 17:58:54 +08:00
parent b9651a9ff3
commit e049be280e
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -3,9 +3,9 @@
"version": "1.0.0", "version": "1.0.0",
"scripts": { "scripts": {
"dev:mp-weixin": "uni -p mp-weixin", "dev:mp-weixin": "uni -p mp-weixin",
"build:mp-weixin": "uni build -p mp-weixin && cp -n static/avatar-*.png dist/build/mp-weixin/static/ 2>/dev/null; true", "build:mp-weixin": "uni build -p mp-weixin && cp -f static/avatar-*.png dist/build/mp-weixin/static/ 2>/dev/null; true",
"dev:h5": "uni", "dev:h5": "uni",
"build:h5": "uni build && cp -n static/avatar-*.png dist/build/h5/static/ 2>/dev/null; true", "build:h5": "uni build && cp -f static/avatar-*.png dist/build/h5/static/ 2>/dev/null; true",
"test": "vitest run", "test": "vitest run",
"test:watch": "vitest" "test:watch": "vitest"
}, },
+6
View File
@@ -6,6 +6,7 @@
<image class="avatar" :src="userInfo.avatar || '/static/avatar-default.png'" mode="aspectFill" /> <image class="avatar" :src="userInfo.avatar || '/static/avatar-default.png'" mode="aspectFill" />
<view class="profile-info"> <view class="profile-info">
<text class="nickname">{{ userInfo.nickname || '未设置昵称' }}</text> <text class="nickname">{{ userInfo.nickname || '未设置昵称' }}</text>
<text class="user-id">ID: {{ maskedId }}</text>
<view class="plan-badge">{{ userInfo.plan || '免费版' }}</view> <view class="plan-badge">{{ userInfo.plan || '免费版' }}</view>
</view> </view>
<text class="header-arrow"></text> <text class="header-arrow"></text>
@@ -103,6 +104,10 @@ const stats = ref({ interviewCount: 0, avgScore: '--', completedCount: 0 })
const token = ref('') const token = ref('')
const isLoggedIn = computed(() => !!token.value) const isLoggedIn = computed(() => !!token.value)
const maskedId = computed(() => {
const id = userInfo.value.id || ''
return id.length > 6 ? `****${id.slice(-6)}` : id || '--'
})
const refreshState = () => { const refreshState = () => {
token.value = uni.getStorageSync('token') || '' token.value = uni.getStorageSync('token') || ''
@@ -177,6 +182,7 @@ const doLogout = () => {
.profile-info { flex: 1; display: flex; flex-direction: column; } .profile-info { flex: 1; display: flex; flex-direction: column; }
.nickname { font-size: 34rpx; font-weight: 700; color: #FFFFFF; } .nickname { font-size: 34rpx; font-weight: 700; color: #FFFFFF; }
.plan-badge { font-size: 20rpx; color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.2); padding: 4rpx 14rpx; border-radius: 8rpx; align-self: flex-start; margin-top: 8rpx; } .plan-badge { font-size: 20rpx; color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.2); padding: 4rpx 14rpx; border-radius: 8rpx; align-self: flex-start; margin-top: 8rpx; }
.user-id { font-size: 20rpx; color: rgba(255,255,255,0.5); margin-top: 4rpx; }
.header-arrow { font-size: 36rpx; color: rgba(255,255,255,0.5); } .header-arrow { font-size: 36rpx; color: rgba(255,255,255,0.5); }
.stats-bar { display: flex; align-items: center; background: rgba(255,255,255,0.15); border-radius: var(--radius-lg); padding: 24rpx 0; } .stats-bar { display: flex; align-items: center; background: rgba(255,255,255,0.15); border-radius: var(--radius-lg); padding: 24rpx 0; }
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; } .stat { flex: 1; display: flex; flex-direction: column; align-items: center; }