ebike-plus-ui/src/store/user-info.ts

33 lines
678 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 退
*/
export const useUserInfoStore = defineStore("routeList", {
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: {
enabled: true // 开启数据缓存-默认缓存全部数据
}
});