28 lines
681 B
TypeScript
28 lines
681 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: "spUserStore",
|
|
storage: window.localStorage,
|
|
paths: ["tokenInfo"],
|
|
}
|
|
})
|