写了一个 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...

相关推荐
陈无左耳、35 分钟前
HarmonyOS学习第4天: DevEco Studio初体验
学习·华为·harmonyos
月未央3 小时前
HarmonyOS Next 开发系列:Local 状态管理实践
harmonyos
openinstall全渠道统计15 小时前
免填邀请码工具:赋能六大核心场景,重构App增长新模型
android·ios·harmonyos
shaodong112316 小时前
鸿蒙系统-同应用跨设备数据同步(分布式功能)
分布式·华为·harmonyos
敢嗣先锋16 小时前
鸿蒙5.0实战案例:基于ImageKit对图片进行处理
移动开发·harmonyos·arkui·组件化·鸿蒙开发
陈无左耳、16 小时前
HarmonyOS学习第3天: 环境搭建开启鸿蒙开发新世界
学习·华为·harmonyos
敢嗣先锋16 小时前
鸿蒙5.0实战案例:基于ArkUI的验证码实现
移动开发·harmonyos·openharmony·arkui·鸿蒙开发
别说我什么都不会18 小时前
鸿蒙轻内核M核源码分析系列十二 事件Event
操作系统·harmonyos
Huang兄20 小时前
鸿蒙-canvas-刮刮乐
华为·harmonyos
Sharknade20 小时前
鸿蒙-阻塞式文件锁
华为·harmonyos