From 44ad220cdd7eb3c967a4ccac0b2e5b0c0e22738e Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期日, 29 五月 2022 21:40:32 +0800
Subject: [PATCH] 使用Pinia代替Vuex进行数据存储

---
 src/views/system/user/profile/userAvatar.vue |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/views/system/user/profile/userAvatar.vue b/src/views/system/user/profile/userAvatar.vue
index f8ceef9..8e9982a 100644
--- a/src/views/system/user/profile/userAvatar.vue
+++ b/src/views/system/user/profile/userAvatar.vue
@@ -25,26 +25,26 @@
     <el-row>
       <el-col :lg="2" :md="2">
         <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
-          <el-button size="small">
+          <el-button>
             閫夋嫨
             <el-icon class="el-icon--right"><Upload /></el-icon>
           </el-button>
         </el-upload>
       </el-col>
       <el-col :lg="{span: 1, offset: 2}" :md="2">
-        <el-button icon="Plus" size="small" @click="changeScale(1)"></el-button>
+        <el-button icon="Plus" @click="changeScale(1)"></el-button>
       </el-col>
       <el-col :lg="{span: 1, offset: 1}" :md="2">
-        <el-button icon="Minus" size="small" @click="changeScale(-1)"></el-button>
+        <el-button icon="Minus" @click="changeScale(-1)"></el-button>
       </el-col>
       <el-col :lg="{span: 1, offset: 1}" :md="2">
-        <el-button icon="RefreshLeft" size="small" @click="rotateLeft()"></el-button>
+        <el-button icon="RefreshLeft" @click="rotateLeft()"></el-button>
       </el-col>
       <el-col :lg="{span: 1, offset: 1}" :md="2">
-        <el-button icon="RefreshRight" size="small" @click="rotateRight()"></el-button>
+        <el-button icon="RefreshRight" @click="rotateRight()"></el-button>
       </el-col>
       <el-col :lg="{span: 2, offset: 6}" :md="2">
-        <el-button type="primary" size="small" @click="uploadImg()">鎻� 浜�</el-button>
+        <el-button type="primary" @click="uploadImg()">鎻� 浜�</el-button>
       </el-col>
     </el-row>
   </el-dialog>
@@ -54,8 +54,9 @@
 import "vue-cropper/dist/index.css";
 import { VueCropper } from "vue-cropper";
 import { uploadAvatar } from "@/api/system/user";
+import useUserStore from '@/store/modules/user'
 
-const store = useStore();
+const userStore = useUserStore()
 const { proxy } = getCurrentInstance();
 
 const open = ref(false);
@@ -64,7 +65,7 @@
 
 //鍥剧墖瑁佸壀鏁版嵁
 const options = reactive({
-  img: store.getters.avatar, // 瑁佸壀鍥剧墖鐨勫湴鍧�
+  img: userStore.avatar, // 瑁佸壀鍥剧墖鐨勫湴鍧�
   autoCrop: true, // 鏄惁榛樿鐢熸垚鎴浘妗�
   autoCropWidth: 200, // 榛樿鐢熸垚鎴浘妗嗗搴�
   autoCropHeight: 200, // 榛樿鐢熸垚鎴浘妗嗛珮搴�
@@ -116,7 +117,7 @@
     uploadAvatar(formData).then(response => {
       open.value = false;
       options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
-      store.commit("SET_AVATAR", options.img);
+      userStore.avatar = options.img;
       proxy.$modal.msgSuccess("淇敼鎴愬姛");
       visible.value = false;
     });
@@ -128,7 +129,7 @@
 };
 /** 鍏抽棴绐楀彛 */
 function closeDialog() {
-  options.img = store.getters.avatar;
+  options.img = userStore.avatar;
   options.visible = false;
 };
 </script>

--
Gitblit v1.9.3