OpenHarmony三方组件:UtilCode

Handpc
发布于 2023-3-17 09:59
浏览
0收藏

OpenHarmonyUtilCode library is a ETS Library that supports common utility functions like Clean Utility(Cleaning the Cache, files and application data), Location utility services (Commonly used location based services), Etc.

Installation Instructions

npm i '@ohos/utilcode'

Details about OpenHarmony NPM environment configuration, see ​​here​

Clean Utils

Clean Utils is Open Harmony ETS Library that performs cleaning operations of an application and its data. Clean Utils can perform the following:

  • Cleaning the Internal Cache
  • Cleaning all the files of the application
  • Cleaning the custom directory of an application
  • Cleaning all databases of an application
  • Cleaning a custom database
  • Cleaning the Shared Preferences

Importing Clean Utils

import { CleanUtils } from '@ohos/utilcode';

CleanUtils Usage

//Creating Object    private cleanutils: CleanUtils = new CleanUtils();
 
//function usage
this.cleanutils.cleanInternalCache().then((path) => { .. })
this.cleanutils.cleanInternalFiles().then((path) => { .. })
this.cleanutils.cleanInternalSp().then((path) => { .. })
this.cleanutils.cleanInternalDbByName(dbName).then((name) => { .. })
this.cleanutils.cleanInternalDbs().then((path) => { .. })
this.cleanutils.cleanCustomDir(dirName).then((name) => { .. })

Directory Structure

|---- UtilCode
|     |---- entry  #Sample Code Folder
|           |---- src
|                 |---- main
|                       |---- ets
|                             |---- MainAbility
|                                   |---- pages
|                                          |---- CleanUtilsSample.ets
|                                          |---- index.ets
|                                          |---- LocationUtilsSample.ets
|     |---- utilcode  #utility library
|           |---- src
|                 |---- main
|                       |---- ets
|                             |---- utils
|                                   |---- CleanUtils.ets
|                                   |---- LocationUtils.ets
|           |---- index.ets

Compatibility

Supports OpenHarmony API Version 8

Code Contribution

If you find any problems during usage, you can submit an ​​Issue​​​ to us. Of course, we also welcome you to send us ​​PR​​.

Open source License

This project is based on ​​Apache License 2.0​​ ,please enjoy and participate in open source freely.



文章转载自:​​https://gitee.com/openharmony-tpc/UtilCode​


分类
UtilCode-master.zip 62.04K 0次下载
收藏
回复
举报
回复
    相关推荐