Skip to content

Commit 7ea7d03

Browse files
committed
feat(uni-app-x web): 补充getDeviceInfo缺失的属性
1 parent 25dba6f commit 7ea7d03

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

packages/uni-h5/src/service/api/device/getSystemInfoSync.ts

+24-14
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,32 @@ export const getDeviceInfo = defineSyncApi<typeof uni.getDeviceInfo>(
3131
system,
3232
deviceOrientation,
3333
deviceType,
34+
osname,
35+
osversion,
3436
} = browserInfo
3537

36-
return {
37-
brand,
38-
deviceBrand,
39-
deviceModel,
40-
devicePixelRatio: __NODE_JS__ ? 1 : window.devicePixelRatio,
41-
deviceId: __NODE_JS__
42-
? Date.now() + '' + Math.floor(Math.random() * 1e7)
43-
: deviceId(),
44-
deviceOrientation,
45-
deviceType,
46-
model,
47-
platform,
48-
system,
49-
}
38+
return extend(
39+
{
40+
brand,
41+
deviceBrand,
42+
deviceModel,
43+
devicePixelRatio: __NODE_JS__ ? 1 : window.devicePixelRatio,
44+
deviceId: __NODE_JS__
45+
? Date.now() + '' + Math.floor(Math.random() * 1e7)
46+
: deviceId(),
47+
deviceOrientation,
48+
deviceType,
49+
model,
50+
platform,
51+
system,
52+
},
53+
__X__
54+
? {
55+
osName: osname ? osname.toLocaleLowerCase() : undefined,
56+
osVersion: osversion,
57+
}
58+
: {}
59+
)
5060
}
5161
)
5262
export const getAppBaseInfo = defineSyncApi<typeof uni.getAppBaseInfo>(

0 commit comments

Comments
 (0)