From 1c72eb11dd5d43b5ae1f32b3861b5c6447d8a84f Mon Sep 17 00:00:00 2001 From: qiang Date: Sat, 4 Jan 2020 11:31:03 +0800 Subject: [PATCH] feat: mp-weixin getSystemInfo safeAreaInsets --- .../mp-weixin/runtime/api/protocols.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/platforms/mp-weixin/runtime/api/protocols.js b/src/platforms/mp-weixin/runtime/api/protocols.js index 9d4bc155c..6991173f5 100644 --- a/src/platforms/mp-weixin/runtime/api/protocols.js +++ b/src/platforms/mp-weixin/runtime/api/protocols.js @@ -1,8 +1,26 @@ import previewImage from '../../helpers/normalize-preview-image' + +function addSafeAreaInsets (result) { + if (result.safeArea) { + const safeArea = result.safeArea + result.safeAreaInsets = { + top: safeArea.top, + left: safeArea.left, + right: result.windowWidth - safeArea.right, + bottom: result.windowHeight - safeArea.bottom + } + } +} export const protocols = { - previewImage + previewImage, + getSystemInfo: { + returnValue: addSafeAreaInsets + }, + getSystemInfoSync: { + returnValue: addSafeAreaInsets + } } -export const todos = [ - 'vibrate' +export const todos = [ + 'vibrate' ] -export const canIUses = [] +export const canIUses = [] -- GitLab