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

相关推荐
柠落少女24401 小时前
React Native 全能商城应用实现与鸿蒙跨端适配深度解析
react native·华为·harmonyos
2501_919749031 小时前
华为鸿蒙图片像素工具APP—小羊像素
华为·harmonyos·鸿蒙
见山是山-见水是水2 小时前
鸿蒙版 Flutter Video 视频播放组件:播放控制、全屏切换与倍速播放
flutter·音视频·harmonyos
HarmonyOS_SDK2 小时前
从启动到畅玩:HarmonyOS SDK如何重塑一场连续的游戏体验
harmonyos
YM52e3 小时前
语言地区选择器-鸿蒙ArkTS国际化页面设计
学习·华为·harmonyos
旭日猎鹰3 小时前
鸿蒙日志采集命令
华为·harmonyos
OH_TPC4 小时前
HarmonyOS APP开发---"商品秀"电商App,需要用到这个库
harmonyos
特立独行的猫A4 小时前
Rust+Tauri 调用系统原生能力完全指南:桌面 / Android / iOS / HarmonyOS
harmonyos
柠落少女24406 小时前
HarmonyOS ArKTS API 24深度
react native·华为·harmonyos
思维新观察7 小时前
装机突破8000万台!鸿蒙有望冲刺年度1亿台目标
华为·harmonyos