const state = {
    baseInfo: localStorage.getItem('baseInfo')
        ? JSON.parse(localStorage.getItem('baseInfo'))
        : {}, // 当前系统baseInfo信息
    history: sessionStorage.getItem('history')
        ? JSON.parse(sessionStorage.getItem('history'))
        : [],
    currentIndex: sessionStorage.getItem('currentIndex')
        ? JSON.parse(sessionStorage.getItem('currentIndex'))
        : '0-0',
    menuIndex: sessionStorage.getItem('menuIndex')
        ? JSON.parse(sessionStorage.getItem('menuIndex'))
        : '0-0',
};
const getters = {
    baseInfo: state => state.baseInfo,
    history: (state) => state.history,
    currentIndex: (state) => state.currentIndex,
    menuIndex: (state) => state.menuIndex,
};
const mutations = {
    setBaseInfo(state, data) {
        localStorage.setItem('baseInfo', JSON.stringify(data));
        state.baseInfo = JSON.parse(localStorage.getItem('baseInfo'));
    },
    clearBaseInfo() {
        localStorage.removeItem('baseInfo');
    },
    setHistory(state, data) {
        sessionStorage.setItem('history', JSON.stringify(data));
        state.history = JSON.parse(sessionStorage.getItem('history'));
    },
    setCurrent(state, data) {
        sessionStorage.setItem('currentIndex', JSON.stringify(data));
        state.currentIndex = JSON.parse(sessionStorage.getItem('currentIndex'));
    },
    setMenuIndex(state, data) {
        sessionStorage.setItem('menuIndex', JSON.stringify(data));
        state.menuIndex = JSON.parse(sessionStorage.getItem('menuIndex'));
    },
};
const actions = {};

export default {
    state,
    getters,
    actions,
    mutations
};
