From abccf8942759e9fa053b003e2986f2a252ff2f02 Mon Sep 17 00:00:00 2001 From: PP Date: Thu, 13 May 2021 15:36:51 +0800 Subject: [PATCH] cache system info on LINK_SURE platform (#8661) --- pal/minigame/runtime.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/pal/minigame/runtime.ts b/pal/minigame/runtime.ts index 6046e685c4..70093e832b 100644 --- a/pal/minigame/runtime.ts +++ b/pal/minigame/runtime.ts @@ -40,6 +40,23 @@ Object.defineProperty(minigame, 'orientation', { return minigame.isLandscape ? landscapeOrientation : Orientation.PORTRAIT; }, }); + +if (VIVO) { + // TODO: need to be handled in ral lib. + minigame.getSystemInfoSync = function () { + const sys = ral.getSystemInfoSync() as SystemInfo; + // on VIVO, windowWidth should be windowHeight when it is landscape + sys.windowWidth = sys.screenWidth; + sys.windowHeight = sys.screenHeight; + return sys; + }; +} else if (LINKSURE) { + // TODO: update system info when view resized, currently the resize callback is not supported. + const cachedSystemInfo = ral.getSystemInfoSync() as SystemInfo; + minigame.getSystemInfoSync = function () { + return cachedSystemInfo; + }; +} // #endregion SystemInfo // #region Accelerometer @@ -89,15 +106,4 @@ minigame.getSafeArea = function () { return { top, left, bottom, right, width, height }; }; -if (VIVO) { - // TODO: need to be handled in ral lib. - minigame.getSystemInfoSync = function () { - const sys = ral.getSystemInfoSync() as SystemInfo; - // on VIVO, windowWidth should be windowHeight when it is landscape - sys.windowWidth = sys.screenWidth; - sys.windowHeight = sys.screenHeight; - return sys; - }; -} - export { minigame };