import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';

const defaultRouterList: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    component: () => import('@/layout'),
    children: [
      {
        path: '/',
        name: 'HomeChild',
        component: () => import('@/pages/home/index.vue'),
        beforeEnter: (to: any, from: any, next) => {
          next('/raffle');
        },
      },
      //   raffle - 抽奖
      {
        path: '/raffle/:code?/:id?',
        name: 'raffle',
        component: () => import('@/pages/raffle/index.vue'),
      },
      //   lp扫描
      {
        path: '/lp',
        name: 'lp',
        component: () => import('@/pages/lp/index.vue'),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes: defaultRouterList,
  scrollBehavior() {
    return {
      el: '#app',
      top: 0,
      behavior: 'smooth',
    };
  },
});

export default router;
