鸿蒙5.0开发进阶:一次开发,多端部署之典型页面场景(应用市场首页)

【鸿蒙开发教程】HarmonyOS Next 页面路由 即 Navigation + NavPathStack + navDestination// 主页用Navigation// 子页面用 NavDestination})有很多小伙伴不知道该从哪里开始学习鸿蒙开发技术?也不知道鸿蒙开发的知识点重点掌握的又有哪些?自学时频繁踩坑,导致浪费大量时间。结果还是一知半解。所以有一份实用的鸿蒙(HarmonyOS NEXT)全栈开发资料用来跟着学习是非常有必要的。这份鸿蒙(HarmonyOS NEXT)资料包含了鸿蒙开发必掌握的核心知识要点,内容包含了。 阅读详情

往期鸿蒙5.0全套实战文章必看:(文中附带全栈鸿蒙5.0学习资料)


应用市场首页

本文将以应用市场首页为例,介绍如何使用自适应布局能力和响应式布局能力适配不同尺寸窗口。

页面设计

一个典型的应用市场首页的UX设计如下所示。

smmdlg

观察应用市场首页的页面设计,不同断点下的页面设计有较多相似的地方。

据此,我们可以将页面分拆为多个组成部分。

  1. 底部/侧边导航栏

  2. 标题栏与搜索栏

  3. 运营横幅

  4. 快捷入口

  5. 精品应用

smmdlg

接下来我们逐一分析各部分的实现。

底部/侧边导航栏

在sm和md断点下,导航栏在底部;在lg断点下,导航栏在左侧。可以通过Tab组件的barPosition和vertical属性控制TabBar的位置,同时还可以通过barWidth和barHeight属性控制TabBar的尺寸。

//BreakpointSystem.ets
import mediaQuery from '@ohos.mediaquery'

export default class BreakpointSystem {
  private currentBreakpoint: string = 'md'
  private smListener?: mediaQuery.MediaQueryListener
  private mdListener?:mediaQuery.MediaQueryListener
  private lgListener?: mediaQuery.MediaQueryListener

  private updateCurrentBreakpoint(breakpoint: string) {
    if (this.currentBreakpoint !== breakpoint) {
      this.currentBreakpoint = breakpoint
      AppStorage.Set<string>('currentBreakpoint', this.currentBreakpoint)
    }
  }

  private isBreakpointSM = (mediaQueryResult:mediaQuery.MediaQueryResult) => {
    if (mediaQueryResult.matches) {
      this.updateCurrentBreakpoint('sm')
    }
  }

  private isBreakpointMD = (mediaQueryResult:mediaQuery.MediaQueryResult) => {
    if (mediaQueryResult.matches) {
      this.updateCurrentBreakpoint('md')
    }
  }

  private isBreakpointLG = (mediaQueryResult:mediaQuery.MediaQueryResult) => {
    if (mediaQueryResult.matches) {
      this.updateCurrentBreakpoint('lg')
    }
  }

  public register() {
    this.smListener = mediaQuery.matchMediaSync('(320vp<=width<600vp)')
    this.smListener.on('change', this.isBreakpointSM)
    this.mdListener = mediaQuery.matchMediaSync('(600vp<=width<840vp)')
    this.mdListener.on('change', this.isBreakpointMD)
    this.lgListener = mediaQuery.matchMediaSync('(840vp<=width)')
    this.lgListener.on('change', this.isBreakpointLG)
  }

  public unregister() {
    this.smListener?.off('change', this.isBreakpointSM)
    this.mdListener?.off('change', this.isBreakpointMD)
    this.lgListener?.off('change', this.isBreakpointLG)
  }
}
import Home from '../common/Home'; //组件请参考相关实例
import TabBarItem from '../common/TabBarItem';
import BreakpointSystem from '../common/BreakpointSystem'

@Entry
@Component
struct Index {
  @State currentIndex: number = 0
  @StorageProp('currentBreakpoint') currentBreakpoint: string = 'md'
  private breakpointSystem: BreakpointSystem = new BreakpointSystem()
  private onTabChange = (index: number) => {
    this.currentIndex = index
  }

  aboutToAppear() {
    this.breakpointSystem.register()
  }

  aboutToDisappear() {
    this.breakpointSystem.unregister()
  }

  @Builder
  tabItem(index: number, title: Resource, icon: Resource, iconSelected: Resource) {
    TabBarItem({
      index: index,
      currentIndex: this.currentIndex,
      title: title,
      icon: icon,
      iconSelected: iconSelected
    })
  }

  build() {
    // 设置TabBar在主轴方向起始或结尾位置
    Tabs({ barPosition: this.currentBreakpoint === "lg" ? BarPosition.Start : BarPosition.End }) {
      // 首页
      TabContent() {
        Home()
      }
      .tabBar(this.tabItem(0, $r('app.string.tabBar1'), $r('app.media.ic_home_normal'),
        $r('app.media.ic_home_actived')))

      TabContent() {
      }.tabBar(this.tabItem(1, $r('app.string.tabBar2'), $r('app.media.ic_app_normal'), $r('app.media.ic_app_actived')))

      TabContent() {
      }
      .tabBar(this.tabItem(2, $r('app.string.tabBar3'), $r('app.media.ic_game_normal'),
        $r('app.media.ic_mine_actived')))

      TabContent() {
      }
      .tabBar(this.tabItem(3, $r('app.string.tabBar4'), $r('app.media.ic_search_normal'),
        $r('app.media.ic_search_actived')))

      TabContent() {
      }
      .tabBar(this.tabItem(4, $r('app.string.tabBar4'), $r('app.media.ic_mine_normal'),
        $r('app.media.ic_mine_actived')))
    }
    .backgroundColor('#F1F3F5')
    .barMode(BarMode.Fixed)
    .barWidth(this.currentBreakpoint === "lg" ? 96 : '100%')
    .barHeight(this.currentBreakpoint === "lg" ? '60%' : 56)
    // 设置TabBar放置在水平或垂直方向
    .vertical(this.currentBreakpoint === "lg")
  }
}

另外在sm及lg断点下,TabBar中各个Item的图标和文字是按照垂直方向排布的,在md断点下,TabBar中各个Item的图标和文字是按照水平方向排布的。

interface GeneratedObjectLiteralInterface_1 {
  NORMAL: string;
  SELECTED: string;
}

const TitleColor: GeneratedObjectLiteralInterface_1 = {
  NORMAL: '#999',
  SELECTED: '#0A59F7'
}

@Component
export default struct TabBarItem {
  @StorageProp('currentBreakpoint') currentBreakpoint: string = 'md'
  @Prop currentIndex: number
  private index?:number
  private icon?:Resource
  private iconSelected?:Resource
  private title?:Resource

  private getIcon() {
    return this.currentIndex === this.index ? this.iconSelected : this.icon
  }

  private getFontColor() {
    return this.currentIndex === this.index ? TitleColor.SELECTED : TitleColor.NORMAL
  }

  build() {
    if (this.currentBreakpoint !== 'md' ) {
      Column() {
        Image(this.getIcon())
          .width(24)
          .height(24)
          .margin(5)
          .objectFit(ImageFit.Contain)
        Text(this.title)
          .fontColor(this.getFontColor())
          .fontSize(12)
          .fontWeight(500)
      }.justifyContent(FlexAlign.Center).height('100%').width('100%')
    } else {
      Row() {
        Image(this.getIcon())
          .width(24)
          .height(24)
          .margin(5)
          .objectFit(ImageFit.Contain)
        Text(this.title)
          .fontColor(this.getFontColor())
          .fontSize(12)
          .fontWeight(500)
      }.justifyContent(FlexAlign.Center).height('100%').width('100%')
    }
  }
}

标题栏与搜索栏

标题栏和搜索栏,在sm和md断点下分两行显示,在lg断点下单行显示,可以通过栅格实现。在sm和md断点下,标题栏和搜索栏占满12列,此时会自动换行显示。在lg断点下,标题栏占8列而搜索栏占4列,此时标题栏和搜索栏在同一行中显示。

sm/mdlg
效果图

栅格布局图

@Component
export default struct IndexHeader {

  @Builder searchBar() {
    Stack({alignContent: Alignment.End}) {
      TextInput({ placeholder: $r('app.string.search') })
        .placeholderColor('#FF000000')
        .placeholderFont({ size: 16, weight: 400 })
        .textAlign(TextAlign.Start)
        .caretColor('#FF000000')
        .width('100%')
        .height(40)
        .fontWeight(400)
        .padding({ top: 9, bottom: 9 })
        .fontSize(16)
        .backgroundColor(Color.White)

      Image($r('app.media.ic_public_search'))
        .width(16)
        .height(16)
        .margin({ right: 20 })
    }.height(56).width('100%')
  }

  @Builder titleBar() {
    Text($r('app.string.tabBar1'))
      .fontSize(24)
      .fontWeight(500)
      .fontColor('#18181A')
      .textAlign(TextAlign.Start)
      .height(56)
      .width('100%')
  }

  build() {
    // 借助栅格实现标题栏和搜索栏在不同断点下的不同布局效果。
    GridRow() {
      GridCol({ span: { xs: 12, lg: 8 } }) {
        this.titleBar()
      }
      GridCol({ span: { xs: 12, lg: 4 } }) {
        this.searchBar()
      }
    }
    .width('100%')
  }
}

运营横幅

不同断点下的运营横幅,sm断点下显示一张图片,md断点下显示两张图片,lg断点下显示三张图片。

@Component
export default struct IndexSwiper {
  @StorageProp('currentBreakpoint') currentBreakpoint: string = 'md';
  @Builder swiperItem(imageSrc:Resource) {
    Image(imageSrc)
      .width('100%')
      .aspectRatio(2.5)
      .objectFit(ImageFit.Fill)
  }

  build() {
    Swiper() {
      this.swiperItem($r('app.media.ic_public_swiper1'))
      this.swiperItem($r('app.media.ic_public_swiper2'))
      this.swiperItem($r('app.media.ic_public_swiper3'))
      // ...
    }
    .autoPlay(true)
    .indicator(false)
    .itemSpace(10)
    // 配置不同断点下运行横幅中展示的图片数量
    .displayCount(this.currentBreakpoint === 'sm' ? 1 : (this.currentBreakpoint === 'md' ? 2 : 3))
    .width('100%')
    .padding({ left: 12, right: 12, bottom: 16, top: 16 })
  }
}

快捷入口

在不同的断点下,快捷入口的5个图标始终均匀排布,这是典型的均分能力使用场景。图标资源文件获取。

// /model/HomeData   在resourse文件中放置以下资源文件,
interface AppItem{
  id:string;
  title:Resource;
  image:Resource;
}

const appList:AppItem[] = [
  { id: '0', title: $r('app.string.public_app1'), image: $r('app.media.ic_public_app1') },
  { id: '1', title: $r('app.string.public_app2'), image: $r('app.media.ic_public_app2') },
  { id: '2', title: $r('app.string.public_app3'), image: $r('app.media.ic_public_app3') },
  { id: '3', title: $r('app.string.public_app4'), image: $r('app.media.ic_public_app4') },
  { id: '4', title: $r('app.string.public_app5'), image: $r('app.media.ic_public_app5') },
  { id: '5', title: $r('app.string.public_app6'), image: $r('app.media.ic_public_app6') },
  { id: '6', title: $r('app.string.public_app7'), image: $r('app.media.ic_public_app7') },
  { id: '7', title: $r('app.string.public_app8'), image: $r('app.media.ic_public_app8') },
  { id: '8', title: $r('app.string.public_app9'), image: $r('app.media.ic_public_app9') },
  { id: '9', title: $r('app.string.public_app10'), image: $r('app.media.ic_public_app10') },
  { id: '10', title: $r('app.string.public_app1'), image: $r('app.media.ic_public_app1') },
  { id: '11', title: $r('app.string.public_app1'), image: $r('app.media.ic_public_app1') },
  { id: '12', title: $r('app.string.public_app2'), image: $r('app.media.ic_public_app2') },
  { id: '13', title: $r('app.string.public_app3'), image: $r('app.media.ic_public_app3') },
  { id: '14', title: $r('app.string.public_app4'), image: $r('app.media.ic_public_app4') },
  { id: '15', title: $r('app.string.public_app5'), image: $r('app.media.ic_public_app5') },
  { id: '16', title: $r('app.string.public_app6'), image: $r('app.media.ic_public_app6') },
  { id: '17', title: $r('app.string.public_app7'), image: $r('app.media.ic_public_app7') },
  { id: '18', title: $r('app.string.public_app8'), image: $r('app.media.ic_public_app8') },
  { id: '19', title: $r('app.string.public_app9'), image: $r('app.media.ic_public_app9') },
  { id: '20', title: $r('app.string.public_app10'), image: $r('app.media.ic_public_app10') }
]

const gameList:AppItem[] = [
  { id: '21', title: $r('app.string.public_game1'), image: $r('app.media.ic_public_game1') },
  { id: '22', title: $r('app.string.public_game2'), image: $r('app.media.ic_public_game2') },
  { id: '23', title: $r('app.string.public_game3'), image: $r('app.media.ic_public_game3') },
  { id: '24', title: $r('app.string.public_game4'), image: $r('app.media.ic_public_game4') },
  { id: '25', title: $r('app.string.public_game5'), image: $r('app.media.ic_public_game5') },
  { id: '26', title: $r('app.string.public_game6'), image: $r('app.media.ic_public_game6') },
  { id: '27', title: $r('app.string.public_game7'), image: $r('app.media.ic_public_game7') },
  { id: '28', title: $r('app.string.public_game8'), image: $r('app.media.ic_public_game8') },
  { id: '29', title: $r('app.string.public_game9'), image: $r('app.media.ic_public_game9') },
  { id: '30', title: $r('app.string.public_game10'), image: $r('app.media.ic_public_game10') },
  { id: '31', title: $r('app.string.public_game1'), image: $r('app.media.ic_public_game1') },
  { id: '32', title: $r('app.string.public_game2'), image: $r('app.media.ic_public_game2') },
  { id: '33', title: $r('app.string.public_game3'), image: $r('app.media.ic_public_game3') },
  { id: '34', title: $r('app.string.public_game4'), image: $r('app.media.ic_public_game4') },
  { id: '35', title: $r('app.string.public_game5'), image: $r('app.media.ic_public_game5') },
  { id: '36', title: $r('app.string.public_game6'), image: $r('app.media.ic_public_game6') },
  { id: '37', title: $r('app.string.public_game7'), image: $r('app.media.ic_public_game7') },
  { id: '38', title: $r('app.string.public_game8'), image: $r('app.media.ic_public_game8') },
  { id: '39', title: $r('app.string.public_game9'), image: $r('app.media.ic_public_game9') },
  { id: '40', title: $r('app.string.public_game10'), image: $r('app.media.ic_public_game10') }
]

const entranceIcons:AppItem[]= [
  { id: '41',title: $r('app.string.home_categories'), image: $r('app.media.ic_home_categories') },
  { id: '42',title: $r('app.string.home_top'), image: $r('app.media.ic_home_top') },
  { id: '43',title: $r('app.string.home_fast'), image: $r('app.media.ic_home_fast') },
  { id: '44',title: $r('app.string.home_flower'), image: $r('app.media.ic_home_flower') },
  { id: '45',title: $r('app.string.home_education'), image: $r('app.media.ic_home_education') },
]

export { entranceIcons, appList, gameList }
//model/HomeDataType
interface AllIcons {
  image: Resource,
  title: Resource,
}

interface AppItem  {
  id: string,
  title: Resource,
  image: Resource
}

class MyAppSource implements IDataSource {
  private dataArray: AppItem[] = []
  private listeners: DataChangeListener[] = []

  constructor(element: AppItem[]) {
    for (let index = 0; index < element.length; index++) {
      this.dataArray.push(element[index])
    }
  }

  public totalCount(): number {
    return this.dataArray.length
  }

  public getData(index: number): AppItem {
    return this.dataArray[index]
  }

  public addData(index: number, data: AppItem): void {
    this.dataArray.splice(index, 0, data)
    this.notifyDataAdd(index)
  }

  public pushData(data: AppItem): void {
    this.dataArray.push(data)
    this.notifyDataAdd(this.dataArray.length - 1)
  }

  registerDataChangeListener(listener: DataChangeListener): void {
    if (this.listeners.indexOf(listener) < 0) {
      this.listeners.push(listener)
    }
  }

  unregisterDataChangeListener(listener: DataChangeListener): void {
    const pos = this.listeners.indexOf(listener);
    if (pos >= 0) {
      this.listeners.splice(pos, 1)
    }
  }

  notifyDataReload(): void {
    this.listeners.forEach(listener => {
      listener.onDataReloaded()
    })
  }

  notifyDataAdd(index: number): void {
    this.listeners.forEach(listener => {
      listener.onDataAdd(index)
    })
  }

  notifyDataChange(index: number): void {
    this.listeners.forEach(listener => {
      listener.onDataChange(index)
    })
  }

  notifyDataDelete(index: number): void {
    this.listeners.forEach(listener => {
      listener.onDataDelete(index)
    })
  }

  notifyDataMove(from: number, to: number): void {
    this.listeners.forEach(listener => {
      listener.onDataMove(from, to)
    })
  }
}

export { AllIcons, MyAppSource, AppItem }
import { entranceIcons } from '../model/HomeData';
import { AllIcons } from '../model/HomeDataType';

@Component
export default struct IndexEntrance {
  build() {
    // 将justifyContent参数配置为FlexAlign.SpaceEvenly实现均分布局
    Row() {
      ForEach(entranceIcons, (icon: AllIcons) => {
        // 各快捷入口的图标及名称
        Column() { 
          // ... 
          }
      })
    }
    .width('100%')
    .height(64)
    .justifyContent(FlexAlign.SpaceEvenly)
    .padding({ left: 12, right: 12 })
  }
}

精品应用

随着可用显示区域的增加,精品应用中显示的图标数量也不断增加,这是典型的延伸能力使用场景。精品游戏的实现与精品应用类似,不再展开分析。

import { AppItem, MyAppSource } from '../model/HomeDataType';

@Component
export default struct IndexApps {
  private title?: Resource;
  @StorageProp('currentBreakpoint') currentBreakpoint: string = 'md';
  private apps: AppItem[] = [];
  @Builder
  appListHeader() {
    Row() {
      Text(this.title)
        .width(100)
        .fontSize(16)
        .textAlign(TextAlign.Start)
        .fontWeight(500)
      Blank()
      Text($r('app.string.more'))
        .fontSize(14)
        .textAlign(TextAlign.End)
        .fontWeight(400)
        .margin({ right: 2 })
      Image($r('app.media.ic_public_arrow_right'))
        .width(12)
        .height(18)
        .opacity(0.9)
        .objectFit(ImageFit.Fill)
    }
    .margin({ bottom: 9, top: 9 })
    .width('100%')
    .alignItems(VerticalAlign.Bottom)
  }

  @Builder
  appListItem(app:AppItem) {
    Column() {
      Image(app.image)
        .width(this.currentBreakpoint === 'lg' ? 80 : 56)
        .height(this.currentBreakpoint === 'lg' ? 80 : 56)
        .margin({ bottom: 8 })
      Text(app.title)
        .width(this.currentBreakpoint === 'lg' ? 80 : 56)
        .height(16)
        .fontSize(12)
        .textAlign(TextAlign.Center)
        .fontColor('#18181A')
        .margin({ bottom: 8 })
      Text($r('app.string.install'))
        .width(this.currentBreakpoint === 'lg' ? 80 : 56)
        .height(28)
        .fontColor('#0A59F7')
        .textAlign(TextAlign.Center)
        .borderRadius(this.currentBreakpoint === 'lg' ? 26 : 20)
        .fontWeight(500)
        .fontSize(12)
        .padding({ top: 6, bottom: 6, left: 8, right: 8 })
        .backgroundColor('rgba(0,0,0,0.05)')
    }
  }
  build() {
    Column() {
      this.appListHeader()
      // 借助List组件能力,实现延伸能力场景
      List({ space: this.currentBreakpoint === 'lg' ? 44 : 20}) {
        LazyForEach(new MyAppSource(this.apps), (app: AppItem)=> {
          ListItem() {
            // 每个应用的图标、名称及安装按钮
            this.appListItem(app)
          }
        })
      }
      .width('100%')
      .height(this.currentBreakpoint === 'lg' ? 140 : 120)
      .listDirection(Axis.Horizontal)
    }
    .width('100%')
    .height(this.currentBreakpoint === 'lg' ? 188 : 164)
    .padding({ bottom: 8, left: 12, right: 12 })
  }
}

运行效果

将上述各页面主要部分组合在一起后,即可完成整体页面开发。

entry/src/main/ets                         // 代码区
|---model
|   |---HomeData.ets                       // 主页用到的图片资源
|   |---HomeDataType.ets                   // 事件监听函数
|---pages                                  
|   |---index.ets                          // 首页
|---common                                    
|   |---BreakpointSystem.ets               // 媒体查询
|   |---Home.ets                           // 主容器
|   |---IndexApps.ets                      // app模块(包含安装,展示图片,更多功能)
|   |---IndexContent.ets                   // 内容模块
|   |---IndexEntrance.ets                  // 下一步模块(箭头跳转组件)
|   |---IndexHeader.ets                    // 头部组件
|   |---IndexSwiper.ets                    // 轮播图   
|   |---TabBarItem.ets                     // 导航栏     
entry/src/main/resources                   // 资源文件
import IndexSwiper from './IndexSwiper';
import IndexEntrance from './IndexEntrance';
import IndexApps from './IndexApps';
import { appList, gameList } from '../model/HomeData';
import IndexHeader from './IndexHeader';

@Component
struct IndexContent {
  // ...
  build() {
    List() {
      // 运营横幅
      ListItem() {
        IndexSwiper()
      }
      // 快捷入口
      ListItem() {
        IndexEntrance()
      }
      // 精品应用
      ListItem() {
        IndexApps({ title: $r('app.string.boutique_application'), apps: appList })
      }
      // 精品游戏
      ListItem() {
        IndexApps({ title: $r('app.string.boutique_game'), apps: gameList })
      }
    }
    .width("100%")
  }
}

@Entry
@Component
export default struct Home {
  // ...
  build() {
    Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) {
      // 标题栏和搜索栏
      IndexHeader()
      // 运营横幅、快捷入口、精品应用、精品游戏等
      IndexContent()
    }
    .height('100%')
    .backgroundColor("#F1F3F5")
  }
}

本页面的实际运行效果如下图所示。

smmdlg

OpenHarmony(鸿蒙南向开发)——子系统开发内核 OpenHarmony的Linux内核基于开源Linux内核LTS分支演进,在此基线基础上,回合CVE补丁及OpenHarmony特性,作为OpenHarmony Common Kernel基线。针对不同的芯片,各厂商合入对应的板级驱动补丁,完成对OpenHarmony的基线适配。Linux社区LTS 4.19.y分支信息请查看kernel官网。Linux社区LTS 5.10.y分支信息请查看kernel官网。 阅读详情

相关推荐

OpenHarmony(鸿蒙南向开发)——标准系统内核(Linux)

标准系统类设备是面向应用处理器的设备,支持的设备最小内存为128MiB。OpenHarmony选择Linux内核作为基础内核,可以对不同资源受限的设备产品配置出适合的OS内核,为上层提供基础的操作系统能力。

maniuT的博客 3252

OpenHarmony与HarmonyOS联系与区别

OpenHammony是由开放原子开源基金会(OpenAtom Foundation)孵化及运营的,开源项目么,开放原子开源基金会由华为、阿里、腾讯、百度、浪潮、招商银行、360等十家互联网企业共同发起组建。目标是面向全场景、全连接、全智能时代,基于开源的方式,搭建-个智能终端设备操作系统的框架和平台,促进万物互联产业的繁荣发展。

qq_40207692的博客 1753

华为鸿蒙系统全景解读:从内核设计到生态落地的技术革命

分布式思维:理解设备虚拟化、服务原子化等概念多范式开发能力:掌握声明式UI、响应式编程等新范式性能调优经验:熟悉跨设备资源调度策略学习路径建议阶段1:掌握ArkTS语言基础(2周)阶段2:理解分布式能力(3周)阶段3:实战复杂项目开发(6周)

我是 二川兄,对Web开发、GIS开发、3D模型、机器学习、面试技巧等方面都有一些涉猎~ 欢迎您加入技术交流圈!你可以在我的文章末尾找到我~ 7981

鸿蒙HarmonyOS和OpenHarmony傻傻分不清?

OpenHarmony的这个“发动机”是开源的,这意味着其他厂商可以自由地拿去,根据自己的需求安装到自己的“车身”上,可能是大型SUV,也可能是小型经济车,还可以对“发动机”进行调校,以适应不同的性能需求。想象一下,HarmonyOS就像是华为生产的一辆完整的汽车,这辆汽车设计精良,内饰豪华,功能齐全,有自家的导航系统,智能联网功能等,而且它是专门为特定消费者群体设计的,比如销售给华为手机用户,或者与特定的硬件和服务搭配使用。我们可以把HarmonyOS和OpenHarmony的关系比作汽车和发动机。

weixin_42082058的博客 1498

《HarmonyOS实战——前端开发华为鸿蒙系统应用 OpenHarmony JS》

导读:一款“面向未来”、面向全场景(移动办公、运动健康、社交通信、媒体娱乐等)的分布式操作系统 。现已开源,名为 OpenHarmony。2019 年 8 月 9 日,华为在 HDC 开发...

孙叫兽的博客 1万+

【半桥LLC】半桥LLC谐振开环闭环软启动DCDC变换器的设计与仿真

本文详细分析了半桥LLC谐振DC-DC变换器的开环与闭环控制设计原理,重点探讨了软启动功能的实现。通过仿真验证,展示了开环与闭环情况下的电压输出差异以及系统效率的提升。该研究为提高DC-DC变换器性能提供了参考。

2401_84610415的博客 2599

【华为鸿蒙系统学习】- HarmonyOS4.0开发|自学篇

本篇博客主要介绍了华为的鸿蒙系统(HarmonyOS4.0)的发布,三大特征,技术架构,技术特性

“路漫漫其修远兮,吾将上下求索。” 2万+

ORCA(动态避障)算法

A物体沿着向量v1和v2移动,刚好能和B擦肩而过,不会发生碰撞;若V1和V2的夹角再小一点的话就一定会发生碰撞。A的速度为V1,B的速度为V2,A对于B的相对速度(也就是我们把B看做静止,A的速度)就是V1-V2。,那么怎么判定A的速度向量是不是在碰撞区域内呢?这就需要用A相对于B的速度来判定。红线画出来的锥形区域就是A相对于B的。

u012861978的专栏 4769

鸿蒙OS开发:典型页面场景【一次开发,多端部署】实战(应用市场首页)

本示例展示了应用市场首页,页面中包括Tab栏、运营横幅、精品应用、精品游戏等。

鸿蒙的技术博客 1568

433M遥控器无线解码1527协议

433M遥控器无线解码1527协议,定时器轮询法

weixin_58595117的博客 1万+

FFmpeg + OBS 低延迟直播串流实战:从H264裸流到RTP组播的完整配置

本文详细介绍了如何利用FFmpeg将H264裸流转码为RTP协议,并通过组播技术实现与OBS客户端的超低延迟直播串流。文章深入剖析了FFmpeg关键参数调优、SDP文件生成与配置,以及OBS客户端的无缝拉流方法,为需要毫秒级实时交互的场景提供了一套去中心化、高效稳定的完整解决方案。

fanta的博客 830

鸿蒙APP架构及开发入门

鸿蒙介绍与开发指南

三翼鸟数字化平台的技术实践分享 3552

【Pandas总结】第二节 Pandas 的数据读取_pd.read_csv()的使用详解(非常全面,推荐收藏)

pandas对纯文本的读取提供了非常强力的支持,参数有四五十个。这些参数中,有的很容易被忽略,但是在实际工作中却用处很大。

weixin_47139649的博客 11万+

华为鸿蒙系统HarmonyOS学习之九:鸿蒙HarmonyOS发展史与未来

华为鸿蒙系统HarmonyOS学习之九:鸿蒙的HarmonyOS发展史与未来

jyl_sh的专栏 1万+

《UDS协议从入门到精通》系列——图解0x38:请求文件传输

详细解释UDS协议中0x38-请求上传服务的各个参数!!

车载系统攻城狮 3271

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

鸿蒙5.0&next开发【页面开发:典型布局场景】一次开发多端部署

虽然不同应用的页面千变万化,但对其进行拆分和分析,页面中的很多布局场景是相似的。本小节将介绍如何借助自适应布局、响应式布局以及常见的容器类组件,实现应用中的典型布局场景。

bbq的博客 1088

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

鸿蒙5.0开发进阶:一次开发,多端部署之典型页面场景(设置应用页面)

介绍如何使用自适应布局能力和响应式布局能力适配不同尺寸窗口。

Androidbye的博客 1282

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

0 基础入门鸿蒙:跟着《HarmonyOS 第一课》1 周掌握应用开发核心能力

这篇文章介绍了《HarmonyOS 第一课》课程的完整学习路径和体验感受,适合零基础开发者入门鸿蒙开发。主要内容包括: 课程分为基础、中级、高级三阶段,共24门课,涵盖从环境搭建到应用上架的全流程 基础阶段学习ArkTS语言和ArkUI框架,中级阶段掌握复杂功能开发,高级阶段学习跨设备协同等鸿蒙特色能力 课程优势:全链路覆盖、80%实战内容、紧跟鸿蒙最新特性,并提供配套资源和答疑支持 给零基础学习者的建议:保持每天1-2小时学习节奏,边学边改代码,善用调试工具解决问题 文章通过作者亲身体验,展示了如何从零开

科技改变人类,技术成就未来 3万+

华为鸿蒙系统

华为鸿蒙系统 华为鸿蒙系统(英文:huaweiHarmonyOS,HongmengOS)。在2019年8月9日,华为在东莞举行华为开发者大会,正式发布操作系统鸿蒙OS。 鸿蒙OS是一款“面向未来”的操作系统,一款基于微内核的面向全场景的分布式操作系统,现已适配智慧屏,未来它将适配手机、平板、电脑、智能汽车、可穿戴设备等多终端设备。 2020年9月10日,华为鸿蒙系统升级至华为鸿蒙系统2.0版本 。华为鸿蒙系统2.0通过跨设备协同、大小屏互动、极速配网、自适应 UX、可视可说 AI 赋能语音交互、开发者开

一个踩这七色彩虹的路人甲 6336

【鸿蒙 5.0 实战开发】一次开发多端部署开发实例(股票类)

本文从目前流行的垂类市场中,选择股票类应用作为典型案例,详细介绍 “一多 在实际开发中的应用。主要包含首页、资讯、自选股、个股详情、行情等9个典型页面。核心功能:分栏布局:分栏布局通过 Navigation 实现,在断点为lg时设置mode属性为NavigationMode.Stack,实现单栏效果,在其他断点下设置mode属性为NavigationMode.Split,实现分栏效果。宫格卡片 的多股同列:用网格布局 Grid组件 ,在不同断点下将父组件分为不同列数,来实现自适应布局的占比能力。

xiaolizibie的博客 879

【鸿蒙 5.0 实战开发】一次开发多端部署开发实例(商务办公)

本文从目前流行的垂类市场中,选择商务办公类应用作为典型案例,详细介绍 “一多” 在实际开发中的应用。主要包含入口、备忘录、笔记汇总、笔记、日历等典型页面。核心功能:侧边栏显隐 :监听断点变化,设置 SideBarContainer组件 的SideBarContainerType属性或改变showSideBar属性参数,实现侧边栏根据不同断点显示隐藏及显示类型的变化。

xiaolizibie的博客 1104

基于鸿蒙系统的刷题app开发

鸿蒙系统如今已初具规模,其意义不单是取代现有的安卓等主流操作系统,而是打造一个可以分布于多个终端、智能设备并使其互相联动的“万物互联”的操作系统。当前鸿蒙缺乏软件生态,特别是缺乏体现鸿蒙多端联动这一特点,并具有趣味性和实用性的应用。 本文描述了鸿蒙的开发环境DevEco Studio 3.1和采用Java进行开发的框架,阐述了鸿蒙应用的特点、组成,根据官方文档提供的API信息以及所需权限等,进行应用开发,在模拟器、真机上进行软件功能的不断调试与优化。

weixin_45673637的博客 3451

鸿蒙5.0开发进阶:一次开发,多端部署(典型布局场景)

本文将介绍如何借助自适应布局、响应式布局以及常见的容器类组件,实现应用中的典型布局场景。

Androidbye的博客 761

【鸿蒙 5.0 实战开发】一次开发多端部署开发实例(即时通讯)

本文从目前流行的垂类市场中,选择即时通讯应用作为典型案例详细介绍 “一多” 在实际开发中的应用。一多即时通讯应用的核心功能为用户交互,主要包含对话聊天、通讯录,社交圈等交互功能。开发者在开发"一多"应用时,经常会遇见多端适配上的问题,本文选择了即时通讯应用的一个常见问题,提供了推荐的解决方案,开发者在"一多"开发中遇见同类问题时可以快速解决。聊天场景如何进行布局设计。

xiaolizibie的博客 1146
上一篇: 鸿蒙5.0开发进阶:一次开发,多端部署(典型布局场景)
下一篇: 鸿蒙5.0开发进阶:一次开发,多端部署之典型页面场景(音乐专辑页)
懂你的大海
博客等级 码龄6年 9049粉丝 1381原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值