Zealon159 / book-ms-ui

:beers: 基于 vue.js 、element-ui 搭建一个极简的前后端分离图书管理平台
MIT License
254 stars 51 forks source link

我是不哪里没弄好 #3

Open GitHubXiaoSiyuan opened 4 years ago

GitHubXiaoSiyuan commented 4 years ago

image 用户名输入adi 点击提交,然后就是登陆成功,不跳转

GitHubXiaoSiyuan commented 4 years ago

image

Zealon159 commented 4 years ago

可以用抓包工具看下哈

  1. 看看请求登录接口是否正常返回 正常返回的响应如:{"msg":"登录成功!","code":"200","success":true,...
  2. 如果正常返回,看看有无JS错误 这个是处理登录成功跳转的函数:
     submitForm(loginForm) {
                this.$refs[loginForm].validate((valid) => {
                    if (valid) {
                        this.loading = true;
                        this.postRequest('/doLogin', this.loginForm).then(resp => {
                            this.loading = false;
                            if (resp.success) {
                                this.db.save("USER", resp.user);
                                let path = this.$route.query.redirect;
                                this.$router.replace((path == '/' || path == undefined) ? '/home' : path);
                            }
                        })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            }

    如果success返回true ,正常是可以跳转到home页的

GitHubXiaoSiyuan commented 4 years ago

1. {"msg":"登录成功!","code":"200","success":true,"user":{"userId":"admin","deptId":1,"deptName":null,"userName":"不懂温柔","sortNumber":99,"freezeStatus":false,"phoneNumber":"13800138000","roles":["管理员","内容编辑"],"headImgUrl":"attachment/2020-03-16/ad50149fd04f4a32a0cf8030a4a3e03a.jpeg"},"url":"system"} 2. image

Failed to load resource: net::ERR_NETWORK_ACCESS_DENIED
[WDS] Disconnected!
sockjs.js?6707:1606 GET http://192.168.1.68:9000/sockjs-node/info?t=1591626493302 net::ERR_NETWORK_ACCESS_DENIED
Zealon159 commented 4 years ago

看着响应结果说明接口没有问题,我这边到没有遇到这个这个问题,那个 sockjs.js 的错误貌似不会影响到跳转...

不过解决思路可以考虑用排除法,比如先确定请求结果有没有正常获取,如果正常那就往下排除,看看使用路由跳转有没有问题。

有时间你可以调试下哈,比如在post请求后打印下响应结果,然后直接路由跳转试试呢

this.postRequest('/doLogin', this.loginForm).then(resp => {
    console.log(resp);
    this.$router.replace('/home');
})
GitHubXiaoSiyuan commented 4 years ago

好的,我的需求还没有做完,有时间我再调试