fix:上传存图片路径之前取的缓存接口getUserProfile(),并且去掉前缀dev-api保证图片回显; #137

Merged
yangws merged 1 commits from yangws into main 2024-08-15 14:11:34 +08:00
4 changed files with 11 additions and 5 deletions

View File

@ -50,3 +50,9 @@ export function updateUserInfo(data) {
data: data data: data
}) })
} }
export function getUserInfo(userId) {
return request({
url: '/system/user/' + userId,
method: 'get'
})
}

View File

@ -37,7 +37,7 @@ const useUserStore = defineStore('user', {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo() getInfo()
.then((res) => { .then((res) => {
res.user.avatar = import.meta.env.VITE_APP_BASE_API + res.user.avatar // res.user.avatar = import.meta.env.VITE_APP_BASE_API + res.user.avatar
const user = res.user const user = res.user
this.user = user this.user = user
const avatar = user.avatar == '' || user.avatar == null ? defAva : user.avatar const avatar = user.avatar == '' || user.avatar == null ? defAva : user.avatar

View File

@ -97,10 +97,10 @@ const state = reactive({
postGroup: {} postGroup: {}
}) })
function getUser() { async function getUser() {
getUserProfile().then((response) => { getUserProfile().then((response) => {
response.data.avatar = import.meta.env.VITE_APP_BASE_API + response.data.avatar // response.data.avatar = import.meta.env.VITE_APP_BASE_API + response.data.avatar
state.user = response.data Object.assign(state.user,response.data)
state.roleGroup = response.roleGroup state.roleGroup = response.roleGroup
state.postGroup = response.postGroup state.postGroup = response.postGroup
}) })

View File

@ -68,7 +68,7 @@ function uploadImg(data) {
/** 关闭窗口 */ /** 关闭窗口 */
function closeDialog() { function closeDialog() {
// options.img = userStore.avatar options.img = userStore.user.avatar
options.visible = false options.visible = false
} }
const cancle = () => { const cancle = () => {