diff --git a/lib/apis.js b/lib/apis.js index 9e2a783249c08c02cd6231da9a31dbdd6e262bdc..1ee829e040247cb8af5fb17e3668097dea97d9af 100644 --- a/lib/apis.js +++ b/lib/apis.js @@ -174,6 +174,9 @@ const ui = [ 'hideTopWindow', 'hideLeftWindow', 'hideRightWindow', + 'getTopWindowStyle', + 'getLeftWindowStyle', + 'getRightWindowStyle', 'setTopWindowStyle', 'setLeftWindowStyle', 'setRightWindowStyle' diff --git a/src/core/helpers/promise.js b/src/core/helpers/promise.js index d6704f500e103a27ff9f41381f344b77197367be..2ab7aa0b7ab91a9a57d3f2a42b8935bf4d9a1fd0 100644 --- a/src/core/helpers/promise.js +++ b/src/core/helpers/promise.js @@ -8,7 +8,7 @@ import { } from './interceptor' const SYNC_API_RE = - /^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/ + /^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/ const CONTEXT_API_RE = /^create|Manager$/ diff --git a/src/platforms/h5/components/app/layout.vue b/src/platforms/h5/components/app/layout.vue index 2f0a5c3a33ada4e14908c8aa203072c6051a8d32..69d47750c2533ce01af6354f4121ee6e21967435 100644 --- a/src/platforms/h5/components/app/layout.vue +++ b/src/platforms/h5/components/app/layout.vue @@ -274,6 +274,13 @@ export default { } } }, + getWindowStyle (type) { + if (!this[type + 'Window']) { + return type + 'Window not found' + } + const style = Object.assign({}, this[type + 'WindowStyle']) + return style + }, setWindowStyle (type, style) { if (!this[type + 'Window']) { return type + 'Window not found' diff --git a/src/platforms/h5/service/api/ui/windows.js b/src/platforms/h5/service/api/ui/windows.js index fc8f79f23adaf9d99bbee1ded9fc926d3c2464cc..43b1184fae07ca18ce6d17504df60c3708f4264d 100644 --- a/src/platforms/h5/service/api/ui/windows.js +++ b/src/platforms/h5/service/api/ui/windows.js @@ -42,6 +42,33 @@ export function hideRightWindow () { return showWindow('right', false) } +function getWindowStyle (type) { + const api = 'get' + capitalize(type) + 'WindowStyle' + const app = getApp() + if (!app) { + return { + errMsg: `${api}:fail app not ready` + } + } + const msg = app.$children[0].$refs.layout.getWindowStyle(type) + if (typeof msg === 'string' && msg.indexOf('Window not found') !== -1) { + return { + errMsg: `${api}:fail ${msg}` + } + } + return msg +} + +export function getTopWindowStyle (style) { + return getWindowStyle('top') +} +export function getLeftWindowStyle (style) { + return getWindowStyle('left') +} +export function getRightWindowStyle (style) { + return getWindowStyle('right') +} + function setWindowStyle (type, style) { const api = 'set' + capitalize(type) + 'WindowStyle' const app = getApp()