597鸿蒙

  • 安装库
    title:597项目需要安装的库
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    cd D:\code\Company\HarmonyOS597
    ohpm install ./libiaries/httpclients
    ohpm install ./libiaries/commonlibs

    ohpm install ./datarepos/repoapis
    ohpm install ./datarepos/repocaches
    ohpm install ./datarepos/reporesources

    ohpm install ./features/feature_launcher
    ohpm install ./features/feature_base
    ohpm install ./features/feature_privacy
    ohpm install ./features/feature_webview
    ohpm install ./features/feature_login
    ohpm install ./features/feature_mine
    ohpm install ./features/feature_update

第三方库

自带的库

新增一个模块

  1. feature文件夹下新建一个static Library【如起名feature_report
  2. zhipin>oh-packages.json5dependencies中加"@ohos/featurereport": "file:../../features/feature_report",
  3. zhipin>build-profile.json5packages中加"@ohos/featurereport", 【建议在这加,子模块会自动继承它】
  4. feature_report:新建自定义组件,并加上builder用于接受跳转和跳转的参数
    fold
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    @Builder  
    export function reportComplaintBuilder(value?: object) {
    reportComplaintPage({
    jobId: JSON.parse(JSON.stringify(value))['jobId'],
    cid: JSON.parse(JSON.stringify(value))['cid']
    })
    }

    @Component
    export struct reportComplaintPage {
    @Prop jobId: string = ""
    @Prop cid: string = ""

    build() {
    NavDestination() {
    Column() {
    NormalTitleBar({
    title: "举报投诉",
    onBackClick: () => {
    RouterModule.pop(RouterNameConstants.ENTRY_HAP)
    }
    })
    //其他内容
    }
    } .hideTitleBar(true)
    .padding({
    bottom: (AppStorage.get<number>('naviIndicatorHeight') || 0)
    })
    .height(CommonConstants.FULL_LENGTH)
    .width(CommonConstants.FULL_LENGTH)
    }
    }
  5. feature_report>Index.ets中加harInit方法,并把相关pagebuilder动态注册进来
    fold
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    import lazy { BuilderNameConstants, RouterModule } from '@ohos/featurebase';  
    import { reportComplaintBuilder } from './src/main/ets/components/ReportComplaintPage'

    export function harInit(builderName: string): void {
    //动态引入要跳转的页面
    switch (builderName) {
    case BuilderNameConstants.HAR_REPORT_COMPLAINT:
    RouterModule.addBuilder(builderName, wrapBuilder(reportComplaintBuilder))
    break;
    default:
    break;
    }
    }
  6. 跳转的地方:【在第3步,zhipin的build-profile.json5packages中加过了,所以这个当前模块不用添加】
    fold
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    //跳转到举报页面  
    let object: Object = new Object({
    'jobId': this.bean.resumeJob.jobRow._jid,
    'cid': ''
    })
    buildRouterModel(RouterNameConstants.ENTRY_HAP, BuilderNameConstants.HAR_REPORT_COMPLAINT, object)
    //跳转并把当前页面移除
    buildRouterModel(RouterNameConstants.ENTRY_HAP,BuilderNameConstants.HAR_REPORT_COMPLAINT,object,(info)=>{
    RouterModule.pop(RouterNameConstants.ENTRY_HAP)
    })

    //举报页面返回到上一个页面
    RouterModule.pop(RouterNameConstants.ENTRY_HAP)

    //todo 跳转到首页

可能用到的控件

其他

  • 安卓和iOS快速鸿蒙化步骤 - 掘金

    这篇文章主要介绍了安卓和 iOS 已有项目鸿蒙化的最快方式——模块化开发。包括鸿蒙开发架构图,如分层架构、依赖规则等;还阐述了开发规范、代码规范,涵盖全局工具类方法、组件编码规范、通用原则等;以及应用权限使用原则和版本管理,包括分支命名、更新与发布阶段的规则和问题定位方法。

  • 鸿蒙原生APP性能优化之ArkTS高性能编程【import lazy和动态加载】

公共代码

  • AppPageManager:页面跳转管理类
  • ApiPathManager:网络请求path管理类
  • AppCaches:缓存管理类【在data>app>el2>100>base>hmos.com.xm597.app>haps>zhipin>preferences>appCachesSp
  • BusinessUtils:业务相关工具类
  • CityUtils:城市选择工具类
  • DateFormatUtils:日期格式化
  • ChatUtils:
  • MultiplePicturesUtil:多选图片工具类
  • StringUtils:字符串工具类【字符串数组拼接字段,如“公司·职位·地址”;逗号分割;】
  • SystemUtils:系统工具类【拨打电话;短信;】
  • UrlUtils:Url工具类【加http前缀;例子:UrlUtils.checkAndBuildUrl(this.companyInfo?._logoUrl)】
  • UserInfoUtils:自己相关的信息【个人身份的简历;登录信息;企业身份的企业信息(公司、hr);字典信息】
  • EmitterUtil:事件发送
  • ApiRepoBaseCallback:网络请求日志打印【搜索“597直聘接口请求”】

报错

华为官网:编译构建常见问题
华为官网:故障分析-JS Crash(进程崩溃)
华为官网:故障分析-CppCrash(进程崩溃)
华为官网:故障分析-AppFreeze(应用无响应)
故障类型
故障类型 说明
THREAD_BLOCK_6S 应用主线程卡死超时
APP_INPUT_BLOCK 用户输入响应超时
LIFECYCLE_TIMEOUT Ability生命周期切换超时
LIFECYCLE_TIMEOUT

不同的生命周期,超时的时间不一样:

生命周期 超时时间
Load 10s
Terminate 10s
Connect 3s
Disconnect 0.5s
Foreground 5s
Background 3s
华为官网:故障分析-Resource Leak(资源泄漏)
hvigor ERROR: Failed :zhipin:default@CompileArkTS…

报错信息:

1
2
3
4
5
> hvigor ERROR: Failed :zhipin:default@CompileArkTS... 
> hvigor ERROR: EINVAL: invalid argument, mkdir 'D:\code\Company\HarmonyOS597\products\zhipin\build\default\cache\default\default@CompileArkTS\esmodule\debug\?'
...
> COMPILE RESULT:FAIL {ERROR:1 WARN:312}
> hvigor ERROR: BUILD FAILED in 1 min 17 s 858 ms
  1. 尝试DevEco》Settings》OpenHarmonySDK》安装API Version12>ArkTSJS,未解决
  2. 尝试删除项目zhipin下build、preview、oh_modules,未解决
  3. 卸载DevEco Studio,删除本地SDK、OpenHarmonySDK、Emulator,重新安装DevEco Studio(装到另一个盘了)重新设置Sdk、OpenHarmonySDK、Emulator路径,解决!!!

    OpenHarmonySDK路径:在DevEco StudioSettings中查看
    SDK路径:在DevEco StudioDevice ManagerNew Emulator界面查看
    模拟器安装路径:在DevEco StudioDevice Manager界面查看

    SourceMap is not initialized yet

    报错信息:

    1
    SourceMap is not initialized yet 

    clean了项目重新运行。报

    1
    2
    App Launch
    Failed to get the device apiVersion.

    抹除模拟器数据wrap user data,在DevEco Studio/sdk/default/openharmony/toolchains/下执行命令行hdc kill -r,重新运行模拟器,解决

    cannot find record ‘&@umeng/common/Index&1.1.1’

    报错信息:【未处理】

    1
    cannot find record '&@umeng/common/Index&1.1.1'

    按友盟文档接入,报上面的错误,在entry/oh-package.json5"main": "",改为 "main": "Index.ets",未能解决

    ability:ZhipinAbility load timeout.

    报错信息【未处理】

    1
    2
    3
    4
    5
    6
    7
    ability:ZhipinAbility load timeout.
    ...
    /proc/transaction_proc : file isn't exists
    ...
    catcher cmd: hilog -z 1000 -P
    ...