/*
*
* router by wuwc 2017-12-20
*
* */
import React from 'react';
import {BrowserRouter, Switch, Route, Redirect} from 'react-router-dom';
import {asyncComponent} from '../utils/asyncComponent';

const routes = [
    {
        path:"/",
        exact: true,
        component: asyncComponent(() => import('../views/videoKindList/videoKindList'))
    },

        {
        path: '/videoKindList',
        exact: true,
        component: asyncComponent(() => import('../views/videoKindList/videoKindList'))
    },
    {
        path: '/videoList',
        exact: true,
        component: asyncComponent(() => import('../views/videoList/videoList'))
    },
    {
        path: '/login',
        exact: true,
        component: asyncComponent(() => import('../views/login/login'))
    }
    // {
    //     path: '/play/:songId',
    //     exact: false,
    //     component: asyncComponent(() => import('../containers/Play'))
    // }
];

/* 本地环境使用BrowserRouter, 线上环境使用HashRouter */
let Router = BrowserRouter ;

const RouterConfig = (
    <Router>
        <Switch>
            {
                routes.map((route, index) => (
                    <Route
                        key={index}
                        path={route.path}
                        exact={route.exact}
                        component={route.component}
                    />
                ))
            }
            <Redirect from='' to="/"/>
        </Switch>
    </Router>
);

export default RouterConfig;