import { createRouter, createWebHashHistory } from 'vue-router' import staticRoutes from '@/router/static' import { useConfig } from '@/stores/config' import NProgress from 'nprogress' import { loading } from '@/utils/loading' const router = createRouter({ history: createWebHashHistory(), routes: staticRoutes }) router.beforeEach((to, from, next) => { NProgress.configure({ showSpinner: false }) NProgress.start() if (!window.existLoading) { loading.show() window.existLoading = true } console.log(to) next() }) // 路由加载后 router.afterEach(() => { if (window.existLoading) { loading.hide() } NProgress.done() }) export default router