no message
Former-commit-id: f35427ac714ea00ff560778838f100da33a5d039 Former-commit-id: 7da1c550f6aef9472b3e03c34ca3d6361dc58cdd Former-commit-id: 6ae6fe82c618260b4db2c8a1fed26aeaee4c84d4
This commit is contained in:
@@ -77,12 +77,16 @@ export default {
|
||||
})
|
||||
.then(res => {
|
||||
this.$log('登录结果', res)
|
||||
// cookie 一天的有效期
|
||||
const setting = {
|
||||
expires: 1
|
||||
}
|
||||
Cookies.set('username', res.username, setting)
|
||||
Cookies.set('password', res.password, setting)
|
||||
// 不要像下面这样写 请改写为你的保存用户逻辑
|
||||
// 保存用户名密码 不等于真正保存到了本地
|
||||
// Cookies.set('username', res.username, setting)
|
||||
// Cookies.set('password', res.password, setting)
|
||||
Cookies.set('token', res.token, setting)
|
||||
// 跳转路由
|
||||
this.$router.push({
|
||||
name: 'index'
|
||||
})
|
||||
|
||||
@@ -19,7 +19,8 @@ let router = new VueRouter({
|
||||
router.beforeEach((to, from, next) => {
|
||||
// 需要身份校验
|
||||
if (to.meta.requiresAuth) {
|
||||
// 这里暂时将cookie里是否存有token作为验证是否登陆的条件 请根据自身业务需要修改
|
||||
// 这里暂时将cookie里是否存有token作为验证是否登陆的条件
|
||||
// 请根据自身业务需要修改
|
||||
if (Cookies.get('token')) {
|
||||
next()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user