import { createRouter, createWebHashHistory } from 'vue-router'

let history = createWebHashHistory()
// let history = createWebHistory('/admin')

let routes = [
  {
    path: '/',
    name: 'Order',
    redirect: '/list'
  },
  {
    path: '/list',
    name: 'List',
    component: ()=> import("../index.vue"),
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/info',
    name: 'OrderInfo',
    component: ()=> import("../Info/index.vue")
  },
  {
    path: '/add',
    name: 'OrderAdd',
    component: ()=> import("../Add/index.vue")
  },
  {
    path: '/printcard',
    name: 'PrintCard',
    component: ()=> import("../printcard.vue")
  },
]

const router = createRouter({ 
  history, 
  routes,
  scrollBehavior(to, from, savedPosition) {
    return { top: 0 };
  }
 })

// router.beforeEach((to, from, next)=>{
  // if( to.meta.isAuth === true && !Cookies.get('token')){
  //   return next({name: 'Login'})
  // }
//   return next()
// })

export default router