/*
 * @Author: your name
 * @Date: 2020-09-10 18:52:15
 * @LastEditTime: 2020-10-09 15:43:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /getCoinsEveryday/src/router/index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../Home/index.vue'
import Color from '../Color/index.vue'
import AR from '../AR/index.vue'
import ARHit from '../ARHit/index.vue'
import Camera from '../Camera/index.vue'
import HandTrack from '../HandTrack/index.vue'



Vue.use(VueRouter)

const routes = [
	{
		path: "/",
		name: "Home",
		component: Home,
		meta: {
			title: "大板栗的玩具屋", // 标题
			keepAlive: false, // 是否保持活跃
		},
	},
	{
		path: "/home",
		name: "Home2",
		component: Home,
		meta: {
			title: "大板栗的玩具屋", // 标题
			keepAlive: false, // 是否保持活跃
		},
	},
	{
		path: "/color",
		name: "Color",
		component: Color,
		meta: {
			title: "Color", // 标题
			keepAlive: false, // 是否保持活跃
		},
	},
	{
		path: "/ar",
		name: "AR",
		component: AR,
		meta: {
			title: "AR Paint", // 标题
			keepAlive: false, // 是否保持活跃
		},
	},
	{
		path: "/arHit",
		name: "ARHit",
		component: ARHit,
		meta: {
			title: "AR Hit Test", // 标题
			keepAlive: false, // 是否保持活跃
		},
	},
	{
		path: "/camera",
		name: "Camera",
		component: Camera,
		meta: {
			title: "camera  test", // 标题
			keepAlive: false, // 是否保持活跃
		},
	},
	{
		path: "/track",
		name: "HandTrack",
		component: HandTrack,
		meta: {
			title: "Hand Track", // 标题
			keepAlive: false, // 是否保持活跃
		},
	},


	// {
	//   path: "/example",
	//   name: "example",
	//   // route level code-splitting
	//   // this generates a separate chunk (about.[hash].js) for this route
	//   // which is lazy-loaded when the route is visited.
	//   component: () => import("../views/example.vue"),
	//   children: [
	//     // {
	//     // 	path: '/',
	//     // 	name: 'com1',
	//     // 	component: () =>
	//     // 		import(/* webpackChunkName: "com1" */ './components/com1.vue'),//像这样的 前面的注释内容是有用的，可以指定chunk的名字
	//     // },
	//   ],
	//   meta: {
	//     keepAlive: false,
	//   },
	// },
];

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

// before守卫
router.beforeEach((to, from, next) => {
	/* 路由发生变化修改页面title */
	if (to.meta.title) {
		document.title = to.meta.title
	}
	next()
})

export default router
