fix avatar
This commit is contained in:
9
src/api/file/file.js
Normal file
9
src/api/file/file.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function uploadFile(data) {
|
||||||
|
return request({
|
||||||
|
url: '/common/upload',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -108,12 +108,15 @@ export function updateUserPwd(oldPassword, newPassword) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 用户头像上传
|
// 用户头像上传
|
||||||
export function uploadAvatar(data) {
|
export function uploadAvatar(url) {
|
||||||
|
const data = {
|
||||||
|
url
|
||||||
|
}
|
||||||
return request({
|
return request({
|
||||||
url: "/system/user/profile/avatar",
|
url: '/system/user/profile/uploadAvatar',
|
||||||
method: "post",
|
method: 'put',
|
||||||
data: data,
|
params: data
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询授权角色
|
// 查询授权角色
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import "vue-cropper/dist/index.css";
|
import "vue-cropper/dist/index.css";
|
||||||
import { VueCropper } from "vue-cropper";
|
import { VueCropper } from "vue-cropper";
|
||||||
|
import { uploadFile } from "@/api/file/file";
|
||||||
import { uploadAvatar } from "@/api/system/user";
|
import { uploadAvatar } from "@/api/system/user";
|
||||||
import useUserStore from "@/store/modules/user";
|
import useUserStore from "@/store/modules/user";
|
||||||
|
|
||||||
@ -119,18 +120,23 @@ function beforeUpload(file) {
|
|||||||
}
|
}
|
||||||
/** 上传图片 */
|
/** 上传图片 */
|
||||||
function uploadImg() {
|
function uploadImg() {
|
||||||
|
|
||||||
proxy.$refs.cropper.getCropBlob(data => {
|
proxy.$refs.cropper.getCropBlob(data => {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append("avatarfile", data);
|
formData.append("file", data);
|
||||||
uploadAvatar(formData).then(response => {
|
uploadFile(formData).then(response => {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
|
options.img = import.meta.env.VITE_APP_BASE_API + response.url;
|
||||||
userStore.avatar = options.img;
|
userStore.avatar = options.img;
|
||||||
|
uploadAvatar(response.url);
|
||||||
proxy.$modal.msgSuccess("修改成功");
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 实时预览 */
|
/** 实时预览 */
|
||||||
function realTime(data) {
|
function realTime(data) {
|
||||||
options.previews = data;
|
options.previews = data;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export default defineConfig(({ mode, command }) => {
|
|||||||
// https://cn.vitejs.dev/config/#server-proxy
|
// https://cn.vitejs.dev/config/#server-proxy
|
||||||
"/dev-api": {
|
"/dev-api": {
|
||||||
// target: 'http://localhost:8080',
|
// target: 'http://localhost:8080',
|
||||||
target: "http://192.168.110.10:1616",
|
target: "http://192.168.1.16:1616",
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (p) => p.replace(/^\/dev-api/, ""),
|
rewrite: (p) => p.replace(/^\/dev-api/, ""),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user