shishuangxi

清除缓存

@@ -11,6 +11,7 @@ import fs from '@ohos.file.fs'; @@ -11,6 +11,7 @@ import fs from '@ohos.file.fs';
11 import { CustomCacheDialog } from './CustomCacheDialog'; 11 import { CustomCacheDialog } from './CustomCacheDialog';
12 import MineSettingDatasModel from '../../model/MineSettingDatasModel'; 12 import MineSettingDatasModel from '../../model/MineSettingDatasModel';
13 import { MineMainSettingFunctionItem } from '../../viewmodel/MineMainSettingFunctionItem'; 13 import { MineMainSettingFunctionItem } from '../../viewmodel/MineMainSettingFunctionItem';
  14 +import common from '@ohos.app.ability.common';
14 15
15 16
16 @Component 17 @Component
@@ -279,18 +280,18 @@ export struct MineSettingComponent { @@ -279,18 +280,18 @@ export struct MineSettingComponent {
279 280
280 //删除缓存 281 //删除缓存
281 deleteCache() { 282 deleteCache() {
282 - // let context = getContext(this) as common.UIAbilityContext  
283 - // let application = context.getApplicationContext();  
284 - // let appPath = application.cacheDir  
285 - // Logger.debug("MineSettingComponent", appPath)  
286 - // fs.rmdir(appPath).then(() => {  
287 - // this.getCacheSize()  
288 - // })  
289 - // let path = context.cacheDir  
290 - // Logger.debug("MineSettingComponent", path)  
291 - // fs.rmdir(path).then(() => {  
292 - // this.getCacheSize()  
293 - // }) 283 + let context = getContext(this) as common.UIAbilityContext
  284 + let application = context.getApplicationContext();
  285 + let appPath = application.cacheDir
  286 + Logger.debug("MineSettingComponent", appPath)
  287 + fs.rmdir(appPath).then(() => {
  288 + this.getCacheSize()
  289 + })
  290 + let path = context.cacheDir
  291 + Logger.debug("MineSettingComponent", path)
  292 + fs.rmdir(path).then(() => {
  293 + this.getCacheSize()
  294 + })
294 } 295 }
295 296
296 getCacheSize() { 297 getCacheSize() {