HarmonyOS NEXT - Stage模型和应用/组件级配置

Stage模型 随着系统的演进发展,HarmonyOS先后提供了两种应用模型:

  • FA(Feature Ability)模型:从API 7开始支持的模型,已经不再主推。
  • Stage模型:从API 9开始新增的模型,是目前主推且会长期演进的模型。在该模型中,由于提供了AbilityStage、WindowStage等类作为应用组件和Window窗口的“舞台”,因此称这种应用模型为Stage模型。

UIAbility组件是一种包含UI界面的应用组件,主要用于和用户交互。

  • UIAbility组件是系统调度的基本单元,为应用提供绘制界面的窗口;
  • 一个UIAbility组件中可以通过多个页面来实现一个功能模块;
  • 每一个UIAbility组件实例,都对应于一个最近任务列表中的任务。

一个应用可以有一个UIAbility,也可以有多个UIAbility。

应用/组件级配置 应用图标、应用标签的配置文件:AppScope/app.json5

{
  "app": {
    "bundleName": "com.helloworld.example",
    "vendor": "example",
    "versionCode": 1000000,
    "versionName": "1.0.0",
    "icon": "$media:layered_image",
    "label": "$string:app_name"
  }
}

入口图标、入口标签的配置文件:entry/src/main/module.json5

{
  "module": {
    "name": "entry",
    "type": "entry",
    "description": "$string:module_desc",
    "mainElement": "EntryAbility",
    "deviceTypes": [
      "phone",
      "tablet",
      "2in1"
    ],
    "deliveryWithInstall": true,
    "installationFree": false,
    "pages": "$profile:main_pages",
    "abilities": [
      {
        "name": "EntryAbility",
        "srcEntry": "./ets/entryability/EntryAbility.ets",
        "description": "$string:EntryAbility_desc",
        "icon": "$media:layered_image",
        "label": "$string:EntryAbility_label",
        "startWindowIcon": "$media:startIcon",
        "startWindowBackground": "$color:start_window_background",
        "exported": true,
        "skills": [
          {
            "entities": [
              "entity.system.home"
            ],
            "actions": [
              "action.system.home"
            ]
          }
        ]
      }
    ],
    "extensionAbilities": [
      {
        "name": "EntryBackupAbility",
        "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
        "type": "backup",
        "exported": false,
        "metadata": [
          {
            "name": "ohos.extension.backup",
            "resource": "$profile:backup_config"
          }
        ]
      }
    ]
  }
}

应用图标:app.icon 应用标签:app.label 入口图标:module.abilities.icon 入口标签:module.abilities.label

注意:如果配置了入口图标和入口标签,则应用图标和应用标签会被覆盖。 但实际上,不配置入口图标和入口标签会报错,说明应用图标和应用标签会被入口图标和入口标签覆盖。

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务