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

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

    }
  },
  mounted(){
    if(window.location.href.indexOf('login') < 0){
      let permission = this.$store.state.progressList;
      let menuList = [];
      this.$router.options.routes[0].children = [];
      let order = permission.find(x=>{return x.cover === '5-1'});
      if(order && order.refund){
        this.$store.state.orderRefund = true
      }
      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[0]]);//调用add
      this.$store.dispatch('setMenu',menuList)
    }

  }
}
</script>

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