更新:增加“我的”相关功能
This commit is contained in:
@@ -4,20 +4,22 @@ import { setAuthToken, clearAuthToken } from '@/utils/auth'
|
||||
import type { IUserInfo } from '@/types/user'
|
||||
|
||||
export const useUserStore = defineStore('user', {
|
||||
state: (): IUserInfo => ({
|
||||
state: (): IUserInfo => (uni.getStorageSync('userInfo') || {
|
||||
id: 0,
|
||||
name: '',
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
token: uni.getStorageSync('token') || '',
|
||||
token: '',
|
||||
age: '',
|
||||
tel: '',
|
||||
sex: '',
|
||||
}),
|
||||
|
||||
getters: {
|
||||
isLoggedIn: (state: any) => Boolean(state.token),
|
||||
userInfo: (state: any) => {
|
||||
const { id, name, avatar, email, phone } = state
|
||||
return { id, name, avatar, email, phone }
|
||||
return state
|
||||
},
|
||||
},
|
||||
|
||||
@@ -54,7 +56,6 @@ export const useUserStore = defineStore('user', {
|
||||
|
||||
clearAuthToken()
|
||||
uni.removeStorageSync('userInfo')
|
||||
uni.reLaunch({ url: '/pages/user/login' })
|
||||
},
|
||||
|
||||
/** 从本地存储恢复用户信息 */
|
||||
|
||||
Reference in New Issue
Block a user