From 92af3839f9fefe915cc9b70dfb83201d21589076 Mon Sep 17 00:00:00 2001 From: wkj <278599135@.com> Date: Tue, 2 Jul 2024 15:47:26 +0800 Subject: [PATCH] =?UTF-8?q?native=E8=8E=B7=E5=8F=96=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=EF=BC=8C=E6=A0=B9=E6=8D=AE=E6=98=AF=E5=90=A6?= =?UTF-8?q?debug=E8=B0=83=E8=AF=95=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/utils/env/env.native.js | 7 +++++-- lib/utils/env/env.native.js | 3 ++- src/utils/env/env.native.ts | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/es/utils/env/env.native.js b/es/utils/env/env.native.js index dac3e885..a5afa6ab 100644 --- a/es/utils/env/env.native.js +++ b/es/utils/env/env.native.js @@ -2,7 +2,8 @@ import { Platform } from 'react-native'; import { getLocales } from 'react-native-localize'; import { getDeviceId } from 'react-native-device-info'; export async function getEnv() { - const language = getLocales()[0].languageTag; + const isDebuggingEnabled = typeof atob !== 'undefined'; + const language = !isDebuggingEnabled ? getLocales()[0].languageTag : navigator.language; const deviceId = getDeviceId(); const fullEnv = { ...Platform, @@ -13,7 +14,9 @@ export async function getEnv() { const briefEnv = { brand: fullEnv.constants.Brand, model: fullEnv.constants.Model, - system: `${fullEnv.OS}/${fullEnv.constants.Version || fullEnv.constants.osVersion}/${language}`, + system: `${fullEnv.OS}/${ + fullEnv.constants.Version || fullEnv.constants.osVersion + }/${language}`, }; return { fullEnv, diff --git a/lib/utils/env/env.native.js b/lib/utils/env/env.native.js index ed7abb23..6b6498cd 100644 --- a/lib/utils/env/env.native.js +++ b/lib/utils/env/env.native.js @@ -5,7 +5,8 @@ const react_native_1 = require("react-native"); const react_native_localize_1 = require("react-native-localize"); const react_native_device_info_1 = require("react-native-device-info"); async function getEnv() { - const language = (0, react_native_localize_1.getLocales)()[0].languageTag; + const isDebuggingEnabled = typeof atob !== 'undefined'; + const language = !isDebuggingEnabled ? (0, react_native_localize_1.getLocales)()[0].languageTag : navigator.language; const deviceId = (0, react_native_device_info_1.getDeviceId)(); const fullEnv = { ...react_native_1.Platform, diff --git a/src/utils/env/env.native.ts b/src/utils/env/env.native.ts index 1701aaec..b7f6cf83 100644 --- a/src/utils/env/env.native.ts +++ b/src/utils/env/env.native.ts @@ -4,7 +4,8 @@ import { getLocales } from 'react-native-localize'; import { getDeviceId } from 'react-native-device-info'; export async function getEnv() { - const language = getLocales()[0].languageTag; + const isDebuggingEnabled = typeof atob !== 'undefined'; + const language = !isDebuggingEnabled ? getLocales()[0].languageTag : navigator.language; const deviceId = getDeviceId(); const fullEnv = { ...Platform,