mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-12-01 01:03:40 +08:00
22 lines
401 B
TypeScript
22 lines
401 B
TypeScript
import type { Router } from 'vue-router'
|
|
|
|
/**
|
|
*
|
|
* @description
|
|
* 路由切换启用顶部加载条。
|
|
* 路由切换启用加载动画。
|
|
*/
|
|
export const setupRouterLoadingBar = (router: Router) => {
|
|
router.beforeEach(() => {
|
|
window.$loadingBar?.start()
|
|
})
|
|
|
|
router.afterEach(() => {
|
|
window.$loadingBar?.finish()
|
|
})
|
|
|
|
router.onError(() => {
|
|
window.$loadingBar?.error()
|
|
})
|
|
}
|