Skip to content

Commit

Permalink
add: uni.setLeft|Right|TopWindowStyle api
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasttian committed Jan 22, 2021
1 parent 8e7c1d3 commit 30c28c0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ const ui = [
'hideTopWindow',
'hideLeftWindow',
'hideRightWindow',
'getTopWindowStyle',
'getLeftWindowStyle',
'getRightWindowStyle',
'setTopWindowStyle',
'setLeftWindowStyle',
'setRightWindowStyle'
Expand Down
2 changes: 1 addition & 1 deletion src/core/helpers/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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$/

Expand Down
7 changes: 7 additions & 0 deletions src/platforms/h5/components/app/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
27 changes: 27 additions & 0 deletions src/platforms/h5/service/api/ui/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 30c28c0

Please sign in to comment.