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

// test工具类
import Radio from '@/pages/radioTest'
import Form from '@/pages/form'

const Home = resolve => require.ensure([], () => { resolve(require('@/pages/home')) }, 'home')
const HlsPopup = resolve => require.ensure([], () => { resolve(require('@/pages/hlsPopup')) }, 'hlsPopup')
const HFile = () => import(/* webpackChunkName:'HFile' */ '@/pages/fileTest')

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/home',
    },
    {path: '/home', component: Home, name: 'Home', meta: {keepAlive: false}},
    // test工具类
    {path: '/hls-popup', component: HlsPopup, name: 'HlsPopup', meta: {keepAlive: false}},
    {path: '/Radio', component: Radio, name: 'Radio', meta: {keepAlive: true}},
    {path: '/HFile', component: HFile, name: 'HFile', meta: {keepAlive: true}},
    {path: '/Form', component: Form, name: 'Form', meta: {keepAlive: true}},
  ],
  scrollBehavior (to, from, savedPosition) {
    if (to.hash) {
      return {
        selector: to.hash,
      }
    }
  },
})
