import { createRouter, createWebHistory } from 'vue-router'
// import { routes } from 'vue-router/auto-routes'
import routes from '~pages'
import { setupLayouts } from 'virtual:generated-layouts'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: setupLayouts(routes),
})
router.beforeEach((to, from, next) => {
  // 检查是否需要滚动到顶部
  if (to.meta.scrollToTop !== false) {
    window.scrollTo(0, 0) // 滚动到顶部
  }
  next()
})
export default router
