The game.json file in the root directory of the Mini Program is used to configure the Mini Program. The file content is a JSON object with the following properties:
Configuration Items
| Attribute | Type | Required | Default Value | Description | Minimum Version |
|---|---|---|---|---|---|
| deviceOrientation | String | No | 'portrait' | Screen orientation | |
| desktopDeviceOrientation | String | No | - | Screen orientation for Windows and Mac. If not specified, the value of deviceOrientation is used on Windows and Mac |
|
| showStatusBar | Boolean | No | false | Whether to display the status bar | |
| networkTimeout | Object | No | - | Timeout duration for network requests, in milliseconds | |
| workers | String | No | - | Multi-threading Worker configuration. For details, refer to the Worker documentation | |
| subpackages | Object Array | No | - | Subpackage structure configuration | |
| parallelPreloadSubpackages | Object Array | No | - | Parallel download capability | |
| navigateToMiniProgramAppIdList | String Array | No | - | List of Mini Programs to navigate to. See wx.navigateToMiniProgram for details | 2.4.0 |
| permission | Object | No | - | Settings related to Mini Game API permissions | WeChat Client 7.0.0 |
| openDataContext | String | No | - | Directory for the Mini Game open data domain. See Relationship Chain Data | |
| resizable | Boolean | No | false | Whether to enable large screen support. If enabled, users on PC can resize the window with a fixed ratio or maximize it to full screen; on iPad, screen rotation is enabled | |
| displayMode | String | No | - | Sets the initial resolution and whether stretching is allowed | |
| disableSetUserStorageFromMiniProgram | Boolean | No | false | Whether to prohibit writing managed data using the open data domain API wx.setUserCloudStorage. If set to true, user managed data can only be written via backend APIs | |
| lockStepOptions | Object | No | | Configuration object for Frame Synchronization Game Service | |
| lockStepOptions.gameTick | Number | No | 33 | Game frame delivery cycle, in ms | 2.8.0 |
| lockStepOptions.heartBeatTick | Number | No | 2000 | Frame synchronization heartbeat cycle, in ms | 2.8.0 |
| lockStepOptions.offlineTimeLength | Number | No | 100000 | Frame synchronization heartbeat timeout duration, in ms | 2.8.0 |
| lockStepOptions.UDPReliabilityStrategy | Number | No | 3 | Frame redundancy strategy, indicating the total number of frames delivered per frame transmission | 2.8.0 |
| lockStepOptions.dataType | String | No | "String" | The data type of actionList. Valid values: "String" for strings; "ArrayBuffer" for binary data | 2.8.0 | | iOSHighPerformance | Boolean | No | false | Whether to enable the iOS high-performance mode. This feature must be enabled in the MP console before use. For details, see High-Performance Mode | | | iOSHighPerformance+ | Boolean | No | false | Whether to enable the iOS High-Performance+ mode. The high-performance mode must also be enabled. For details, see High-Performance Mode | | | plugins | Object | No | - | Mini Game plugins. See Plugin Introduction | |
Valid values for deviceOrientation and desktopDeviceOrientation
| Value | Description | Minimum Version |
|---|---|---|
| portrait | Portrait. Does not rotate with the user's device rotation. | |
| landscape | Landscape with the home button on the right side. If the user's device screen orientation is not locked, the landscape orientation rotates with the device. | |
| landscapeLeft | Landscape with the home button on the left side | WeChat Client 7.0.0 |
| landscapeRight | Landscape with the home button on the right side | WeChat Client 7.0.0 |
networkTimeout
Timeout duration for various network requests, specified in milliseconds.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| request | Number | No | 60000 | Timeout for wx.request, in milliseconds. |
| connectSocket | Number | No | 60000 | Timeout for wx.connectSocket, in milliseconds. |
| uploadFile | Number | No | 60000 | Timeout for wx.uploadFile, in milliseconds. |
| downloadFile | Number | No | 60000 | Timeout for wx.downloadFile, in milliseconds. |
Valid values for displayMode
| Value | Resolution | Stretchable |
|---|---|---|
| mobile | 736x414 | No |
| pad | 1024x768 | No |
| desktop | 1024x768 | Yes, but only proportional scaling is supported |
workers
When using Worker to handle multi-threaded tasks, set the directory where the Worker code is located
subpackages
Supported in WeChat client version 6.6.7 and above, and Base Library version 2.1.0 and above.
When subpackages are enabled, declare the subpackage structure of the project.
Writing it as
subPackagesis also supported.
permission
Supported on WeChat client version 7.0.0 and above.
Configuration related to interface permissions for Mini Games. The field type is Object, with the following structure:
| Attribute | Type | Required | Default | Description |
|---|---|---|---|---|
| scope.userFuzzyLocation | PermissionObject | No | Declaration of permissions related to fuzzy location |
PermissionObject Structure
| Attribute | Type | Required | Default | Description |
|---|---|---|---|---|
| desc | string | Yes | Mini Program Description of the interface purpose displayed when requesting permission. Up to 30 characters |
Example:
{
"permission": {
"scope.userFuzzyLocation": {
"desc":"Your location information will be used for the effect display of the Mini Game location interface"
}
}
}
Configuration Example
{
"deviceOrientation": "portrait",
"networkTimeout": {
"request": 5000,
"connectSocket": 5000,
"uploadFile": 5000,
"downloadFile": 5000
},
"navigateToMiniProgramAppIdList": [
"wxe5f52902cf4de896"
]
}