From d5ced0718f586ca156e80c56078ae1f3de4ee917 Mon Sep 17 00:00:00 2001 From: molvqingtai Date: Mon, 4 Nov 2024 21:31:45 +0800 Subject: [PATCH] fix: incompatible with old data of userInfo, causing crash --- src/domain/impls/Storage.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/domain/impls/Storage.ts b/src/domain/impls/Storage.ts index fba5ebb..2fc0636 100644 --- a/src/domain/impls/Storage.ts +++ b/src/domain/impls/Storage.ts @@ -56,7 +56,14 @@ export const IndexDBStorageImpl = IndexDBStorageExtern.impl({ export const BrowserSyncStorageImpl = BrowserSyncStorageExtern.impl({ name: STORAGE_NAME, - get: async (key) => JSONR.parse(await browserSyncStorage.getItem(key)), + get: async (key) => { + const value: any = await browserSyncStorage.getItem(key) + try { + return JSONR.parse(value) + } catch { + return value + } + }, set: (key, value) => browserSyncStorage.setItem(key, JSONR.stringify(value)), remove: browserSyncStorage.removeItem, clear: browserSyncStorage.clear,