Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mp-weixin): 修复微信小程序上的 getSystemInfo 警告 #5229

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/uni-api/src/service/base/upx2px.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion packages/uni-mp-core/src/api/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/uni-mp-core/src/runtime/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ export function initAppLifecycle(

function initLocale(appVm: ComponentPublicInstance) {
const locale = ref<string>(
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() {
Expand Down
Loading