before.ts 376 B

1234567891011121314
  1. import router from '@/router'
  2. import { done, start } from '@/utils/nprogress'
  3. const WHITE_LIST = ['/', '/falow']
  4. export const setupAuthRoutes = () => {
  5. router.beforeEach(async (to, _from, next) => {
  6. start()
  7. if (WHITE_LIST.includes(to.path)) return next()
  8. // 重定向登录页面
  9. next(`/`)
  10. })
  11. router.afterEach(() => {
  12. done() // 结束Progress
  13. })
  14. }