33 lines
697 B
TypeScript
Raw Normal View History

2024-04-11 13:07:43 +08:00
import { defineStore } from "pinia";
/**
*
* @methods setAccount
* @methods setToken token
* @methods logOut 退
*/
2024-04-12 00:31:21 +08:00
export const useUserInfoStore = defineStore("userInfo", {
2024-04-11 13:07:43 +08:00
state: (): any => ({
account: {
username: "",
roles: []
}, // 账号信息
token: "" // token
}),
actions: {
async setAccount(data: Array<string>) {
this.account = data;
},
async setToken(data: string) {
this.token = data;
},
async logOut() {
this.account = {};
this.token = "";
}
},
persist: {
2024-04-27 19:18:49 +08:00
enabled: true, // 开启数据缓存-默认缓存全部数据
key: "userInfo"
2024-04-11 13:07:43 +08:00
}
});