Commit 68f9266e by yancanhua

fix: 登录防抖

1 parent 50365685
...@@ -29,16 +29,22 @@ function createRouter () { ...@@ -29,16 +29,22 @@ function createRouter () {
routes routes
}) })
} }
var isLoginTimer = null;
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */ /* 路由发生变化修改页面title */
store.dispatch('setPageMeta', to.meta) store.dispatch('setPageMeta', to.meta)
/* 路由发生变化修改页面背景色 */ /* 路由发生变化修改页面背景色 */
document.documentElement.style.backgroundColor = to.meta.backgroundColor || '#fff' document.documentElement.style.backgroundColor = to.meta.backgroundColor || '#fff'
to.matched.forEach(recode => { to.matched.forEach(recode => {
console.log(recode) //设置防抖,避免重复登录
if (!isLoginTimer) {
isLoginTimer = 1
setTimeout(() => { setTimeout(() => {
store.dispatch('login') store.dispatch('login')
}, 666) isLoginTimer = null
}, 1200);
}
}) })
if (to.matched.some(recode => recode.meta.noAuth)) { if (to.matched.some(recode => recode.meta.noAuth)) {
console.log('noAuth') console.log('noAuth')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!