fix: 用户头像
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m32s

This commit is contained in:
sexygoat
2026-04-14 14:24:00 +08:00
parent e9634cd4bf
commit eb81a5cb21
3 changed files with 59 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
<view class="card user-info-card interactive">
<view class="flex-row-g20">
<view class="user-avatar">
<image src="https://img1.baidu.com/it/u=2462918877,1866131262&fm=253&fmt=auto&app=138&f=JPEG?w=506&h=500" mode="aspectFill" alt="用户头像" />
<image :src="avatarUrl" mode="aspectFill" alt="用户头像" />
</view>
<view class="user-details flex-col-g8">
<view class="flex-row-g20">
@@ -19,12 +19,25 @@
</template>
<script setup>
import { computed } from 'vue';
import { useUserStore } from '@/store/index.js';
const userStore = useUserStore();
defineProps({
currentCardNo: { type: String, default: '' },
deviceInfo: { type: Object, default: () => ({}) },
onlineStatus: { type: String, default: '离线' },
isDevice: { type: Boolean, default: true }
});
// 默认头像
const defaultAvatar = 'https://img1.baidu.com/it/u=2462918877,1866131262&fm=253&fmt=auto&app=138&f=JPEG?w=506&h=500';
// 用户头像,优先使用 store 中的头像,否则使用默认头像
const avatarUrl = computed(() => {
return userStore.state.userInfo.avatar || defaultAvatar;
});
</script>
<style scoped lang="scss">