Based on different requirements, you can encapsulate different businesses into an offline package, and then distribute the package through the release platform to update the client-side resource.
Generating an offline package mainly includes the following two steps:
Build a frontend .zip package
The paths of the resource packages vary by package type:
Global resource package
Normal resource package
Global resource package and normal resource package cannot coexist in the same H5 offline package.
Offline package ID (namely the top-level directory mentioned below) must be a 8-digit number.
Global resource package
You can place the common resource which is referenced by other normal resource packages in the global resource package. It is required to specify the resource path within the package with following rules:
Top-level directory: Offline package ID, for example: 77777777.
Second-level directory: The server’s domain address that is accessible to the resource.
For public cloud: The secondary directory should be fixed as
mcube-prod.mpaascloud
Otherwise, the acceleration capability of real-time publishing and docking will not be available.For private cloud: Refer to the domain address of mdsweb server deployed in the private cloud.
Third-level directory: In the format of
appId_workspaceId
, for example53E5279071442_test
.Avoid using special characters in folder names, file names, and files for public resource files. Special characters are characters that will be converted by the
urlencode
function. What follows the third-level directory is your custom public resource.
After the resource files are organized according to the above rules, you can fast locate the paths of resource files as in the following formats.
Resource files on public cloud:
http://domain/appID_workspace/resource file path
Resource files on private cloud:
http://domain/mcube/appID_workspace/resource file path
For the resource files on private cloud, you need to add /mcube
after the second-level directory (server domain name) in the file path.
Example:
In public cloud, the second-level directory is fixed to
mcube-prod.oss-cn-hangzhou.aliyuncs.com
, thus the path of the resource filecommon.js
ishttps://mcube-prod.oss-cn-hangzhou.aliyuncs.com/53E5279071442_test/common.js
.In private cloud, the second-level directory is the domain name of the mdsweb server deployed in private cloud. Taking
mdsweb-outer.alipay.net
as an example, the path of the resource filecommon.js
ishttps://mdsweb-outer.alipay.net/mcube/53E5279071442_test/common.js
.
The absolute length of the public resource cannot exceed 100 characters, otherwise the client might fail to load the resource and the page goes blank.
The server does not control the global resource package version. You can customize the version by adding a file directory structure after the third-level directory according to actual needs.
In private cloud, if the file storage format used by the server is hdfs or afs, you need to add a directory before the third-level directory mentioned above. The new directory name is the name of the storage space (bucket) in the mdsweb server.
To reference public resources, it means accessing the content of global resource packages via normal offline packages, so the access path must be absolute path, such as
https://mcube-prod.oss-cn-hangzhou.aliyuncs.com/53E5279071442_test/common.js
.
Normal resource package
You can place the relevant frontend resources such as HTML, CSS, and JavaScript into an offline package based on your business. The directory structure is as follows:
Top-level directory: Offline package ID, for example: 20171228.
Second-level and the following directories are your custom public resource. It is best to save all frontend files in a
/www
directory, and set a main entry file, for example:/www/index.html
.
Generate the .zip package
After configuring the path of resource package, you can directly compress the whole directory where the appId is located into a .zip
package.
Generate an .amr package on line
Log in to the mPaaS console, navigate to Mobile Delivery Service > Manage offline packages, and upload the .zip
package generated in the previous step to the Mobile Delivery Service platform to generate a .amr
package. For detailed steps, see Mobile Delivery Service > Create offline packages.
When you create an offline package, the minimum version of iOS client must be lower than the Product Version field in the
info.plist
file. You are recommended to set the minimum version of iOS client to 1.0.0.The Product Version in the
info.plist
file should be consistent with the value of Bundle versions string, short, otherwise the offline package may not take effect.