From b9cccba9ddcecd82f937f4bcb5a0e0bde2d89256 Mon Sep 17 00:00:00 2001 From: yuhe <1641284022@qq.com> Date: Tue, 19 Nov 2024 17:47:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(mp-weixin):=20=E4=BF=AE=E5=A4=8D=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=8A=E7=9A=84=20getSys?= =?UTF-8?q?temInfo=20=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-api/src/service/base/upx2px.ts | 8 +++++++- packages/uni-mp-core/src/api/locale.ts | 4 +++- packages/uni-mp-core/src/runtime/app.ts | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/uni-api/src/service/base/upx2px.ts b/packages/uni-api/src/service/base/upx2px.ts index 62505502cab..1e39cdd1c5f 100644 --- a/packages/uni-api/src/service/base/upx2px.ts +++ b/packages/uni-api/src/service/base/upx2px.ts @@ -16,7 +16,13 @@ let baseWidth = 375 let includeWidth = 750 function checkDeviceWidth() { - const { platform, pixelRatio, windowWidth } = getBaseSystemInfo() + const { windowWidth, pixelRatio, platform } = + __PLATFORM__ === 'mp-weixin' + ? Object.assign({}, wx.getWindowInfo(), { + platform: wx.getDeviceInfo().platform, + }) + : getBaseSystemInfo() + deviceWidth = windowWidth as number deviceDPR = pixelRatio as number isIOS = (platform as string) === 'ios' diff --git a/packages/uni-mp-core/src/api/locale.ts b/packages/uni-mp-core/src/api/locale.ts index 3009799d6a7..722828f19a5 100644 --- a/packages/uni-mp-core/src/api/locale.ts +++ b/packages/uni-mp-core/src/api/locale.ts @@ -7,7 +7,9 @@ export const getLocale: typeof uni.getLocale = () => { if (app && app.$vm) { return app.$vm.$locale } - return normalizeLocale(__GLOBAL__.getSystemInfoSync().language) || LOCALE_EN + return __PLATFORM__ === 'mp-weixin' + ? normalizeLocale(__GLOBAL__.getAppBaseInfo().language) || LOCALE_EN + : normalizeLocale(__GLOBAL__.getSystemInfoSync().language) || LOCALE_EN } export const setLocale: typeof uni.setLocale = (locale) => { diff --git a/packages/uni-mp-core/src/runtime/app.ts b/packages/uni-mp-core/src/runtime/app.ts index 95f4d060fef..dc17bebf73b 100644 --- a/packages/uni-mp-core/src/runtime/app.ts +++ b/packages/uni-mp-core/src/runtime/app.ts @@ -164,7 +164,9 @@ export function initAppLifecycle( function initLocale(appVm: ComponentPublicInstance) { const locale = ref( - normalizeLocale(__GLOBAL__.getSystemInfoSync().language) || LOCALE_EN + __PLATFORM__ === 'mp-weixin' + ? normalizeLocale(__GLOBAL__.getAppBaseInfo().language) || LOCALE_EN + : normalizeLocale(__GLOBAL__.getSystemInfoSync().language) || LOCALE_EN ) Object.defineProperty(appVm, '$locale', { get() {