使用Pinia代替Vuex进行数据存储

This commit is contained in:
RuoYi
2025-04-23 20:53:28 +08:00
parent fd97380edb
commit 3eca7b1219
15 changed files with 169 additions and 155 deletions

View File

@@ -38,7 +38,7 @@
<script>
import config from '@/config'
import store from "@/store"
import { useUserStore } from '@/store'
import { uploadAvatar } from "@/api/system/user"
const baseUrl = config.baseUrl
@@ -68,7 +68,7 @@
*/
data() {
return {
imageSrc: store.getters.avatar,
imageSrc: useUserStore().avatar,
isShowImg: false,
// 初始化的宽高
cropperInitW: SCREEN_WIDTH,
@@ -257,7 +257,7 @@
uni.hideLoading()
let data = {name: 'avatarfile', filePath: res.tempFilePath}
uploadAvatar(data).then(response => {
store.commit('SET_AVATAR', baseUrl + response.imgUrl)
useUserStore().SET_AVATAR(baseUrl + response.imgUrl)
uni.showToast({ title: "修改成功", icon: 'success' })
uni.navigateBack()
})