|
@@ -2,7 +2,7 @@
|
|
|
* @Author: wjc
|
|
|
* @Date: 2024-06-05 17:13:30
|
|
|
* @LastEditors: wjc
|
|
|
- * @LastEditTime: 2024-06-17 15:11:47
|
|
|
+ * @LastEditTime: 2024-06-25 15:15:56
|
|
|
* @Description:
|
|
|
*/
|
|
|
import { defineStore } from 'pinia'
|
|
@@ -17,16 +17,14 @@ export const useUserStore = defineStore('user', {
|
|
|
isInstall: false,
|
|
|
token: '',
|
|
|
userInfo: new Employees({}),
|
|
|
+ storageLoginInfo: undefined,
|
|
|
+ storageUserId: '',
|
|
|
}
|
|
|
},
|
|
|
- getters: {
|
|
|
- getIsInstall(state) {
|
|
|
- return state.isInstall || uni.getStorageSync('isInstall')
|
|
|
- },
|
|
|
- getIsPrivacyShowed(state) {
|
|
|
- return state.isPrivacyShowed || uni.getStorageSync('isPrivacyShowed')
|
|
|
- },
|
|
|
+ persist: {
|
|
|
+ paths: ['isPrivacyShowed', 'isInstall', 'storageUserId', 'storageLoginInfo'],
|
|
|
},
|
|
|
+ getters: {},
|
|
|
actions: {
|
|
|
loginAction(data: ILogin): Promise<LoginRes> {
|
|
|
return new Promise((resolve, reject) => {
|
|
@@ -35,10 +33,8 @@ export const useUserStore = defineStore('user', {
|
|
|
if (res && res.data) {
|
|
|
this.isPrivacyShowed = true
|
|
|
this.isInstall = true
|
|
|
- uni.setStorageSync('isPrivacyShowed', this.isPrivacyShowed)
|
|
|
- uni.setStorageSync('isInstall', this.isInstall)
|
|
|
- uni.setStorageSync('storage-loginInfo', data)
|
|
|
- uni.setStorageSync('storage-user-id', res.data.id)
|
|
|
+ this.storageLoginInfo = data
|
|
|
+ this.storageUserId = res.data.id
|
|
|
resolve(res.data)
|
|
|
}
|
|
|
})
|
|
@@ -52,7 +48,7 @@ export const useUserStore = defineStore('user', {
|
|
|
logout()
|
|
|
.then((res) => {
|
|
|
if (res && res.data) {
|
|
|
- uni.clearStorageSync()
|
|
|
+ this.$reset()
|
|
|
resolve(res.data)
|
|
|
}
|
|
|
})
|
|
@@ -63,9 +59,8 @@ export const useUserStore = defineStore('user', {
|
|
|
},
|
|
|
getUserInfoAction(): Promise<Employees> {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- const id = uni.getStorageSync('storage-user-id')
|
|
|
- if (id) {
|
|
|
- getUserInfo(id)
|
|
|
+ if (this.storageUserId) {
|
|
|
+ getUserInfo(this.storageUserId)
|
|
|
.then((res) => {
|
|
|
if (res && res.data) {
|
|
|
this.userInfo = res.data
|