cache system info on LINK_SURE platform (#8661)

This commit is contained in:
PP
2021-05-13 15:36:51 +08:00
committed by GitHub
parent e9018cbf22
commit abccf89427
+17 -11
View File
@@ -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 };