import { statisticRoutes } from '@/router/module/statisticRoutes';
import { pageRoutes } from './module/pageRoutes';
import { currentVersionIsNew } from '@/utils/util.ts';
import { createRouter, createWebHistory } from 'vue-router';

/**
 * * 如果需要打包成app，则要将路由改为Hash路由，createWebHashHistory
 * * 如果不需要 createWebHistory
 */
const router = createRouter({
	history: createWebHistory(import.meta.env.BASE_URL), // createWebHashHistory()
	routes: [...pageRoutes, ...statisticRoutes],
});

// @ts-ignore
router.beforeEach(async (to: any, from: any, next: any) => {
	next();
	await currentVersionIsNew();
});

export default router;
