读取中状态

This commit is contained in:
jqtmviyu@gmail.com 2021-01-15 16:49:40 +08:00
parent 616ac68cc7
commit f8522bdf51
2 changed files with 18 additions and 1 deletions

View File

@ -67,10 +67,16 @@
import router from '@/router'
import store from '@/store'
// 引入一份进度条插件
import NProgress from 'nprogress'
// 引入进度条样式
import 'nprogress/nprogress.css'
const whiteList = ['/login', '/404']
// 全局前置路由守卫
router.beforeEach((to, from, next) => {
NProgress.start()
// 判断是否有token
if (store.getters.token) { // 有token
if (to.path === '/login') { // 在登录页
@ -83,7 +89,15 @@ router.beforeEach((to, from, next) => {
next()
} else {
next('/login')
console.log('aaa')
}
}
// 主动结束进度条
NProgress.done()
})
// 全局后置路由守卫
router.afterEach(() => {
// 结束进度条
NProgress.done()
})

View File

@ -127,6 +127,7 @@ export default {
})
},
async handleLogin() {
this.loading = true
try {
await this.$refs.loginForm.validate() //
// await this.$store.dispatch('user/login', this.loginForm) // await
@ -136,6 +137,8 @@ export default {
} catch (error) {
console.log('捕获错误')
console.log(error)
} finally {
this.loading = false
}
}
}