'f'
mh-two-thousand-and-two
2024-04-12 26f2711ef9461961fb953e2b497bd314ef95e345
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import api from './web-view-api'
 
const isAppPlus = /uni-app/i.test(navigator.userAgent)
const isHtml5Plus = /Html5Plus/i.test(navigator.userAgent)
 
const readyRE = /complete|loaded|interactive/
 
export function initWebviewApi (readyCallback) {
  if (!isAppPlus && !isHtml5Plus) {
    return
  }
  if (window.__uniapp_x_postMessage || window.__uniapp_x_) { // uvue web-view
    document.addEventListener('DOMContentLoaded', readyCallback)
  } else if (window.__dcloud_weex_postMessage || window.__dcloud_weex_) { // nvue web-view
    document.addEventListener('DOMContentLoaded', readyCallback)
  } else if (window.plus && readyRE.test(document.readyState)) {
    setTimeout(readyCallback, 0)
  } else {
    document.addEventListener('plusready', readyCallback)
  }
  return api
}