policeSecurity/securityManagement/src/stores/modules/userStore.ts

28 lines
699 B
TypeScript

import {defineStore} from "pinia";
import {TokenInfo, UserStore} from "@/types/stores/userStore.ts";
export const useUserStore = defineStore({
id: 'useUserStore',
state: (): UserStore => {
return {
tokenInfo: undefined,
}
},
actions: {
saveTokenInfo(tokenInfo: TokenInfo) {
this.tokenInfo = tokenInfo
},
async resetUserInfo() {
this.tokenInfo = undefined;
},
},
getters: {
getTokenInfo: (state): TokenInfo => state.tokenInfo as TokenInfo,
},
persist: {
key: "useUserStore", //spUserStore
storage: window.localStorage,
paths: ["tokenInfo"],
}
})