| 12345678910111213141516171819202122 |
- import { STORAGE } from '@/core/constants/storage-keys'
- export function clearSession({ commit, rootState }) {
- const user = rootState.user
- Object.keys(user).forEach((k) => {
- if (typeof user[k] === 'boolean') user[k] = false
- else if (typeof user[k] === 'number') user[k] = 0
- else user[k] = ''
- })
- user.isLogin = false
- const stats = rootState.stats
- ;['order', 'dynamic', 'notice'].forEach((block) => {
- Object.keys(stats[block] || {}).forEach((k) => {
- stats[block][k] = 0
- })
- })
- uni.removeStorageSync(STORAGE.user)
- uni.removeStorageSync(STORAGE.stats)
- commit('user/reset', null, { root: true })
- }
|