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({
|
||||
url: "/system/user/profile/avatar",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
url: '/system/user/profile/uploadAvatar',
|
||||
method: 'put',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
// 查询授权角色
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,7 @@
|
||||
<script setup>
|
||||
import "vue-cropper/dist/index.css";
|
||||
import { VueCropper } from "vue-cropper";
|
||||
import { uploadFile } from "@/api/file/file";
|
||||
import { uploadAvatar } from "@/api/system/user";
|
||||
import useUserStore from "@/store/modules/user";
|
||||
|
||||
@ -119,18 +120,23 @@ function beforeUpload(file) {
|
||||
}
|
||||
/** 上传图片 */
|
||||
function uploadImg() {
|
||||
|
||||
proxy.$refs.cropper.getCropBlob(data => {
|
||||
let formData = new FormData();
|
||||
formData.append("avatarfile", data);
|
||||
uploadAvatar(formData).then(response => {
|
||||
formData.append("file", data);
|
||||
uploadFile(formData).then(response => {
|
||||
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;
|
||||
uploadAvatar(response.url);
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
visible.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 实时预览 */
|
||||
function realTime(data) {
|
||||
options.previews = data;
|
||||
|
@ -33,7 +33,7 @@ export default defineConfig(({ mode, command }) => {
|
||||
// https://cn.vitejs.dev/config/#server-proxy
|
||||
"/dev-api": {
|
||||
// target: 'http://localhost:8080',
|
||||
target: "http://192.168.110.10:1616",
|
||||
target: "http://192.168.1.16:1616",
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/dev-api/, ""),
|
||||
},
|
||||
|
Reference in New Issue
Block a user