const $ = require('yoho-jquery'); const Alert = require('./common/dialog').Alert; // 注册ajaxError处理服务端异常 $(document).ajaxError((event, xhr) => { if (xhr.responseJSON) { if (xhr.status === 510) { if (xhr.responseJSON.data && xhr.responseJSON.data.refer) { window.location.href = xhr.responseJSON.data.refer; } else if (xhr.responseJSON.message) { new Alert(xhr.responseJSON.message).show(); } } else if (xhr.status === 403 && xhr.responseJSON.code === 4403) { new Alert(xhr.responseJSON.message).show(); setTimeout(function() { window.location.href = `${xhr.responseJSON.data.url}&refer=${encodeURIComponent(window.location.href)}`; }, 2000); } } });