写了一个 harmony next app 开发demo

华为鸿蒙项目(api11) 具体包含功能如下:

1、网络请求的基础封装(基于axios);

基于 @ohos/axios 实现了网络拦截器,网络解析等功能,封装项目页面多状态(加载中,成功,失败,空数据);

2、全局loading实现

原生的 toast 并不好用,通过添加子窗口的形式,通过事件线或者直接调用

javascript 复制代码
/**
 * 通过创建子窗口来显示Loading弹窗
 */
static createLoadingWindow(stage: window.WindowStage) {
  stage?.createSubWindow('loading_window').then(async win => {
    // 设置子窗口显示的页面
    await win.setUIContent('pages/LoadingPage')
    let d = display.getDefaultDisplaySync()
    let windowClass = stage.getMainWindowSync()
    let area = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
    // 调整子窗口大小,需剔除状态栏和导航栏高度,否则显示内容不居中
    await win.resize(d.width, d.height - area.topRect.height - area.bottomRect.height)
    // 设置半透明效果
    win.setWindowBackgroundColor('#00000000')
  })
}

/**
 * 销毁子窗口来
 */
static async destroyLoadingWindow() {
  let windowClass: window.Window | undefined = undefined;
  try {
    windowClass = window.findWindow('loading_window');
    await windowClass.destroyWindow()
  } catch (_) {

  }
}


/**
 * 显示loading子窗口
 * @param stage stage
 */
static async showLoadingWindow() {
  let windowClass: window.Window | undefined = undefined;
  try {
    windowClass = window.findWindow('loading_window');
    await windowClass.showWindow()
  } catch (exception) {

  }

}

/**
 * 关闭loading子窗口
 * @param stage stage
 */
static async closeLoadingWindow() {
  let windowClass: window.Window | undefined = undefined;
  try {
    windowClass = window.findWindow('loading_window');
    await windowClass.minimize();
  } catch (_) {

  }
}

3、存储工具/权限工具/json,视频播放器封装工具等

4、日历封装可以左右切换/上下切换

具体实现可见 github.com/lijiee/harm...

通过 flutter 鸿蒙分支的 flutter 鸿蒙化地址 github.com/lijiee/flut...

相关推荐
前端不太难18 小时前
鸿蒙 App 的“无状态 System”设计
华为·状态模式·harmonyos
UnicornDev20 小时前
【Flutter x HarmonyOS 6】魔方计时APP——计时逻辑实现
flutter·华为·harmonyos·鸿蒙·鸿蒙系统
AlbertZein1 天前
ImageKnifePro 源码解读:鸿蒙图片加载框架全貌
harmonyos
AlbertZein1 天前
鸿蒙工程化:build-profile.json5 逐字段解析
harmonyos
前端技术2 天前
鸿蒙ArkTS 自定义底部导航栏(Tabs+@Builder 极简实现)
harmonyos·鸿蒙
Swift社区2 天前
为什么“页面跳转”在鸿蒙 PC 上是错误设计?
华为·harmonyos
熬夜敲代码的小N2 天前
鸿蒙PC开发者必备!GitNext深度测评:一站式Git管理工具
git·华为·harmonyos
秋の本名2 天前
第一章 鸿蒙生态架构与开发理念
华为·wpf·harmonyos
Ww.xh2 天前
鸿蒙系统中HTML与Vue集成方案
vue.js·html·harmonyos
前端不太难2 天前
鸿蒙游戏 CI/CD:为什么你还在手动打包?
游戏·ci/cd·harmonyos