12345678910111213141516171819202122232425262728293031323334353637 |
- import { AuthModule } from "../..";
- import { User } from "../../typings";
- import { Dict_Auth_Storage } from "../dicts/storage";
- const initialState = {
- alipay: "",
- avatar: "",
- city: "",
- company: "",
- companyKey: "",
- desc: "",
- email: "",
- name: "",
- phone: "",
- wechat: "",
- userType: 2,
- _id: "",
- };
- export const userStore = AuthModule.store({
- state: () => ({
- token: Dict_Auth_Storage.get("token"),
- userInfo: initialState,
- }),
- actions: {
- setToken(token: string) {
- Dict_Auth_Storage.set("token", (this.store.token = token));
- },
- setUserInfo(userInfo: User) {
- Dict_Auth_Storage.set("userInfo", (this.store.userInfo = userInfo));
- },
- clearUserInfo() {
- this.store.setUserInfo({ ...initialState });
- this.store.setToken("");
- },
- },
- });
|