您的位置:首页 > 新闻 > 资讯 > 智能小程序开发平台_品牌vi设计包括哪些_站长工具ping_外贸推广方式

智能小程序开发平台_品牌vi设计包括哪些_站长工具ping_外贸推广方式

2025/6/6 9:28:04 来源:https://blog.csdn.net/SophieBryant/article/details/143628285  浏览:    关键词:智能小程序开发平台_品牌vi设计包括哪些_站长工具ping_外贸推广方式
智能小程序开发平台_品牌vi设计包括哪些_站长工具ping_外贸推广方式

前言:鸿蒙实现 APP 清除缓存功能

import { fileIo, storageStatistics } from '@kit.CoreFileKit';
import { CacheInfo } from '../ble/module/CacheInfo';
import { contextConstant } from '@kit.AbilityKit';class ClearCache {//   清理缓存cleanAppCache(context: Context) {// el1加密分区context.getApplicationContext().area = contextConstant.AreaMode.EL1;context.area = contextConstant.AreaMode.EL1;const el1AppCacheDir = context.getApplicationContext().cacheDirconst el1HapCacheDir = context.cacheDir// el2加密分区context.getApplicationContext().area = contextConstant.AreaMode.EL2;context.area = contextConstant.AreaMode.EL2;const el2AppCacheDir = context.getApplicationContext().cacheDirconst el2HapCacheDir = context.cacheDirconst task = [this.clearCacheTask(el1AppCacheDir),this.clearCacheTask(el1HapCacheDir),this.clearCacheTask(el2AppCacheDir),this.clearCacheTask(el2HapCacheDir)]Promise.all(task).then(() => {this.getCache()})}clearCacheTask(dir: string): Promise<boolean> {return new Promise((resolve) => {fileIo.access(dir).then((exist: boolean) => {if (exist) {fileIo.rmdir(dir)}resolve(true)})})}// 获取缓存数据大小async getCache(): Promise<CacheInfo> {return storageStatistics.getCurrentBundleStats().then((res) => {let cache = (res.cacheSize / (1024 * 1024)).toFixed(2) + 'MB';let cacheInfo = new CacheInfo();cacheInfo.cache_size = cache;return cacheInfo;});}
}export const clearCache = new ClearCache()

以上是工具类,下面的是 Bean 对象

@Observed
export class CacheInfo {cache_path: string = "";cache_size: string = "";
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com