fix: login state refresh, hero layout, default avatar consistency

This commit is contained in:
yuzhiran
2026-06-15 11:04:00 +08:00
parent 07c6557454
commit 5a49d15696
3 changed files with 57 additions and 25 deletions
+7 -4
View File
@@ -3,7 +3,7 @@
<!-- 个人中心 -->
<view class="header" v-if="isLoggedIn">
<view class="profile-section">
<image class="avatar" :src="userInfo.avatar || '/static/avatar-default.svg'" mode="aspectFill" />
<image class="avatar" :src="userInfo.avatar || '/static/avatar-default.png'" mode="aspectFill" />
<view class="profile-info">
<text class="nickname">{{ userInfo.nickname || '未设置昵称' }}</text>
<view class="plan-badge">{{ userInfo.plan || '免费版' }}</view>
@@ -33,7 +33,6 @@
<view class="guest-avatar"><text class="guest-icon">👤</text></view>
<view class="guest-info">
<text class="guest-name">未登录 / 点击登录</text>
<text class="guest-hint">登录后体验全部功能</text>
</view>
<text class="header-arrow"></text>
</view>
@@ -84,6 +83,7 @@
<script setup>
import { ref, computed, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { api } from '../../config'
const userInfo = ref({})
@@ -93,13 +93,16 @@ const token = ref('')
const isLoggedIn = computed(() => !!token.value)
onMounted(() => {
const refreshState = () => {
token.value = uni.getStorageSync('token') || ''
if (!token.value) return
try { const s = uni.getStorageSync('userInfo'); if (s) userInfo.value = JSON.parse(s) } catch(e) {}
loadStats()
checkAdmin()
})
}
onMounted(refreshState)
onShow(refreshState)
const loadStats = async () => {
try {