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

Merged
yangws merged 1 commits from yangws into main 2024-08-15 15:11:45 +08:00
3 changed files with 9 additions and 5 deletions

View File

@ -29,7 +29,7 @@
@command="handleCommand"
>
<div class="avatar-wrapper">
<img :src="userStore.user.avatar" class="user-avatar" style="float: left" />
<img :src="dev_api + userStore.user.avatar" class="user-avatar" style="float: left" />
<div style="margin-top: 18px; font-size: 0.8em">{{ userStore.user.nickName }}</div>
</div>
<template #dropdown>
@ -62,6 +62,7 @@ const { ipcRenderer } = window.electron || {}
const userStore = useUserStore()
const router = useRouter()
const currentRoute = ref('')
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
const handleOutLink = (path, type) => {
if (!path) return

View File

@ -11,7 +11,7 @@
<!-- 裁剪+效果 -->
<div class="box">
<div class="box_1">
<img :src="filePath" ref="image" />
<img :src="dev_api + filePath" ref="image" />
</div>
<!--裁剪完的图片-->
@ -60,6 +60,7 @@ export default {
},
},
setup(props, context) {
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
//
const uploadImg = (e) => {
@ -163,7 +164,7 @@ export default {
//
onMounted(() => {
if (props.filePath) {
dataFile.image.src = props.filePath;
dataFile.image.src = dev_api.value + props.filePath;
copper();
}
});
@ -175,6 +176,7 @@ export default {
uploadImg,
upLoading,
cancle,
dev_api
};
},
};

View File

@ -1,6 +1,6 @@
<template>
<div class="user-info-head" @click="editCropper()">
<img :src="options.img" title="点击上传头像" class="img-circle img-lg" />
<img :src="dev_api + options.img" title="点击上传头像" class="img-circle img-lg" />
<el-dialog
v-model="open"
append-to-body
@ -28,6 +28,7 @@ const userStore = useUserStore()
const open = ref(false)
const visible = ref(false)
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
//
const options = reactive({
@ -56,7 +57,7 @@ function uploadImg(data) {
formData.append('avatarfile', data)
uploadAvatar(formData).then((response) => {
open.value = false
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl
options.img = response.imgUrl
userStore.user.avatar = options.img
ElMessage({
message: '上传成功',