Skip to content

Commit

Permalink
fix: 缺失头像导致的登陆异常
Browse files Browse the repository at this point in the history
  • Loading branch information
fullstackyang authored and fullstackyang committed Apr 7, 2023
1 parent 1cc04ad commit a958fae
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { permissionListToPermissions } from '@/utils/permissions'
import defaultAvatar from '@/assets/logo.png'
import { logout as ssoLogout } from '@/utils/sso'
import { baseURL } from '@/utils/request'
import avatar from 'element-ui/packages/avatar'

const state = {
token: getToken(),
Expand Down Expand Up @@ -86,8 +87,9 @@ const actions = {

commit('SET_NAME', name)
commit('SET_INFO', info)
const isExternal = /^(https?:|mailto:|tel:|\/\/)/.test(info.avatarUrl)
commit('SET_AVATAR', isExternal ? info.avatarUrl : info.avatarUrl ? baseURL + info.avatarUrl : null)
const avatarUrl = info && info.avatarUrl ? info.avatarUrl : null
const isExternal = /^(https?:|mailto:|tel:|\/\/)/.test(avatarUrl)
commit('SET_AVATAR', isExternal ? avatarUrl : avatarUrl ? baseURL + avatarUrl : null)
resolve(data)
}).catch(error => {
reject(error)
Expand Down

0 comments on commit a958fae

Please sign in to comment.