目录

extJson说明

extJson参数在使用模板生成元服务时,用于承载模板中可变信息(AppID、版本信息、模块信息等)的配置。

配置字段说明

属性

类型

是否必填

描述

extAppId

String

是

待构建元服务的appid。

appConfig

Object

是

替换模板工程AppScope/app.json5的配置,格式需与app.json5定义保持一致。

详细内容参考appConfig。

moduleConfig

Object

否

替换模板工程中对应模块下module.json5的配置,格式需与module.json5定义保持一致。

数组类型,支持配置多个module。

详细内容参考moduleConfig。

ascfConfig

Object

否

ASCF框架元服务才需要配置,ArkUI开发的元服务无需配置此内容。

替换模板包中hap包下resources/rawfile/manifest.json的配置,除entryPagePath之外支持增量替换。

详细内容参考ascfConfig。

[h2]appConfig

属性

类型

是否必填

描述

versionCode

数值

否

构建版本号。

  • 如果填写,当次构建versionCode的值比上次构建的versionCode的值要大。
  • 如果不填写,会直接复用模板的versionCode。

versionName

字符串

否

构建版本名称。仅由数字和点构成,必须符合正则校验规则:^[0-9.]+|(?=.*[{])(?=.*[}])[0-9a-zA-Z_.{}]+$

推荐采用“A.B.C.D”四段式的形式。

description

字符串

否

应用描述。

不支持 $xxx 资源引用方式。

长度为0~255个字符。

[h2]moduleConfig

属性

类型

是否必填

描述

name

字符串

是

需要替换Module的名称。

Module的名称不会被替换,此配置是为了查找到需要替换的module文件。

abilities

对象数组

否

需要替换Module中UIAbility的配置信息。

abilities详细内容参考abilities。

clientId

字符串

否

需要替换Module中client_id的配置信息。

此字段值会替换模板工程中对应模块module.json5文件中的client_id值。元服务的client_id值可以在第三方平台查询授权信息获取。

长度为0~255个字符。

abilities

属性

类型

是否必填

描述

name

字符串

是

需要替换UIAbility组件的名称。

UIAbility组件的名称不会被替换,此配置是为了查找到需要替换的UIAbility文件。

maxWindowRatio

数值

否

需要替换UIAbility组件支持的最大的宽高比。

minWindowRatio

数值

否

需要替换UIAbility组件支持的最小的宽高比。

maxWindowWidth

数值

否

需要替换UIAbility组件支持的最大的窗口宽度。

minWindowWidth

数值

否

需要替换UIAbility组件支持的最小的窗口宽度。

maxWindowHeight

数值

否

需要替换UIAbility组件支持的最大的窗口高度。

minWindowHeight

数值

否

需要替换UIAbility组件支持的最小的窗口高度。

ascfConfig

属性

类型

是否必填

描述

entryPagePath

字符串

否

启动页的路径。

此字段不支持增量替换。

pages

Object

否

manifest文件中router/pages节点下的页面设置。

pages下的“pages/discovery/discovery”是用于定位具体位置,实际仅替换info下的内容。

tabBar

Object

否

全局的导航栏设置。

tabBar详细内容参考tabBar。

window

Object

否

全局的窗口设置。

window详细内容参考window。

tabBar

属性

类型

是否必填

描述

backgroundColor

字符串

否

导航栏的背景颜色。

borderStyle

字符串

否

导航栏的边框风格。

color

字符串

否

导航栏的颜色。

list

对象数组

否

导航栏中组件的配置清单。

list详细内容参考list。

selectedColor

字符串

否

导航栏选中后的颜色。

list

属性

类型

是否必填

描述

iconPath

字符串

否

导航栏中组件的图标路径。

pagePath

字符串

否

导航栏中组件的跳转页面路径。

selectedIconPath

字符串

否

导航栏中组件的被选中后图标路径。

text

字符串

否

导航栏中组件的名称文本。

window

属性

类型

是否必填

描述

backgroundColor

字符串

否

全局的窗口背景颜色。

backgroundTextStyle

字符串

否

全局的窗口字体风格。

enablePullDownRefresh

枚举值

否

全局的窗口是否支持下拉更新。

navigationBarBackgroundColor

字符串

否

全局的窗口导航栏的背景颜色。

navigationBarTextStyle

字符串

否

全局的窗口导航栏标题风格。

navigationBarTitleText

字符串

否

全局的窗口导航栏标题名称。

extJson配置样例

构建元服务extJson完整配置样例:
{
   "extAppId": "1118669435474119700", 
   "appConfig":{
     "app": {
       "versionCode": 1000,
       "versionName": "1.0.0.0",
       "description": "元服务简介"
     }
    },
    "moduleConfig": [
        {
            "module": {
                "name": "entry",
                "abilities": [
                    {
                        "name": "EntryAbility",
                        "maxWindowHeight": 300,
                        "maxWindowRatio": 3.5,
                        "maxWindowWidth": 2560,
                        "minWindowHeight": 200,
                        "minWindowRatio": 0.5,
                        "minWindowWidth": 1400
                    }
                ],
                "clientId": "1****1"
            }
        }
    ],
    "ascfConfig": {
        "entryPagePath": "entryPagePath",
        "pages": {
            "pages/discovery/discovery": {
                "info": {
                    "navigationBarTitleText": ""
                }
            }
        },
        "tabBar": {
            "backgroundColor": "#FFFFFF",
            "borderStyle": "white",
            "color": "#626567",
            "list": [
                {
                    "iconPath": "images/index.png",
                    "pagePath": "pages/index/index",
                    "selectedIconPath": "images/index_focus.png",
                    "text": ""
                }
            ],
            "selectedColor": "#2A8CE5"
        },
        "window": {
            "backgroundColor": "#F4F4F4",
            "backgroundTextStyle": "light",
            "enablePullDownRefresh": true,
            "navigationBarBackgroundColor": "#0068C4",
            "navigationBarTextStyle": "white",
            "navigationBarTitleText": "知乎"
        }
    }
}