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

import homeRouters from './modules/home';
// 存放固定的路由
const defaultRouterList: Array<RouteRecordRaw> = [...homeRouters];
// 打包为app时，使用hash模式
const isHistory = import.meta.env.MODE == 'app';
const router = createRouter({
  history: isHistory ? createWebHashHistory() : createWebHistory(),
  routes: defaultRouterList,
  scrollBehavior() {
    return {
      el: '#app',
      top: 0,
      behavior: 'smooth',
    };
  },
});

export default router;
