import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Login from '@/views/auth/Login.vue'
import Register from '@/views/auth/Register.vue'
import Notfound from '@/views/Notfound.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'home',
    component: HomeView
  }
  , {
    path: '',
    redirect: '/home'
  },
  {
    path: '/auth/login',
    component: Login
  },
  {
    path: '/auth/register',
    component: Register
  },
  {
    path: '/paynotice',
    name: 'paynotice',
    component: () => import('@/views/PayNotice.vue')
  },
  {
    path: '/layout',
    component: () => import('@/views/layout/Home.vue'),
    redirect: '/layout/index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/layout/Dashboard.vue'),
        meta: {
          title: '控制台',
          icon: 'home',
          showInMenu: true,
          showInUser: false,
          isHome: true
        }
      },
      {
        path: 'users',
        component: () => import('@/views/layout/Users.vue'),
        meta: {
          title: '用户管理',
          icon: 'users',
          showInMenu: true,
          showInUser: false,
          isHome: false
        }
      },
      {
        path: 'apis',
        component: () => import('@/views/layout/APIs.vue'),
        meta: {
          title: 'API管理',
          icon: 'layers',
          showInMenu: true,
          showInUser: false,
          isHome: false
        }
      },
      {
        path: 'packages',
        component: () => import('@/views/layout/Packages.vue'),
        meta: {
          title: '套餐管理',
          icon: 'grid',
          showInMenu: true,
          showInUser: false,
          isHome: false
        }
      },
      {
        path: 'apilist',
        component: () => import('@/views/layout/APIList.vue'),
        meta: {
          title: 'API列表',
          icon: 'grid',
          showInMenu: true,
          showInUser: true,
          isHome: false
        }
      },
      {
        path: 'buypackage',
        component: () => import('@/views/layout/BuyPackage.vue'),
        meta: {
          title: '套餐购买',
          icon: 'shopping-bag',
          showInMenu: true,
          showInUser: true,
          isHome: false
        }
      },
      {
        path: 'mypackages',
        component: () => import('@/views/layout/MyPackages.vue'),
        meta: {
          title: '已购套餐',
          icon: 'shopping-bag',
          showInMenu: true,
          showInUser: true,
          isHome: false
        }
      },
      {
        path: 'orders',
        component: () => import('@/views/layout/Orders.vue'),
        meta: {
          title: '订单管理',
          icon: 'shopping-cart',
          showInMenu: true,
          showInUser: true,
          isHome: false
        }
      }, 
      {
        path: 'balance',
        component: () => import('@/views/layout/Balance.vue'),
        meta: {
          title: '充值中心',
          icon: 'dollar-sign',
          showInMenu: true,
          showInUser: true,
          isHome: false
        }
      },
      {
        path: 'paymentconfig',
        component: () => import('@/views/layout/PayConfig.vue'),
        meta: {
          title: '支付配置',
          icon: 'sliders',
          showInMenu: true,
          showInUser:false,
          isHome:false
        }
      },
      {
        path: 'system',
        component: () => import('@/views/layout/SystemConfig.vue'),
        meta: {
          title: '系统设置',
          icon: 'settings',
          showInMenu: true,
          showInUser:false,
          isHome:false
        }
      },
      {
        path: 'center',
        component: () => import('@/views/layout/PersonalCenter.vue'),
        meta: {
          title: '个人中心',
          icon: 'user',
          showInMenu: false,
          showInUser:true,
          isHome:false
        }
      },
    ]
  },
  {
    path: '*',
    name: 'NotFound',
    component: Notfound
  }
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router