import { Layout } from '@/layout'

// 重定向路由
export const REDIRECT_ROUTE = {
  path: '/redirect',
  component: Layout,
  name: 'RedirectTo',
  meta: {
    title: 'Redirect',
    hideInMenu: true
  },
  children: [
    {
      path: '/redirect/:path(.*)/:_redirect_type(.*)/:_origin_params(.*)',
      name: 'Redirect',
      component: () => import('@/pages/redirect/index.vue'),
      meta: {
        title: 'Redirect'
      }
    }
  ]
}

const basicRoutes = [
  {
    path: '/',
    name: 'Login2',
    component: () => Layout,
    redirect: 'Login',
    meta: {
      title: '登录',
      ignoreAuth: false,
      hideInMenu: true
    }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/pages/Login.vue'),
    meta: {
      title: '登录',
      ignoreAuth: false,
      hideInMenu: true
    }
  },
  {
    path: '/page/:index/view',
    name: 'PageView',
    component: () => import('@/pages/PageView.vue'),
    meta: {
      title: '页面',
      ignoreAuth: true,
      hideInMenu: true
    }
  },
  {
    path: '/page/create',
    name: 'Create',
    component: () => import('@/pages/DesignerView/View.vue'),
    meta: {
      title: '创建页面',
      ignoreAuth: false,
      permission: 'CreatePage',
      hideInMenu: true
    }
  },
  {
    path: '/page/:index/edit',
    name: 'Editor',
    component: () => import('@/pages/DesignerView/View.vue'),
    meta: {
      title: '编辑页面',
      ignoreAuth: false,
      permission: 'EditePage',
      hideInMenu: true
    }
  },
  {
    path: '/preview',
    name: 'Preview',
    component: () => import('@/pages/Preview.vue'),
    meta: {
      title: '预览界面',
      ignoreAuth: false,
      permission: 'PreviewPage',
      hideInMenu: true
    }
  },
  {
    path: '/pageLayout',
    name: 'PageLayout',
    component: Layout,
    meta: {
      title: '布局界面',
      icon: 'template'
    },
    children: [
      {
        path: '/pages',
        name: 'Pages',
        component: () => import('@/pages/Pages.vue'),
        meta: {
          title: '页面管理',
          ignoreAuth: false,
          icon: 'page'
        }
      }
    ]
  },
  REDIRECT_ROUTE,
  {
    path: '/404',
    name: '404',
    component: () => import('@/pages/exception/404.vue'),
    meta: {
      title: '错误页面',
      ignoreAuth: true,
      hideInMenu: true
    }
  },
  {
    path: '/403',
    name: '403',
    component: () => import('@/pages/exception/403.vue'),
    meta: {
      title: '无权限',
      ignoreAuth: true,
      hideInMenu: true
    }
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'Error',
    component: () => import('@/pages/exception/404.vue'),
    meta: {
      title: '错误页面',
      ignoreAuth: true,
      hideInMenu: true
    }
  }
]

export default basicRoutes
