mirror of
https://github.com/yangzongzhuan/RuoYi-App.git
synced 2025-09-27 14:42:41 +00:00
用户头像http(s)链接支持
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import storage from '@/utils/storage'
|
import storage from '@/utils/storage'
|
||||||
import constant from '@/utils/constant'
|
import constant from '@/utils/constant'
|
||||||
|
import { isHttp, isEmpty } from "@/utils/validate"
|
||||||
import { login, logout, getInfo } from '@/api/login'
|
import { login, logout, getInfo } from '@/api/login'
|
||||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||||
|
import defAva from '@/static/images/profile.jpg'
|
||||||
|
|
||||||
const baseUrl = config.baseUrl
|
const baseUrl = config.baseUrl
|
||||||
|
|
||||||
@@ -60,9 +62,12 @@ const user = {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getInfo().then(res => {
|
getInfo().then(res => {
|
||||||
const user = res.user
|
const user = res.user
|
||||||
const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar
|
let avatar = user.avatar || ""
|
||||||
const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName
|
if (!isHttp(avatar)) {
|
||||||
if (res.roles && res.roles.length > 0) {
|
avatar = (isEmpty(avatar)) ? defAva : baseUrl + avatar
|
||||||
|
}
|
||||||
|
const username = (isEmpty(user) || isEmpty(user.userName)) ? "" : user.userName
|
||||||
|
if (res.roles && res.roles.length > 0) {
|
||||||
commit('SET_ROLES', res.roles)
|
commit('SET_ROLES', res.roles)
|
||||||
commit('SET_PERMISSIONS', res.permissions)
|
commit('SET_PERMISSIONS', res.permissions)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user