This commit is contained in:
张成
2026-04-13 13:25:54 +08:00
parent daa6a46af6
commit 45f6f330c6

View File

@@ -3,7 +3,7 @@
<label class="loginName-box">{{userName}}</label>
<Dropdown>
<Avatar :src="typeof userAvator === 'string' ? userAvator : userIcon" />
<Avatar :src="avatarSrc" />
<Icon :size="18" type="md-arrow-dropdown"></Icon>
<DropdownMenu slot="list">
@@ -21,7 +21,7 @@
<script>
import './user.less'
import { mapMutations, mapActions } from 'vuex'
import { mapActions } from 'vuex'
const userIcon = require("@/assets/images/administrato.png").default
@@ -39,6 +39,23 @@ export default {
userIcon: userIcon
}
},
computed: {
/** 接口无头像或空串时用本地默认图,避免 Avatar 空 src 显示灰色块 */
avatarSrc() {
const v = this.userAvator
if (v != null && typeof v === 'string' && v.trim() !== '') {
const s = v.trim()
if (/^https?:\/\//i.test(s)) {
return s
}
if (this.$http && typeof this.$http.ImgSrc === 'function') {
return this.$http.ImgSrc(s)
}
return s
}
return this.userIcon
},
},
methods: {
...mapActions('user', ['handleLogOut']),
logout() {