Files
admin-govern/src/router/index.ts

32 lines
716 B
TypeScript
Raw Normal View History

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