提交 ebb73f88 编写于 作者: Q qiang

feat: app-plus uni.onNetworkStatusChange

上级 9f4217af
import {
invoke
} from 'uni-core/service/bridge'
import {
onMethod
} from '../../platform'
const callbacks = []
onMethod('onNetworkStatusChange', res => {
callbacks.forEach(callbackId => {
invoke(callbackId, res)
})
})
export function onNetworkStatusChange (callbackId) {
callbacks.push(callbackId)
}
......@@ -16,7 +16,11 @@ import {
isTabBarPage
} from '../api/util'
import tabBar from './tab-bar'
import tabBar from './tab-bar'
import {
publish
} from '../bridge'
let appCtx
......@@ -54,7 +58,7 @@ function initGlobalListeners () {
plus.globalEvent.addEventListener('netchange', () => {
const networkType = NETWORK_TYPES[plus.networkinfo.getCurrentType()]
emit('onNetworkStatusChange', {
publish('onNetworkStatusChange', {
isConnected: networkType !== 'none',
networkType
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册