1***@qq.com
1***@qq.com
  • 发布:2023-02-07 18:06
  • 更新:2023-02-08 17:05
  • 阅读:789

#插件讨论# 【 uni-starter - DCloud前端团队 】配置"needLogin": true后依然可以跳过登录

分类:uni-app
关联插件: uni-starter

我是新手,说一个自己遇到的问题吧。在pages.json中的‘pages/list/list’页面(首页)配置"needLogin": true后,可以正常跳到登录页。但是登录页左上角会出现‘小房子’按钮,点击该按钮会回到首页,从而跳过登录,然后所有的页面均可访问啦,一直搞不清楚这个问题该如何解决,希望开发者能够解答疑惑,万分感谢!

"pages": [{  
            "path": "pages/list/list",  
            "style": {  
                // #ifndef APP-PLUS  
                "enablePullDownRefresh": false,  
                // #endif  
                "navigationBarTitleText": "电光研工"  
                // "navigationStyle": "custom"  
            },  
            "needLogin": true  
        },  
        {  
            "path": "pages/grid/grid",  
            "style": {  
                //#ifndef MP  
                "navigationStyle": "custom"  
                //#endif  
            }  
        },  
        {  
            "path": "pages/ucenter/ucenter",  
            "style": {  
                "navigationStyle": "custom"  
            }  
        }]  
"uniIdRouter": {  
        "loginPage": "uni_modules/uni-id-pages/pages/login/login-withpwd",  
        "needLogin": [  
            "/uni_modules/uni-id-pages/pages/userinfo/userinfo"  
        ],  
        "resToLogin": true  
    }  

2023-02-07 18:06 负责人:无 分享
已邀请:

最佳回复

DCloud_uniCloud_JSON

DCloud_uniCloud_JSON

  1. hidehomebutton可以通过uni.hideHomeButton()隐藏,后续uni-starter会直接内置这个逻辑。

  2. 你的结论:“点击该按钮会回到首页,从而跳过登录,然后所有的页面均可访问啦”,说明你只做了前端拦截没做服务端(云函数)拦截未登录的用户访问;前后有一个拦截就会自动跳转到登录页面。

1***@qq.com

1***@qq.com (作者)

非常感谢你的认真回复!【抱拳】
但我似乎找到了一个简单的方法:```javascript
{
"path": "login/login-withpwd",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "login/login-withoutpwd",
"style": {
"navigationStyle": "custom"
}
}


只要在登录页加上"navigationStyle": "custom"就没有任何按钮啦。。。这个方法可能不治本,但是对我来说够用了,毕竟还不会云函数等。  
再次感谢!  

该问题目前已经被锁定, 无法添加新回复