describe
App version management and upgrade is an indispensable function, and uniapp provides a whole set of processes. Since the official document is too complicated and written in a cloud, I personally record my operation until The configuration was successful.
overall
It is divided into 2 parts. The two official plug-ins ( uni-upgrade-center - Admin
and uni-upgrade-center - App
) are used together. This article adopts the simplest and rude way to achieve.
front end settings
1 Install the front-end plugin
Plugin uni-upgrade-center - App , import the plugin into your project.
2 Add path
In pages.json
the file, add an update page (officially provided)
{
"path": "uni_modules/uni-upgrade-center-app/pages/upgrade-popup",
"style": {
"disableScroll": true,
"app-plus": {
"backgroundColorTop": "transparent",
"background": "transparent",
"titleNView": false,
"scrollIndicator": false,
"popGesture": "none",
"animationType": "fade-in",
"animationDuration": 200
}
}
}
3 Add update code
Put the updated code where you want to display it
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update.js'
For example, I wrote in App.vue
it that it detects as soon as the project is opened
backend settings
I personally suggest not to use the back-end uni-upgrade-center - Admin
, just create a new project and use the uni-admin
built-in upgrade center, because there will be statistics in the follow-up, and uni-admin will be used, so it is easier for us to use this directly
step
- Create a new uni-admin project
- Use the new cloud development space, not shared with the app
- Upload directly to cloud hosting when publishing
There is basically no change in the uni-admin project, it can be used directly after downloading and uploading
The back-end project is built, enter the background, and add your APP
Notice
1 Cloud function adjustment (required)
Because the front and back end are two projects, we need to modify the updated cloud function and point the service space to uni-admin to call the update cloud function, and the parameters can be seen in the service space
const myCloud = uniCloud.init({
provider: 'aliyun',
spaceId: 'mp-xxxxxxxxxxxxxxxxxxx',
clientSecret: 'xxxxxxxxx'
});
myCloud.callFunction({
name: 'uni-upgrade-center',
data,
success: (e) => {
console.log("e: ", e);
resolve(e)
},
fail: (error) => {
reject(error)
}
})
2 Publish wgt package problem
manifest.json
Please be sure to modify the version name in to a higher version before packaging
3 Release a new version
You can publish it directly in the admin background, and you can check it on the app side
4 How to test
You must package the apk and install it on your mobile phone. I couldn’t check it using the web side before, and I couldn’t check it using the hbuild base APP.