update
init
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { createStore } from 'vuex';
|
||||
const state: any = {
|
||||
userInfo: {},
|
||||
questionList: [],
|
||||
};
|
||||
export default createStore({
|
||||
state,
|
||||
getters: {
|
||||
getUserInfo(state) {
|
||||
if (Object.keys(state.userInfo).length === 0) state.userInfo = JSON.parse(localStorage.getItem('userInfo') as string);
|
||||
return state.userInfo;
|
||||
},
|
||||
getQuestionList(state) {
|
||||
if (state.questionList.length === 0) state.questionList = JSON.parse(localStorage.getItem('questionList') as string);
|
||||
return state.questionList;
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
setUserInfo(state, userInfo: any) {
|
||||
state.userInfo = userInfo;
|
||||
localStorage.setItem('userInfo', JSON.stringify(userInfo));
|
||||
},
|
||||
setQuestionList(state, questionList: any) {
|
||||
state.questionList = questionList;
|
||||
localStorage.setItem('questionList', JSON.stringify(questionList));
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user