From 7ea7d03b75109e87482a28f3ac9407a7232bcec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=9A=E7=90=AA?= Date: Sat, 18 May 2024 15:30:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(uni-app-x=20web):=20=E8=A1=A5=E5=85=85getD?= =?UTF-8?q?eviceInfo=E7=BC=BA=E5=A4=B1=E7=9A=84=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/api/device/getSystemInfoSync.ts | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts b/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts index a12576ea9af..ec99b77e5f8 100644 --- a/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts +++ b/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts @@ -31,22 +31,32 @@ export const getDeviceInfo = defineSyncApi( system, deviceOrientation, deviceType, + osname, + osversion, } = browserInfo - return { - brand, - deviceBrand, - deviceModel, - devicePixelRatio: __NODE_JS__ ? 1 : window.devicePixelRatio, - deviceId: __NODE_JS__ - ? Date.now() + '' + Math.floor(Math.random() * 1e7) - : deviceId(), - deviceOrientation, - deviceType, - model, - platform, - system, - } + return extend( + { + brand, + deviceBrand, + deviceModel, + devicePixelRatio: __NODE_JS__ ? 1 : window.devicePixelRatio, + deviceId: __NODE_JS__ + ? Date.now() + '' + Math.floor(Math.random() * 1e7) + : deviceId(), + deviceOrientation, + deviceType, + model, + platform, + system, + }, + __X__ + ? { + osName: osname ? osname.toLocaleLowerCase() : undefined, + osVersion: osversion, + } + : {} + ) } ) export const getAppBaseInfo = defineSyncApi(