import { Module, VuexModule, getModule, // MutationAction, } from 'vuex-module-decorators'; import store from '@/store'; /** * [TODO:REMOVE] demo refercences */ // import { // loginApi, // } from '@/api'; // import { // UserInfo, // } from '@/types'; // import localforage from 'localforage'; @Module({ namespaced: true, dynamic: true, store, name: 'User', stateFactory: true, }) class User extends VuexModule { /** * [TODO:REMOVE] demo */ // userInfo: UserInfo | null = null; // get username() { // return (this.userInfo && this.userInfo.username) || ''; // } // @MutationAction({ mutate: ['userInfo'] }) // async fetchUserInfo(): Promise<{ userInfo: UserInfo | null }> { // await getModule(User).fetchUserInfoAtLocal(); // const userInfoAtStore = getModule(User).userInfo; // try { // if (userInfoAtStore) { // return { // userInfo: userInfoAtStore, // }; // } // const res = await loginApi.getUserInfoByToken(); // if (res !== undefined) { // localforage.setItem('apmUserInfo', res); // return { // userInfo: res, // }; // } // throw Error; // } catch (error) { // return { // userInfo: userInfoAtStore, // }; // } // } } export default getModule(User);