You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
631 B
20 lines
631 B
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.__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
|
|
}
|
|
|