import { createRouter, createWebHistory } from "vue-router";

//all routes
const appAllRoutes = [];
function importAllRoutes (r){
  for(let key in r) {
    appAllRoutes.push(...r[key].default)
  }
}
importAllRoutes(import.meta.glob('./modules/*.js',{ eager: true }))

const routes = [
  ...appAllRoutes,

  {
    path:'/',
    redirect: '/login'
  },
  {
    path:'/login',
    name:'Login',
    component: () => import("@/views/Login.vue"),
    meta:{
      title:'登录'
    }
  },
  {
    path: "/:pathMatch(.*)",
    name: "error",
    component: () => import("@/views/404.vue"),
    meta: { title: "404" },
  },
];

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_APP_BASE_URL),
  routes,
});


export default router;
