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 |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/views/system/user/profile/userAvatar.vue b/src/views/system/user/profile/userAvatar.vue
index 383d9f2..8e9982a 100644
--- a/src/views/system/user/profile/userAvatar.vue
+++ b/src/views/system/user/profile/userAvatar.vue
@@ -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