Skip to content

Commit

Permalink
fix(web): 修复uni-app-x getStorage调用报错
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangyaqi committed Nov 12, 2024
1 parent 550a39c commit 972d5db
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/uni-h5/src/service/api/storage/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ function parseValue(value: any) {
if (keys.length === 2 && 'data' in object) {
// eslint-disable-next-line valid-typeof
if (typeof object.data === type) {
//#if _X_
if (type === 'object' && !Array.isArray(object.data)) {
// @ts-expect-error 访问global.UTS
return UTS.JSON.parse(JSON.stringify(object.data))
}
return object.data
//#else
return object.data
//#endif
}
// eslint-disable-next-line no-useless-escape
if (
Expand Down Expand Up @@ -87,13 +95,7 @@ function getStorageOrigin(key: string): any {
}
let data: any = value
try {
let object
//#if _X_
// @ts-expect-error 访问global.UTS
object = UTS.JSON.parse(value)
//#else
object = JSON.parse(value)
//#endif
const object = JSON.parse(value)
const result = parseValue(object)
if (result !== undefined) {
data = result
Expand Down

0 comments on commit 972d5db

Please sign in to comment.