Skip to content

Commit a958fae

Browse files
fullstackyangfullstackyang
authored andcommitted
fix: 缺失头像导致的登陆异常
1 parent 1cc04ad commit a958fae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/store/modules/user.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { permissionListToPermissions } from '@/utils/permissions'
55
import defaultAvatar from '@/assets/logo.png'
66
import { logout as ssoLogout } from '@/utils/sso'
77
import { baseURL } from '@/utils/request'
8+
import avatar from 'element-ui/packages/avatar'
89

910
const state = {
1011
token: getToken(),
@@ -86,8 +87,9 @@ const actions = {
8687

8788
commit('SET_NAME', name)
8889
commit('SET_INFO', info)
89-
const isExternal = /^(https?:|mailto:|tel:|\/\/)/.test(info.avatarUrl)
90-
commit('SET_AVATAR', isExternal ? info.avatarUrl : info.avatarUrl ? baseURL + info.avatarUrl : null)
90+
const avatarUrl = info && info.avatarUrl ? info.avatarUrl : null
91+
const isExternal = /^(https?:|mailto:|tel:|\/\/)/.test(avatarUrl)
92+
commit('SET_AVATAR', isExternal ? avatarUrl : avatarUrl ? baseURL + avatarUrl : null)
9193
resolve(data)
9294
}).catch(error => {
9395
reject(error)

0 commit comments

Comments
 (0)