#放码来战.端云一体化开发#HarmonyOS 5 【农民叔叔】26.【端侧工程】关于我们拉起浏览器打开备案官网

鸿花粉H
发布于 2025-6-8 18:26
浏览
0收藏

APP必须工信部备案,且在页面明示备案号,点击可打开工信备案官方网站。

1.新建AboutUsPage.ets文件,build()布局如下:

build() {
    Navigation(){
      Column(){
        Image($r('app.media.icon'))
          .width(216)
          .height(216)
          .margin({ top: 8, bottom: 16 });
        Text('农民叔叔')
          .fontSize(24)
          .fontColor($r('sys.color.ohos_id_color_text_primary'))
          .fontWeight(FontWeight.Medium);
        Text('病虫害诊断专家')
          .fontSize(16)
          .fontColor($r('sys.color.ohos_id_color_text_secondary'))
          .margin({ top: 8 })
        Text('V1.0.0.123')
          .fontSize(12)
          .fontColor($r('sys.color.ohos_id_color_text_secondary'))
          .margin({ top: 12, bottom: 12 })
        Blank()
          .layoutWeight(1)
        // 备案号
        Text('粤ICP备2023123032号-4A')
          .fontColor($r('sys.color.ohos_id_color_text_primary_activated'))
          .fontFamily($r('sys.string.ohos_id_text_font_family_regular'))
          .fontSize($r('sys.float.ohos_id_text_size_body3'))
          .fontWeight(FontWeight.Regular)
          .opacity(0.6)
          .margin({ bottom: 12 })
          .onClick(() => {
            // 浏览器打开工信部备案官网
            const context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
            this.openBrowseUrl(context, 'https://beian.miit.gov.cn/#/home');
          })
      }
      .height('100%')
      .width('100%')
      .justifyContent(FlexAlign.Start)
      .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
      .padding({top:12,bottom:12})
    }
    .hideBackButton(false)
    .title('关于')
    .titleMode(NavigationTitleMode.Mini)

  }

2.拉起手机浏览器,跳转到指定链接的页面

/**
   * 打开浏览器
   * @param context
   * @param url
   */
  openBrowseUrl(context: common.UIAbilityContext, url: string):void{
    let want:Want={
      action:'ohos.want.action.viewData',
      entities:['entity.system.browsable'],
      uri:url
    };
    context.startAbility(want)
      .then(()=>{
        // 打开成功
      })
      .catch((err:BusinessError)=>{
        // 打开失败
      })
  }


收藏
回复
举报
回复
    相关推荐