init
This commit is contained in:
2025-06-27 17:42:38 +08:00
commit bd6402478b
5317 changed files with 785994 additions and 0 deletions
+28
View File
@@ -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));
},
},
});