用户信息持久化

This commit is contained in:
2024-03-15 11:20:11 +08:00
parent 7a3dd0fae8
commit 43b5ea640e
2 changed files with 17 additions and 17 deletions

View File

@@ -6,7 +6,7 @@
1.长按识别下方二维码添加xxxx 1.长按识别下方二维码添加xxxx
</text> </text>
<view class='divider' style='margin-top: 28rpx' /> <view class='divider' style='margin-top: 28rpx' />
<image :src=' assetsUrl("test_qrcode.png")' /> <image :src=' assetsUrl("test_qrcode.png")' show-menu-by-longpress />
<text class='step-title'> <text class='step-title'>
2.识别xxxx发您的二维码即可入群 2.识别xxxx发您的二维码即可入群
</text> </text>

View File

@@ -1,10 +1,6 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import type { UserState, providerType } from './types'; import type { providerType, UserState } from './types';
import { import { getUserProfile, login as userLogin, login, logout as userLogout } from '@/api/user/index';
getUserProfile,
login as userLogin,
logout as userLogout, login
} from '@/api/user/index';
import { clearToken, setCompanyId, setToken } from '@/utils/auth'; import { clearToken, setCompanyId, setToken } from '@/utils/auth';
import type { LoginParams } from '@/api/user/types'; import type { LoginParams } from '@/api/user/types';
@@ -21,16 +17,20 @@ const useUserStore = defineStore('user', {
birthday: '' birthday: ''
}), }),
persist: true, persist: {
// 修改存储中使用的键名称,默认为当前 Store的 id
// persist: { key: 'userState',
// // 修改存储中使用的键名称,默认为当前 Store的 id storage: {
// key: 'userState', setItem(key, value) {
// // 修改为 sessionStorage默认为 localStorage uni.setStorageSync(key, value); // [!code warning]
// // storage: window.localStorage, },
// // 部分持久化状态的点符号路径数组,[]意味着没有状态被持久化(默认为undefined持久化整个状态) getItem(key) {
// paths: undefined return uni.getStorageSync(key); // [!code warning]
// }, }
},
// 部分持久化状态的点符号路径数组,[]意味着没有状态被持久化(默认为undefined持久化整个状态)
paths: undefined
},
getters: { getters: {
userInfo(state: UserState): UserState { userInfo(state: UserState): UserState {