feat: RouterStack
Some checks failed
CI / cache-and-install (push) Failing after 1m1s

This commit is contained in:
严浩
2024-08-08 15:13:35 +08:00
parent 5c11b15c1b
commit 2798254dab
18 changed files with 272 additions and 308 deletions

26
src/router/guard/index.ts Normal file
View File

@ -0,0 +1,26 @@
import NProgress from 'nprogress'
import type { Router } from 'vue-router'
import { createLogGuard, createStackGuard } from './log-guard'
// Don't change the order of creation
export function setupRouterGuard(router: Router) {
createProgressGuard(router)
createLogGuard(router)
createStackGuard(router)
router.onError((error) => {
console.debug('🚨 [router error]: ', error)
})
}
export function createProgressGuard(router: Router) {
router.beforeEach(() => {
NProgress.start()
})
router.afterEach(() => {
NProgress.done()
})
}