优化
This commit is contained in:
@@ -12,13 +12,15 @@ function ensureListening() {
|
||||
if (typeof uni.onNetworkStatusChange === 'function') {
|
||||
uni.onNetworkStatusChange((result) => {
|
||||
online = Boolean(result.isConnected)
|
||||
console.info('[Overseas PDA network] status change', { isConnected: result.isConnected, networkType: result.networkType })
|
||||
notify()
|
||||
})
|
||||
}
|
||||
if (typeof uni.getNetworkType === 'function') {
|
||||
uni.getNetworkType({
|
||||
success: (result) => {
|
||||
success: (result) => {
|
||||
online = result.networkType !== 'none'
|
||||
console.info('[Overseas PDA network] initial status', { networkType: result.networkType, online })
|
||||
notify()
|
||||
}
|
||||
})
|
||||
@@ -31,6 +33,7 @@ export function isOnline() {
|
||||
}
|
||||
|
||||
export function requireOnline(message = '当前网络不可用,请联网后刷新重试') {
|
||||
console.info('[Overseas PDA network] preflight', { online })
|
||||
if (!isOnline()) {
|
||||
const error = new Error(message)
|
||||
error.network = true
|
||||
|
||||
Reference in New Issue
Block a user