zhangbo1_wd

切环境,清除首页缓存

@@ -89,6 +89,15 @@ export class KVStoreHelper { @@ -89,6 +89,15 @@ export class KVStoreHelper {
89 } 89 }
90 } 90 }
91 91
  92 + deleteAll() {
  93 + this.kvManager?.deleteKVStore(AppUtils.getPackageName(getContext()), KVStoreHelper._default_store_id)
  94 + .then(() => {
  95 + Logger.error(TAG, 'deleteAll success')
  96 + }).catch((e: object) => {
  97 + Logger.error(TAG, 'deleteAll error: ' + JSON.stringify(e))
  98 + })
  99 + }
  100 +
92 private checkStoreCreated() { 101 private checkStoreCreated() {
93 if (!this.kvManager) { 102 if (!this.kvManager) {
94 this.createKVManager() 103 this.createKVManager()
1 -import { SPHelper } from 'wdKit/Index'; 1 +import { KVStoreHelper, SPHelper } from 'wdKit/Index';
2 import { HostEnum, HostManager, HttpUrlUtils } from 'wdNetwork/Index'; 2 import { HostEnum, HostManager, HttpUrlUtils } from 'wdNetwork/Index';
3 3
4 @CustomDialog 4 @CustomDialog
@@ -86,10 +86,15 @@ export struct EnvironmentCustomDialog { @@ -86,10 +86,15 @@ export struct EnvironmentCustomDialog {
86 Button('确认') 86 Button('确认')
87 .margin({ top: 20 }) 87 .margin({ top: 20 })
88 .onClick(() => { 88 .onClick(() => {
89 - // HttpUrlUtils.hostUrl = this.currentEnvironment  
90 - SPHelper.default.saveSync('hostUrl', this.currentEnvironment);  
91 - this.controller.close()  
92 - this.confirm() 89 + new Promise<void>(() => {
  90 + // HttpUrlUtils.hostUrl = this.currentEnvironment
  91 + SPHelper.default.saveSync('hostUrl', this.currentEnvironment);
  92 + // 清首页缓存
  93 + KVStoreHelper.default.deleteAll()
  94 + // TODO 清sp相关
  95 + this.controller.close()
  96 + this.confirm()
  97 + })
93 }) 98 })
94 }.height(261).backgroundColor(Color.White).borderRadius(6).width('74%') 99 }.height(261).backgroundColor(Color.White).borderRadius(6).width('74%')
95 100