From ab3eb58afdd8ad261e7b49d15cfd5fb2871f46bd Mon Sep 17 00:00:00 2001 From: ZoeLeeFZ Date: Sun, 12 Jan 2020 11:15:23 +0800 Subject: [PATCH] =?UTF-8?q?!710=20=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UI/Store/UserConfigStore.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/UI/Store/UserConfigStore.ts b/src/UI/Store/UserConfigStore.ts index 30471d93c..130d6cc3a 100644 --- a/src/UI/Store/UserConfigStore.ts +++ b/src/UI/Store/UserConfigStore.ts @@ -248,6 +248,7 @@ export class UserConfigStore extends Singleton { // 删除视图中的对应项 let currentName = this.configName; + if (!currentName) return; observable(this.configsNames).remove(currentName); @@ -263,9 +264,18 @@ export class UserConfigStore extends Singleton if (data.err_code === RequestStatus.Ok) { - await dbStore.Put(StoreName.ConfigData, GetIndexDBID(type), configs); - await dbStore.Put(StoreName.ConfigVersion, GetIndexDBID(type), data.version); - appCache.set(type, configs); + if (Object.keys(configs).length > 0) + { + await dbStore.Put(StoreName.ConfigData, GetIndexDBID(type), configs); + await dbStore.Put(StoreName.ConfigVersion, GetIndexDBID(type), data.version); + appCache.set(type, configs); + } + else + { + dbStore.Delete(StoreName.ConfigData, GetIndexDBID(type)); + dbStore.Delete(StoreName.ConfigVersion, GetIndexDBID(type)); + appCache.delete(type); + } //切换到第一项 if (this.configsNames.length > 0) {