From c12fc6130f9ec8c575d65cd16e61211d7b0b2254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=9A=E7=90=AA?= Date: Sat, 9 Nov 2024 12:01:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=9D=E5=AD=98UTSJ?= =?UTF-8?q?SONObject=E5=88=B0storage=E5=86=85=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BE=8B=E5=9C=A8=E5=AE=89=E5=8D=93=E7=AB=AF=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/storage/storage.test.js | 4 ++-- pages/API/storage/storage.uvue | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pages/API/storage/storage.test.js b/pages/API/storage/storage.test.js index e1265f44..bb1efb35 100644 --- a/pages/API/storage/storage.test.js +++ b/pages/API/storage/storage.test.js @@ -306,8 +306,8 @@ describe('ExtApi-StorageInfoTest', () => { jest_saveUTSJSONObjectSyncResult, jest_saveUTSJSONObjectAsyncResult } = await page.data() - expect(jest_saveUTSJSONObjectSyncResult).toBe(true) - expect(jest_saveUTSJSONObjectAsyncResult).toBe(true) + expect(jest_saveUTSJSONObjectSyncResult).toBe(1) + expect(jest_saveUTSJSONObjectAsyncResult).toBe(1) }) }); diff --git a/pages/API/storage/storage.uvue b/pages/API/storage/storage.uvue index 8db8d8e8..335e1f2d 100644 --- a/pages/API/storage/storage.uvue +++ b/pages/API/storage/storage.uvue @@ -113,8 +113,8 @@ apiGetData: '' as any | null, storageInfo: '', staticComplexRet: false, - jest_saveUTSJSONObjectSyncResult: false, - jest_saveUTSJSONObjectAsyncResult: false + jest_saveUTSJSONObjectSyncResult: 0, + jest_saveUTSJSONObjectAsyncResult: 0 } }, methods: { @@ -378,13 +378,15 @@ b: 1 } }) - const dataSync = uni.getStorageSync(key) - this.jest_saveUTSJSONObjectSyncResult = dataSync instanceof UTSJSONObject && dataSync['a'] instanceof UTSJSONObject + const dataSync = uni.getStorageSync(key) as UTSJSONObject + const dataSyncA = dataSync['a'] as UTSJSONObject + this.jest_saveUTSJSONObjectSyncResult = dataSyncA.get('b') as number uni.getStorage({ key, success: (res) => { - const data = res.data - this.jest_saveUTSJSONObjectAsyncResult = data instanceof UTSJSONObject && data['a'] instanceof UTSJSONObject + const dataAsync = res.data as UTSJSONObject + const dataAsyncA = dataAsync['a'] as UTSJSONObject + this.jest_saveUTSJSONObjectAsyncResult = dataAsyncA.get('b') as number console.log('this.jest_saveUTSJSONObjectSyncResult: ' + this.jest_saveUTSJSONObjectSyncResult) console.log('this.jest_saveUTSJSONObjectAsyncResult: ' + this.jest_saveUTSJSONObjectAsyncResult) } -- GitLab