import { createRouter, createWebHashHistory } from 'vue-router';
const { VITE_APP_NAME } = import.meta.env;

let routes = [
    {
        path: '/',
        name: 'home',
        component: () => import('@/views/welcome.vue'),
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/login.vue'),
    },
];

/**
 * 如果打包项目A，将B的页面注释掉，这样打包只会打包A的页面，减少资源
 * 如果打包项目B，将A的页面注释掉，这样打包只会打包B的页面，减少资源
 */
switch (VITE_APP_NAME) {
    case 'projectA':
        routes = routes.concat([
            {
                path: '/test',
                name: 'test',
                component: () => import('@projectA/views/test/index.vue'),
            },
            {
                path: '/error',
                name: 'error',
                component: () => import('@projectA/views/error/index.vue'),
            },
        ]);
        break;
    // case 'projectB':
    //     routes = routes.concat([
    //         {
    //             path: '/monitor',
    //             name: 'monitor',
    //             component: () => import('@projectB/views/monitor/index.vue'),
    //         },
    //         {
    //             path: '/error',
    //             name: 'error',
    //             component: () => import('@projectB/views/error/index.vue'),
    //         },
    //     ]);
    //     break;
}

const router = createRouter({
    history: createWebHashHistory(),
    routes,
});

export default router;
