From 1c2da6dfb1e23fa38c58ada5d7e98f91ae2d738e Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期三, 11 九月 2024 14:19:21 +0800
Subject: [PATCH] 修改导出文件名称

---
 src/views/system/user/profile/userAvatar.vue |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/views/system/user/profile/userAvatar.vue b/src/views/system/user/profile/userAvatar.vue
index 343968b..b99f58d 100644
--- a/src/views/system/user/profile/userAvatar.vue
+++ b/src/views/system/user/profile/userAvatar.vue
@@ -73,38 +73,45 @@
 
 //鍥剧墖瑁佸壀鏁版嵁
 const options = reactive({
-  img: userStore.avatar, // 瑁佸壀鍥剧墖鐨勫湴鍧�
-  autoCrop: true, // 鏄惁榛樿鐢熸垚鎴浘妗�
-  autoCropWidth: 200, // 榛樿鐢熸垚鎴浘妗嗗搴�
-  autoCropHeight: 200, // 榛樿鐢熸垚鎴浘妗嗛珮搴�
-  fixedBox: true, // 鍥哄畾鎴浘妗嗗ぇ灏� 涓嶅厑璁告敼鍙�
-  outputType: "png", // 榛樿鐢熸垚鎴浘涓篜NG鏍煎紡
-  previews: {} //棰勮鏁版嵁
+  img: userStore.avatar,     // 瑁佸壀鍥剧墖鐨勫湴鍧�
+  autoCrop: true,            // 鏄惁榛樿鐢熸垚鎴浘妗�
+  autoCropWidth: 200,        // 榛樿鐢熸垚鎴浘妗嗗搴�
+  autoCropHeight: 200,       // 榛樿鐢熸垚鎴浘妗嗛珮搴�
+  fixedBox: true,            // 鍥哄畾鎴浘妗嗗ぇ灏� 涓嶅厑璁告敼鍙�
+  outputType: "png",         // 榛樿鐢熸垚鎴浘涓篜NG鏍煎紡
+  filename: 'avatar',        // 鏂囦欢鍚嶇О
+  previews: {}               //棰勮鏁版嵁
 });
 
 /** 缂栬緫澶村儚 */
 function editCropper() {
   open.value = true;
 }
+
 /** 鎵撳紑寮瑰嚭灞傜粨鏉熸椂鐨勫洖璋� */
 function modalOpened() {
   visible.value = true;
 }
+
 /** 瑕嗙洊榛樿涓婁紶琛屼负 */
 function requestUpload() {}
+
 /** 鍚戝乏鏃嬭浆 */
 function rotateLeft() {
   proxy.$refs.cropper.rotateLeft();
 }
+
 /** 鍚戝彸鏃嬭浆 */
 function rotateRight() {
   proxy.$refs.cropper.rotateRight();
 }
+
 /** 鍥剧墖缂╂斁 */
 function changeScale(num) {
   num = num || 1;
   proxy.$refs.cropper.changeScale(num);
 }
+
 /** 涓婁紶棰勫鐞� */
 function beforeUpload(file) {
   if (file.type.indexOf("image/") == -1) {
@@ -114,14 +121,16 @@
     reader.readAsDataURL(file);
     reader.onload = () => {
       options.img = reader.result;
+      options.filename = file.name;
     };
   }
 }
+
 /** 涓婁紶鍥剧墖 */
 function uploadImg() {
   proxy.$refs.cropper.getCropBlob(data => {
     let formData = new FormData();
-    formData.append("avatarfile", data);
+    formData.append("avatarfile", data, options.filename);
     uploadAvatar(formData).then(response => {
       open.value = false;
       options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
@@ -131,10 +140,12 @@
     });
   });
 }
+
 /** 瀹炴椂棰勮 */
 function realTime(data) {
   options.previews = data;
 }
+
 /** 鍏抽棴绐楀彛 */
 function closeDialog() {
   options.img = userStore.avatar;

--
Gitblit v1.9.3