/*
 * @Date: 2021-12-08 16:13:09
 * @LastEditors: JinxuChen
 * @LastEditTime: 2021-12-10 10:19:33
 * @FilePath: \GpsCardAdmin\src\store\localStore.js
 * @description: store 使用local Storage
 */
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);
const  prefix = 'gps_card_admin_';
export default new Vuex.Store({
    state: {
        userName:'',
    },
    mutations: {
        userName(state, userName) {
            state.userName = userName;
            window.localStorage[prefix + 'userName'] = userName;
        },
    },
    getters: {
        userName: state => {
            if (state.userName != '') return state.userName;
            else return window.localStorage[prefix + 'userName'] == null ? '' : window.localStorage[prefix + 'userName'];
        },
    },
    actions: {},
    modules: {}
})
