更新:增加“我的”相关功能

This commit is contained in:
2025-11-06 13:33:41 +08:00
parent d908b049fa
commit 33f861fa14
24 changed files with 4413 additions and 43 deletions

View File

@@ -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' })
},
/** 从本地存储恢复用户信息 */