<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
  import menu from './util/menuList'
export default {
  name: 'App',
  data(){
    return {

    }
  },
  mounted(){
    let permission = this.$store.state.progressList;
    let menuList = [];
    this.$router.options.routes[0].children = [];
    menu.forEach(i=>{
      let p = false;
      let t = [];
      i.list.forEach(j=>{
        let find = permission.find(x=>{return x.cover === j.cover});
        if(find){
          j.router.meta = {};
          j.router.meta.readonly = find.readonly;
          j.router.meta.delete = !!find.delete;
          t.push(j);
          this.$router.options.routes[0].children.push(j.router);
          p = true;
        }
      });
      if(p){
        i.list = t;
        menuList.push(i)
      }
    })
    this.$router.addRoutes(this.$router.options.routes);//调用add
    this.$store.dispatch('setMenu',menuList)
  }
}
</script>

<style>
#app {
  height: 100%;
}
  html,body{
    height: 100%;
    margin: 0;
    padding: 0;
  }
</style>
