The APP developed by uni-app judges which page to jump to based on the login status when starting up

Actual scenario: When the user opens the APP, if he is not logged in, he will be redirected to the login page, if he is already logged in, he will be redirected to the home page.

Configure the startup interface in the manifest.json of the project, and manually close the startup page (after the page jumps, close the startup page, no matter which is the first page configured in page.json, there will be no splash screen)

 Open the source code view and modify the splashscreen configuration as follows:

"splashscreen" : {
    "waiting" : false,
    "alwaysShowBeforeRender" : false,
    "autoclose" : false,
    "delay" : 0
}

Judging the login status on the appvue page and jumping, the first page configured in page.json is the home page, so if you have already logged in, just manually close the startup page

onLaunch: function() {
    // 进入APP后跳转至哪个页面
    let token= uni.getStorageSync('token');  //通过token判断是否登录
    if (token) {
        //存在则关闭启动页进入首页
        plus.navigator.closeSplashscreen();
    } else {
        //不存在则跳转至登录页
        uni.reLaunch({
            url: "/pages/signlogin/index",
            success: () => {
                plus.navigator.closeSplashscreen();
            }
        })
    }
}

Guess you like

Origin blog.csdn.net/WeiflR10/article/details/126875185