bridge.js 885 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3
export {
  unpack,
  invoke
fxy060608's avatar
format  
fxy060608 已提交
4
}
fxy060608's avatar
fxy060608 已提交
5
  from 'uni-core/service/bridge'
fxy060608's avatar
format  
fxy060608 已提交
6

fxy060608's avatar
fxy060608 已提交
7 8
export function requireNativePlugin (name) {
  return uni.requireNativePlugin(name)
fxy060608's avatar
fxy060608 已提交
9 10
}

fxy060608's avatar
fxy060608 已提交
11 12 13 14 15
/**
 * 触发 service 层,与 onMethod 对应
 */
export function publish (name, res) {
  return UniServiceJSBridge.emit('api.' + name, res)
fxy060608's avatar
fxy060608 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
}

let lastStatusBarStyle

export function setStatusBarStyle (statusBarStyle) {
  if (!statusBarStyle) {
    const pages = getCurrentPages()
    if (!pages.length) {
      return
    }
    statusBarStyle = pages[pages.length - 1].$page.meta.statusBarStyle
    if (!statusBarStyle || statusBarStyle === lastStatusBarStyle) {
      return
    }
  }
  if (process.env.NODE_ENV !== 'production') {
    console.log(`[uni-app] setStatusBarStyle`, statusBarStyle)
  }

  lastStatusBarStyle = statusBarStyle

  plus.navigator.setStatusBarStyle(statusBarStyle)
fxy060608's avatar
format  
fxy060608 已提交
38
}