初始化uni-app
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import { createPinia } from 'pinia'
|
||||
|
||||
const pinia = createPinia()
|
||||
|
||||
export default pinia
|
||||
@@ -0,0 +1,27 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useUserStore = defineStore('user', {
|
||||
state: () => ({
|
||||
token: '',
|
||||
userInfo: null
|
||||
}),
|
||||
|
||||
getters: {
|
||||
isLoggedIn: (state) => !!state.token
|
||||
},
|
||||
|
||||
actions: {
|
||||
setToken(token) {
|
||||
this.token = token
|
||||
},
|
||||
|
||||
setUserInfo(userInfo) {
|
||||
this.userInfo = userInfo
|
||||
},
|
||||
|
||||
logout() {
|
||||
this.token = ''
|
||||
this.userInfo = null
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user