登录跳转判断
- 用户输入后台路径/
- vue router 进行跳转
- 跳转前触发导航守卫 router.beforeEach,在文件src/permission.js 中定义的,判断有没有token信息,没有的话跳转到登录页面src/views/login/views/index.vue;有的话跳转到对应的页面.
验证密码判断
- 登录页src/views/login/views/index.vue的账号密码输入模块src/views/login/views/userlogin.vue ,点击登录后,通过handleLogin() 里面的vuex 方法LoginByUsername() 方法提交,数据为
- LoginByUsername ({ commit }, userInfo){},先将用户数据通过encryption 加密(CryptoJS),格式如下:
- 加密后的数据,通过@/network/userLogin/user里面的loginByUsername 方法,发送给后端路径/user/login。
vue router 跳转到主页 src/views/index/index.vue 。
主页 src/views/index/index.vue 创建(created)时,先调用 自己页面定义 的 refreshToken( ) 方法,判断是否要重新刷新token,每1分钟判断一次。
如果token使用时间,大于网站设定的token过期时间,则刷新token:
1.先获取token,调用src\store\modules\user.js 的RefeshToken()方法,给后端发送请求
2.获取的token,调用本页的SET_TOKEN 方法,给公共
如果token过期