import Vue from 'vue'
import Router from 'vue-router'
import paths from '../assets/js/path.js'

Vue.use(Router)

/**
 *
 * author: water
 * data: 2019.7.8
 * */

let newpath = paths.path;

let arr = [];

function arrFn(path){
  let newArr = [];
  for (let [key, val] of Object.entries(path)) {
    let obj = {
      path: "/" + path[key].path,
      component: resolve => require(['../components/'+path[key].adddress+'.vue'], resolve),
      children:[]
    }

    if(path[key].children){
      obj.children = arrFn(path[key].children);
    }
    newArr.push(obj);
  }
  // console.log(newArr)
  return newArr;
}


// arr = arrFn(newpath);

export default new Router({
  // mode: 'history',
  routes: arrFn(newpath)
})
