import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * roles: ['admin', 'common']       // 访问路由的角色权限
 * permissions: ['a:a:a', 'b:b:b']  // 访问路由的菜单权限
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */
// 公共路由
export const constantRoutes = [{
  path: '/redirect',
  component: Layout,
  hidden: true,
  children: [{
    path: '/redirect/:path(.*)',
    component: () => import('@/views/redirect')
  }]
},
{
  path: '/login',
  component: () => import('@/views/login'),
  hidden: true
},
{
  path: '/register',
  component: () => import('@/views/register'),
  hidden: true
},
{
  path: '/404',
  component: () => import('@/views/error/404'),
  hidden: true
},
{
  path: '/401',
  component: () => import('@/views/error/401'),
  hidden: true
},
{
  path: '',
  component: Layout,
  redirect: 'index',
  children: [{
    path: 'index',
    component: () => import('@/views/index'),
    name: 'Index',
    meta: {
      title: '首页',
      icon: 'home',
      affix: true
    }
  }]
},
{
  path: '/user',
  component: Layout,
  hidden: true,
  redirect: 'noredirect',
  children: [{
    path: 'profile',
    component: () => import('@/views/system/user/profile/index'),
    name: 'Profile',
    meta: {
      title: '个人中心',
      icon: 'user'
    }
  }]
}
]

// 动态路由，基于用户权限动态去加载
export const dynamicRoutes = [{
  path: '/system/user-auth',
  component: Layout,
  hidden: true,
  permissions: ['system:user:edit'],
  children: [{
    path: 'role/:userId(\\d+)',
    component: () => import('@/views/system/user/authRole'),
    name: 'AuthRole',
    meta: {
      title: '分配角色',
      activeMenu: '/system/user'
    }
  }]
},
{
  path: '/system/role-auth',
  component: Layout,
  hidden: true,
  permissions: ['system:role:edit'],
  children: [{
    path: 'user/:roleId(\\d+)',
    component: () => import('@/views/system/role/authUser'),
    name: 'AuthUser',
    meta: {
      title: '分配用户',
      activeMenu: '/system/role'
    }
  }]
},
{
  path: '/system/dict-data',
  component: Layout,
  hidden: true,
  permissions: ['system:dict:list'],
  children: [{
    path: 'index/:dictId(\\d+)',
    component: () => import('@/views/system/dict/data'),
    name: 'Data',
    meta: {
      title: '字典数据',
      activeMenu: '/system/dict'
    }
  }]
},
{
  path: '/monitor/job-log',
  component: Layout,
  hidden: true,
  permissions: ['monitor:job:list'],
  children: [{
    path: 'index',
    component: () => import('@/views/monitor/job/log'),
    name: 'JobLog',
    meta: {
      title: '调度日志',
      activeMenu: '/monitor/job'
    }
  }]
},
{
  path: '/tool/gen-edit',
  component: Layout,
  hidden: true,
  permissions: ['tool:gen:edit'],
  children: [{
    path: 'index/:tableId(\\d+)',
    component: () => import('@/views/tool/gen/editTable'),
    name: 'GenEdit',
    meta: {
      title: '修改生成配置',
      activeMenu: '/tool/gen'
    }
  }]
},
// 内容管理
// 文章管理
// {
//   path: '/content',
//   component: Layout,
//   hidden: true,
//   permissions: ['content:article:list'],
//   children: [{
//     path: 'articleList/detail',
//     component: () => import('@/views/content/article/detail'),
//     name: 'articleListDetail',
//     meta: {
//       title: '文章详情',
//       activeMenu: '/content/articleList'
//     }
//   }]
// },
// 设备管理
// 设备列表
{
  path: '/device',
  component: Layout,
  hidden: true,
  permissions: ['device:list:list'],
  name: 'deviceList',
  children: [{
    path: 'list/detail',
    component: () => import('@/views/device/list/detail'),
    name: 'deviceListDetail',
    meta: {
      title: '设备详情',
      activeMenu: '/device/DeviceList'
    }
  }]
},
// 设备升级
{
  path: '/device',
  component: Layout,
  hidden: true,
  permissions: ['device:version:list'],
  children: [{
    path: 'version/detail',
    component: () => import('@/views/device/version/detail'),
    name: 'deviceVersionDetail',
    meta: {
      title: '设备升级详情',
      activeMenu: '/device/version'
    }
  }]
},
// 设备文章
{
  path: '/device',
  component: Layout,
  hidden: true,
  permissions: ['device:article:list'],
  name: 'article',
  children: [{
    path: 'article/detail',
    component: () => import('@/views/device/article/detail'),
    name: 'articleDetail',
    meta: {
      title: '文章详情',
      activeMenu: '/device/article'
    }
  }]
},
// 音频管理
// 歌手
{
  path: "/music",
  component: Layout,
  hidden: true,
  permissions: ['music:singer:list'],
  name: 'singer',
  children: [{
    path: 'singer/detail',
    component: () => import('@/views/music/singer/detail'),
    name: 'musicSingerDetail',
    meta: {
      title: `歌手详情`,
      activeMenu: '/music/singer'
    }
  }]
},
// 歌曲
{
  path: '/music',
  component: Layout,
  hidden: true,
  permissions: ['music:list:list'],
  name: 'musicList',
  children: [{
    path: 'musicList/detail',
    component: () => import('@/views/music/list/detail'),
    name: 'musicListDetail',
    meta: {
      title: `歌曲详情`,
      activeMenu: '/music/musicList'
    }
  }]
},
// 歌单
{
  path: '/music',
  component: Layout,
  hidden: true,
  permissions: ['music:menu:list'],
  name: 'musicMenu',
  children: [{
    path: 'menu/detail',
    component: () => import('@/views/music/menu/detail'),
    name: 'menu',
    meta: {
      title: `歌单详情`,
      activeMenu: '/music/musicMenu'
    }
  }]
},
// 音乐专辑
{
  path: '/music',
  component: Layout,
  hidden: true,
  permissions: ['music:album:list'],
  name: 'album',
  children: [{
    path: 'album/detail',
    component: () => import('@/views/music/album/detail'),
    name: 'albumDetail',
    meta: {
      title: '专辑详情',
      activeMenu: '/music/album'
    }
  }]
},
// 播客专辑
{
  path: '/music',
  component: Layout,
  hidden: true,
  permissions: ['music:blog:list'],
  name: 'blog',
  children: [{
    path: 'blog/detail',
    component: () => import('@/views/music/blog/detail'),
    name: 'blogDetail',
    meta: {
      title: `播客详情`,
      activeMenu: '/music/blog'
    }
  }]
},
// 节目
{
  path: '/music',
  component: Layout,
  hidden: true,
  permissions: ['music:program:list'],
  name: 'program',
  children: [{
    path: 'program/detail',
    component: () => import('@/views/music/program/detail'),
    name: 'programDetail',
    meta: {
      title: `节目详情`,
      activeMenu: '/music/program'
    }
  }]
},
// 主播
{
  path: '/music',
  component: Layout,
  hidden: true,
  permissions: ['music:anchor:list'],
  name: 'anchor',
  children: [{
    path: 'anchor/detail',
    component: () => import('@/views/music/anchor/detail'),
    name: 'anchorDetail',
    meta: {
      title: '主播详情',
      activeMenu: '/music/anchor'
    }
  }]
},
// 广播电台
{
  path: '/music',
  component: Layout,
  hidden: true,
  permissions: ['music:radio:list'],
  name: 'radio',
  children: [{
    path: 'radio/detail',
    component: () => import('@/views/music/radio/detail'),
    name: 'radioDetail',
    meta: {
      title: `电台详情`,
      activeMenu: '/music/radio'
    }
  }]
},
// 猫王精选电台
{
  path: '/music',
  component: Layout,
  hidden: true,
  permissions: ['music:choiceness:list'],
  name: 'choiceness',
  children: [{
    path: 'choiceness/detail',
    component: () => import('@/views/music/choiceness/detail'),
    name: 'choicenessDetail',
    meta: {
      title: '猫王精选详情',
      activeMenu: '/music/choiceness'
    }
  }]
},
// 项目管理
// 项目列表
{
  path: '/project',
  component: Layout,
  hidden: true,
  permissions: ['project:list:list'],
  children: [{
    path: 'projectList/detail',
    component: () => import('@/views/project/list/detail'),
    name: 'projectListDetail',
    meta: {
      title: `项目详情`,
      activeMenu: '/project/projectList'
    }
  }]
},
// 运营管理
// 启动页
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:startPage:list'],
  children: [{
    path: 'startPage/detail',
    component: () => import('@/views/operation/startPage/detail'),
    name: 'startPageDetail',
    meta: {
      title: '启动页详情',
      activeMenu: '/operation/startPage'
    }
  }]
},
// 推荐管理
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:recommend:list'],
  children: [{
    path: 'homePage/recommend/detail',
    component: () => import('@/views/operation/recommend/detail'),
    name: 'recommendDetail',
    meta: {
      title: '推荐详情',
      activeMenu: '/operation/homePage/operationRecommend'
    }
  }]
},
// 定制频道
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:channel:list'],
  name: 'channel',
  children: [{
    path: 'channel/detail',
    component: () => import('@/views/operation/channel/detail'),
    name: 'channelDetail',
    meta: {
      title: `频道详情`,
      activeMenu: '/operation/channel'
    }
  }]
},
// 标签分类
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:tag:list'],
  name: 'tag',
  children: [{
    path: 'tag/detail',
    component: () => import('@/views/operation/tag/detail'),
    name: 'tagDetail',
    meta: {
      title: '标签详情',
      activeMenu: '/operation/tag'
    }
  }]
},
// 唤醒音
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:waken:list'],
  name: 'waken',
  children: [{
    path: 'waken/detail',
    component: () => import('@/views/operation/waken/detail'),
    name: 'wakenDetail',
    meta: {
      title: '唤醒音详情',
      activeMenu: '/operation/waken'
    }
  }]
},
// 场景专区
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:scene:list'],
  name: 'scene',
  children: [{
    path: 'scene/detail',
    component: () => import('@/views/operation/scene/detail'),
    name: 'sceneDetail',
    meta: {
      title: '场景专区详情',
      activeMenu: '/operation/scene'
    }
  }]
},
// 协议管理
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:agreement:list'],
  name: 'agreement',
  children: [{
    path: 'agreement/detail',
    component: () => import('@/views/operation/agreement/detail'),
    name: 'agreementDetail',
    meta: {
      title: '协议详情',
      activeMenu: '/operation/agreement'
    }
  }]
},
// 活动管理
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:activity:list'],
  name: 'activity',
  children: [{
    path: 'activity/detail',
    component: () => import('@/views/operation/activity/detail'),
    name: 'activityDetail',
    meta: {
      title: '活动详情',
      activeMenu: '/operation/activity'
    }
  }]
},
// 反馈列表
{
  path: '/operation',
  component: Layout,
  hidden: true,
  permissions: ['operation:feedbacklist:list'],
  name: 'feedbacklist',
  children: [{
    path: 'feedback/feedbacklist/detail',
    component: () => import('@/views/operation/feedbacklist/detail'),
    name: 'feedbacklistDetail',
    meta: {
      title: '反馈详情',
      activeMenu: '/operation/feedback/feedbacklist'
    }
  }]
},
// 商品管理
// 商品推荐
{
  path: '/goods',
  component: Layout,
  hidden: true,
  permissions: ['goods:list:list'],
  children: [{
    path: 'goodsList/detail',
    component: () => import('@/views/goods/list/detail'),
    name: 'goodsListDetail',
    meta: {
      title: '商品详情',
      activeMenu: '/goods/goodsList'
    }
  }]
},
// 服务管理
// 音乐套餐 / 流量套餐
{
  path: '/service',
  component: Layout,
  hidden: true,
  permissions: ['service:package:list'],
  children: [{
    path: 'package/detail',
    component: () => import('@/views/service/package/detail'),
    name: 'packageDetail',
    meta: {
      title: '套餐详情'
    }
  }]
},
// 签到管理
// 抽奖配置
{
  path: '/registration',
  component: Layout,
  hidden: true,
  permissions: ['registration:lotteryConfig:list'],
  children: [{
    path: 'lotteryConfig/detail',
    component: () => import('@/views/registration/lottery/detail'),
    name: 'lotteryConfigDetail',
    meta: {
      title: '配置详情',
      activeMenu: '/registration/lotteryConfig'
    }
  }]
},
// 内容配置
{
  path: '/registration',
  component: Layout,
  hidden: true,
  permissions: ['registration:contentConfig:list'],
  children: [{
    path: 'contentConfig/detail',
    component: () => import('@/views/registration/content/detail'),
    name: 'contentConfigDetail',
    meta: {
      title: '配置详情',
      activeMenu: '/registration/contentConfig'
    }
  }]
},
// 兑换配置
{
  path: '/registration',
  component: Layout,
  hidden: true,
  permissions: ['registration:exchangeConfig:list'],
  children: [{
    path: 'exchangeConfig/detail',
    component: () => import('@/views/registration/exchange/detail'),
    name: 'exchangeConfigDetail',
    meta: {
      title: '配置详情',
      activeMenu: '/registration/exchangeConfig'
    }
  }]
},
// App升级
{
  path: '/push',
  component: Layout,
  hidden: true,
  permissions: ['push:update:list'],
  children: [{
    path: 'update/detail',
    component: () => import('@/views/push/update/detail'),
    name: 'updateDetail',
    meta: {
      title: '升级详情',
      activeMenu: '/push/update'
    }
  }]
},
// 推送弹窗
{
  path: '/push',
  component: Layout,
  hidden: true,
  permissions: ['push:dialog:list'],
  children: [{
    path: 'pushDialog/detail',
    component: () => import('@/views/push/dialog/detail'),
    name: 'dialogDetail',
    meta: {
      title: '弹窗详情',
      activeMenu: '/push/pushDialog'
    }
  }]
}]

export default new Router({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})