This commit is contained in:
26
src/router/guard/index.ts
Normal file
26
src/router/guard/index.ts
Normal 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()
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user