export default {
    namespaced:true,
    state:()=>{
        return {
            list:[],
            navIdx:-1,
            curIdx:-1
        }
    },
    mutations:{
        init(state,payload){
            state.list = [].concat(payload)
        },
        setNavIdx(state,idx){
            state.navIdx = idx;
        }
    },
    getters:{
        menu(state){
            let result =  state.list[state.navIdx]
            if(result && result.children){
               
                return result.children;
            }
            return []
        },
        localUrl(){
            let {  pathname,hash } = document.location;
            if(pathname.lastIndexOf('/')===pathname.length-1){
                return pathname+hash
            }
            return pathname+'/'+hash
        }
    },
    actions:{

    }
}
