包含所有线上运行的改动: - 荷官端倒计时卡顿修复(CountdownService TTL+10/前端watchdog) - 停止下注debounce防重复(8个handle.js) - 洗码量规则重写(单边/双边/开和不计/百家乐+龙虎) - 龙虎和局不杀庄闲(全额退回) - 日志系统(Logger工具类/日志查看/清理脚本) - 好路提醒异常处理(WaybillRemindService try-catch) - 扫牌器连接改进(ScanConnectService) - 牛牛/三卡开牌修复 - .gitignore更新/.DS_Store清理
63 lines
1.9 KiB
JavaScript
63 lines
1.9 KiB
JavaScript
(function() {
|
|
var reportUrl = '/log/report';
|
|
var queue = [];
|
|
var sending = false;
|
|
var ignorePatterns = [
|
|
'play() request was interrupted',
|
|
'The play() request was interrupted',
|
|
'NotAllowedError',
|
|
'AbortError'
|
|
];
|
|
|
|
function shouldIgnore(msg) {
|
|
if (!msg) return false;
|
|
for (var i = 0; i < ignorePatterns.length; i++) {
|
|
if (msg.indexOf(ignorePatterns[i]) !== -1) return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function send(data) {
|
|
if (queue.length >= 10) return;
|
|
if (shouldIgnore(data.message)) return;
|
|
data.source = 'handle';
|
|
data.time = new Date().toISOString();
|
|
data.url = location.href;
|
|
queue.push(data);
|
|
flush();
|
|
}
|
|
|
|
function flush() {
|
|
if (sending || queue.length === 0) return;
|
|
sending = true;
|
|
var item = queue.shift();
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', reportUrl);
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.onloadend = function() { sending = false; flush(); };
|
|
xhr.onerror = function() { sending = false; };
|
|
xhr.timeout = 3000;
|
|
xhr.send(JSON.stringify(item));
|
|
}
|
|
|
|
window.onerror = function(message, source, lineno, colno, error) {
|
|
send({
|
|
type: 'error',
|
|
message: String(message),
|
|
stack: error && error.stack ? error.stack.substring(0, 2000) : '',
|
|
file: source,
|
|
line: lineno,
|
|
col: colno
|
|
});
|
|
};
|
|
|
|
window.addEventListener('unhandledrejection', function(event) {
|
|
var reason = event.reason;
|
|
send({
|
|
type: 'unhandledrejection',
|
|
message: reason && reason.message ? reason.message : String(reason),
|
|
stack: reason && reason.stack ? reason.stack.substring(0, 2000) : ''
|
|
});
|
|
});
|
|
})();
|