智能照明系统APP-本地串口
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.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/4a/4ab1ac177e33f261a0c17f3d2a0...

46 lines
1.5 KiB

import {
preloadWebview,
setPreloadWebview,
consumeWebviewReady
} from '../webview'
import {
perf
} from '../perf'
let isLaunchWebviewReady = false // 目前首页双向确定 ready,可能会导致触发两次 onWebviewReady(主要是 Android)
export default function onWebviewReady (data, pageId) {
const isLaunchWebview = pageId === '1'
if (isLaunchWebview && isLaunchWebviewReady) {
if (process.env.NODE_ENV !== 'production') {
console.log('[uni-app] onLaunchWebviewReady.prevent')
}
return
}
if (isLaunchWebview) { // 首页
isLaunchWebviewReady = true
setPreloadWebview(plus.webview.getLaunchWebview())
} else if (!preloadWebview) { // preloadWebview 不存在,重新加载一下
setPreloadWebview(plus.webview.getWebviewById(pageId))
}
if (preloadWebview.id !== pageId) {
return console.error(`webviewReady[${preloadWebview.id}][${pageId}] not match`)
}
preloadWebview.loaded = true // 标记已 ready
consumeWebviewReady(pageId)
if (isLaunchWebview) {
const entryPagePath = '/' + __uniConfig.entryPagePath
const routeOptions = __uniRoutes.find(route => route.path === entryPagePath)
if (!routeOptions.meta.isNVue) { // 非 nvue 首页,需要主动跳转
const navigateType = routeOptions.meta.isTabBar ? 'switchTab' : 'navigateTo'
process.env.NODE_ENV !== 'production' && perf(`${entryPagePath} navigateTo`)
return uni[navigateType]({
url: entryPagePath + (__uniConfig.entryPageQuery || ''),
openType: 'appLaunch'
})
}
}
}