Problem 1.

After uni-app development and app packaging, the user does not log in. Enter the login page for the first time. Login jumps to the home page!

The usual solution is to judge whether the user is logged in or not in the onLaunch life cycle, but there is a bad experience is that each time you enter the program, you enter the first page set first and enter the home page, so the experience is not very good

2. Solve

Uni – app documents address: https://uniapp.dcloud.io/collocation/manifest? Id = splashscreen H5 + document address: http://www.html5plus.org/doc/zh_cn/navigator.html#plus.navigator.closeSplashscreen

Use plus. The navigator. CloseSplashscreen () first manifest. Json app – plus the value is true by default set to false in closed when necessary

Manifest.json source code configuration

"app-plus" : {
     "splashscreen" : {
         "alwaysShowBeforeRender" : false."waiting" : true."autoclose" : false."delay" : 0}}Copy the code

Vue file onLaunch life cycle in the writing (according to their own needs judgment) here is to use the token to judge whether there is a jump to the home page does not exist a jump to the login page

onLaunch: function() {
    console.log('App Launch');
    // #ifdef APP-PLUS
    // Token token to judge
    let token= uni.getStorageSync('token');    
    if (token) {
        If yes, close the startup page and go to the home page
	plus.navigator.closeSplashscreen();
	
    } else {
	// If no, go to the login page
        uni.reLaunch({
            url: "/pages/login/login".success: () = >{ plus.navigator.closeSplashscreen(); }})}// #endif
}
Copy the code