這里寫描述
push-uniapp.js 斷線后 代碼監(jiān)聽事件疊加
打包安卓后 navigator.onLine 報(bào)錯(cuò)
push-uniapp.js 斷線后 代碼監(jiān)聽事件疊加
function Connection(options) {
this.dispatcher = new Dispatcher();
__extends(this, this.dispatcher);
var properies = ['on', 'off', 'emit'];
for (var i in properies) {
this[properies[i]] = this.dispatcher[properies[i]];
}
this.options = options;
this.state = 'initialized'; //initialized connecting connected disconnected
this.doNotConnect = 0;
this.reconnectInterval = 1;
this.connection = null;
this.reconnectTimer = 0;
//增加已經(jīng)創(chuàng)建過(guò)的標(biāo)記
this.isConnection = false;
this.connect();
}
//非首次連接不設(shè)置回調(diào) uniapp 只需要首次 注冊(cè)事件 否則會(huì)疊加回調(diào)事件
if(!_this.isConnection){
_this.isConnection = true;
cb();
}
打包安卓后 navigator.onLine 報(bào)錯(cuò)
// 有網(wǎng)絡(luò)的狀態(tài)下,重連間隔最大2秒 這里安卓有bug 做兼容處理
// #ifdef H5
if (this.reconnectInterval > 2000 && navigator.onLine) {
_this.reconnectInterval = 2000;
}
// #endif
// #ifdef APP-PLUS
if (this.reconnectInterval > 2000) {
_this.reconnectInterval = 2000;
}
// #endif