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

相关推荐
0***1418 分钟前
HarmonyOS系统安全机制
华为·harmonyos
m***D2862 小时前
HarmonyOS在智能家居中的家庭网络
华为·智能家居·harmonyos
S***42802 小时前
HarmonyOS在智能家居中的Huawei HiLink
华为·智能家居·harmonyos
anyup2 小时前
🔥100+ 天,已全面支持鸿蒙!uView Pro 近期更新盘点及未来计划
前端·uni-app·harmonyos
lqj_本人3 小时前
鸿蒙Qt触控疑云:事件传递丢失与坐标偏移修复
qt·华为·harmonyos
t***L2666 小时前
HarmonyOS在工业互联网中的边缘计算
华为·边缘计算·harmonyos
A***071712 小时前
HarmonyOS在智能家居中的安防系统
华为·智能家居·harmonyos
爱笑的眼睛1113 小时前
HarmonyOS Scroll滚动容器深度性能优化实践
华为·harmonyos
6***x54515 小时前
HarmonyOS在智能穿戴中的健康提醒
华为·harmonyos
x***J34815 小时前
HarmonyOS在智能车载中的Huawei HiCar
华为·harmonyos