import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import Layout from "@/layout/index.vue";

export const constantRoutes = [
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
          {
            path: '/redirect/:path(.*)',
            component: () => import('@/views/redirect/index.vue')
          }
        ]
    },
    {
        path: '/',
        redirect: '/login', // 这里做重定向
        hidden: true,
    },
    {
        path: "/login",
        component: () => import("@/views/login.vue"),
        meta: { title: "登录" },
        hidden: true,
    },
    {
        path: '/whiteboard',
        component: () => import('@/views/custom/tabulaRase/index.vue'),
        meta: { title: "白板" },
        hidden: true,
    },
    {
        path: "/coordinate",
        redirect: "/coordinate/CoordinatePage",
        component: Layout, 
        children: [
            {
                path: 'CoordinatePage',
                name: "Coordinate", 
                component: () => import("@/views/coordinate/personnelList/index.vue"),
                meta: { title: "远程协作", icon: "client", affix: true },
            }
        ]
    },
        {
        path: "/conferencingRoom", 
        // component: Layout, 
        hidden: true,
        children: [
            {
                path: '',
                name: "ConferencingRoom",
                component: () => import("@/views/conferencingRoom/index.vue"),
                meta: { title: "会议房间", icon: "client", affix: true },
            }
        ]
    },
    // 错误页面路由
    {
        path: "/:pathMatch(.*)*",
        component: () => import("@/views/error/404.vue"),
        hidden: true,
    },
    {
        path: "/401",
        component: () => import("@/views/error/401.vue"),
        hidden: true,
        meta: { title: "401未授权" }
    }, 
]

export const dynamicRoutes = [
    
]

// const router = createRouter({
//     history: createWebHashHistory(import.meta.env.BASE_URL),
//     routes: [
//         // {
//         //     path: '/',
//         //     component: () => import("@/views/custom/tabulaRase/index.vue"), 
//         // },
//         {
//             path: '/',
//             redirect: '/login', // 这里做重定向
//         },
//         {
//             path: '/whiteboard',
//             component: () => import('@/views/custom/tabulaRase/index.vue'),
//         },
//         {
//             path: "/login",
//             component: () => import("@/views/login.vue"),
//         },
//         {
//             path: "/coordinate",
//             component: Layout,
//             meta: { title: "远程协作", icon: "client", affix: true },
//             children: [
//                 {
//                     path: '',
//                     name: "Coordinate",
//                     component: () => import("@/views/coordinate/personnelList/index.vue")
//                 }
//             ]
//         },
//         {
//             path: "/conferencingRoom",
//             children: [
//                 {
//                     path: '',
//                     name: "ConferencingRoom",
//                     component: () => import("@/views/conferencingRoom/index.vue")
//                 }
//             ]
//         },


//         // 错误页面路由
//         {
//             path: "/:pathMatch(.*)*",
//             component: () => import("@/views/error/404.vue"),
//         },
//         {
//             path: "/401",
//             component: () => import("@/views/error/401.vue"),
//         }
//     ],
// })
const router = createRouter({
    // history: createWebHistory(import.meta.env.VITE_BASE_PATH),
    history: createWebHashHistory(import.meta.env.BASE_URL),
    routes: constantRoutes,
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition;
        } else {
            return { top: 0 };
        }
    },
});


export default router
