Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init: function init(cb) {
var _this = this;
var OFFLINE_MILL = 15 * 60 * 1000; // 15分钟不操作认为不在线
var SEND_MILL = 5 * 1000; // 每5s打点一次
var lastTime = _Date$now();
window.addEventListener('click', function () {
if (_this.needRecordTimeOnPage === false) {
_this.debugLogger("config.record.time_on_page\u503C\u4E3Afalse, \u8DF3\u8FC7\u505C\u7559\u65F6\u957F\u6253\u70B9");
return;
}
var now = _Date$now();
var duration = now - lastTime;
if (duration > OFFLINE_MILL) {
lastTime = _Date$now();
} else if (duration > SEND_MILL) {
lastTime = _Date$now();
value: function init(params) {
var _this = this;
if (_typeof(params) === "object") {
var _loop = function _loop(key) {
if (key === "list") {
_this[key] = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this.queue = [{
fct: params[key],
args: args
}];
return _this;
};
} else {
// when we need '$SP().list()'
switch (key) {
url = url.toLowerCase();
if (_indexOfInstanceProperty(url).call(url, "_api") !== -1) url = url.split("_api")[0];else if (_indexOfInstanceProperty(url).call(url, "_vti_bin/client.svc/processquery") !== -1) url = url.split("_vti_bin/client.svc/processquery")[0]; // check cache
if (settings.cache) digest = global._SP_CACHE_REQUESTDIGEST[url];
if (!digest) {
_context2.next = 11;
break;
}
if (!(new Date().getTime() - new Date(digest.split(",")[1]).getTime() < 86400000)) {
_context2.next = 11;
break;
}
return _context2.abrupt("return", _Promise.resolve(digest));
case 11:
if (!(global._SP_ISBROWSER && document && settings.cache)) {
_context2.next = 17;
break;
}
e = document.querySelector("#__REQUESTDIGEST");
if (!e) {
_context2.next = 17;
break;
}
digest = e.value; // cache
function _getRequestDigest() {
_getRequestDigest = _asyncToGenerator(
/*#__PURE__*/
_regeneratorRuntime.mark(function _callee(settings) {
var _context, e, digest, url, data;
return _regeneratorRuntime.wrap(function _callee$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
settings = settings || {};
settings.cache = settings.cache === false ? false : true;
url = settings.url || this.url;
if (!url) url = _sliceInstanceProperty(_context = window.location.href.split("/")).call(_context, 0, 3).join("/");
url = url.toLowerCase();
if (_indexOfInstanceProperty(url).call(url, "_api") !== -1) url = url.split("_api")[0];else if (_indexOfInstanceProperty(url).call(url, "_vti_bin/client.svc/processquery") !== -1) url = url.split("_vti_bin/client.svc/processquery")[0]; // check cache
function _getRequestDigest() {
_getRequestDigest = _asyncToGenerator(
/*#__PURE__*/
_regeneratorRuntime.mark(function _callee(settings) {
var _context, e, digest, url, data;
return _regeneratorRuntime.wrap(function _callee$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
settings = settings || {};
settings.cache = settings.cache === false ? false : true;
url = settings.url || this.url;
if (!url) url = _sliceInstanceProperty(_context = window.location.href.split("/")).call(_context, 0, 3).join("/");
url = url.toLowerCase();
if (_indexOfInstanceProperty(url).call(url, "_api") !== -1) url = url.split("_api")[0];else if (_indexOfInstanceProperty(url).call(url, "_vti_bin/client.svc/processquery") !== -1) url = url.split("_vti_bin/client.svc/processquery")[0]; // check cache
if (settings.cache) digest = global._SP_CACHE_REQUESTDIGEST[url];
_regeneratorRuntime.mark(function _callee(settings) {
var _context, e, digest, url, data;
return _regeneratorRuntime.wrap(function _callee$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
settings = settings || {};
settings.cache = settings.cache === false ? false : true;
url = settings.url || this.url;
if (!url) url = _sliceInstanceProperty(_context = window.location.href.split("/")).call(_context, 0, 3).join("/");
url = url.toLowerCase();
if (_indexOfInstanceProperty(url).call(url, "_api") !== -1) url = url.split("_api")[0];else if (_indexOfInstanceProperty(url).call(url, "_vti_bin/client.svc/processquery") !== -1) url = url.split("_vti_bin/client.svc/processquery")[0]; // check cache
if (settings.cache) digest = global._SP_CACHE_REQUESTDIGEST[url];
if (!digest) {
_context2.next = 11;
break;
export function parseDomain(hostname) {
// 首先用比较严肃的方法:
// 先尝试匹配常见后缀
var checkReg = new RegExp(/(.*?)\.?([^.]*?)\.(gl|com|net|org|biz|ws|in|me|co\.uk|co|org\.uk|ltd\.uk|plc\.uk|me\.uk|edu|mil|br\.com|cn\.com|eu\.com|hu\.com|no\.com|qc\.com|sa\.com|se\.com|se\.net|us\.com|uy\.com|ac|co\.ac|gv\.ac|or\.ac|ac\.ac|af|am|as|at|ac\.at|co\.at|gv\.at|or\.at|asn\.au|com\.au|edu\.au|org\.au|net\.au|id\.au|be|ac\.be|adm\.br|adv\.br|am\.br|arq\.br|art\.br|bio\.br|cng\.br|cnt\.br|com\.br|ecn\.br|eng\.br|esp\.br|etc\.br|eti\.br|fm\.br|fot\.br|fst\.br|g12\.br|gov\.br|ind\.br|inf\.br|jor\.br|lel\.br|med\.br|mil\.br|net\.br|nom\.br|ntr\.br|odo\.br|org\.br|ppg\.br|pro\.br|psc\.br|psi\.br|rec\.br|slg\.br|tmp\.br|tur\.br|tv\.br|vet\.br|zlg\.br|br|ab\.ca|bc\.ca|mb\.ca|nb\.ca|nf\.ca|ns\.ca|nt\.ca|on\.ca|pe\.ca|qc\.ca|sk\.ca|yk\.ca|ca|cc|ac\.cn|com\.cn|edu\.cn|gov\.cn|org\.cn|bj\.cn|sh\.cn|tj\.cn|cq\.cn|he\.cn|nm\.cn|ln\.cn|jl\.cn|hl\.cn|js\.cn|zj\.cn|ah\.cn|gd\.cn|gx\.cn|hi\.cn|sc\.cn|gz\.cn|yn\.cn|xz\.cn|sn\.cn|gs\.cn|qh\.cn|nx\.cn|xj\.cn|tw\.cn|hk\.cn|mo\.cn|cn|cx|cz|de|dk|fo|com\.ec|tm\.fr|com\.fr|asso\.fr|presse\.fr|fr|gf|gs|co\.il|net\.il|ac\.il|k12\.il|gov\.il|muni\.il|ac\.in|co\.in|org\.in|ernet\.in|gov\.in|net\.in|res\.in|is|it|ac\.jp|co\.jp|go\.jp|or\.jp|ne\.jp|ac\.kr|co\.kr|go\.kr|ne\.kr|nm\.kr|or\.kr|li|lt|lu|asso\.mc|tm\.mc|com\.mm|org\.mm|net\.mm|edu\.mm|gov\.mm|ms|nl|no|nu|pl|ro|org\.ro|store\.ro|tm\.ro|firm\.ro|www\.ro|arts\.ro|rec\.ro|info\.ro|nom\.ro|nt\.ro|se|si|com\.sg|org\.sg|net\.sg|gov\.sg|sk|st|tf|ac\.th|co\.th|go\.th|mi\.th|net\.th|or\.th|tm|to|com\.tr|edu\.tr|gov\.tr|k12\.tr|net\.tr|org\.tr|com\.tw|org\.tw|net\.tw|ac\.uk|uk\.com|uk\.net|gb\.com|gb\.net|vg|sh|kz|ch|info|ua|gov|name|pro|ie|hk|com\.hk|org\.hk|net\.hk|edu\.hk|us|tk|cd|by|ad|lv|eu\.lv|bz|es|jp|cl|ag|mobi|eu|co\.nz|org\.nz|net\.nz|maori\.nz|iwi\.nz|io|la|md|sc|sg|vc|tw|travel|my|se|tv|pt|com\.pt|edu\.pt|asia|fi|com\.ve|net\.ve|fi|org\.ve|web\.ve|info\.ve|co\.ve|tel|im|gr|ru|net\.ru|org\.ru|hr|com\.hr|ly|xyz)$/);
var parseResult = hostname.match(checkReg);
var domain;
if (parseResult) {
domain = parseResult[2] ? parseResult[2] + '.' + parseResult[3] : undefined;
}
if (domain === undefined) {
// 没有匹配到常见后缀, 则使用最后两段被.分隔的字符, 作为主域名
var urlSplitList = hostname.split('.');
domain = _sliceInstanceProperty(urlSplitList).call(urlSplitList, urlSplitList.length - 2, urlSplitList.length).join('.');
} // 强制转为字符串
domain = domain + '';
return domain;
}
export function getDeviceId() {
window.addEventListener('unhandledrejection', function (event) {
// reason可能是正常的字符串, 也可能会有message和stack信息
// 如果有的话, 就抓一下
var promiseErrorInfo = '';
var reason = '';
try {
promiseErrorInfo = _JSON$stringify(_.get(event, ['promise'], ''));
reason = _JSON$stringify(_.get(event, ['reason'], ''));
} catch (e) {
console.log('promise stringify出错===>' + e);
promiseErrorInfo = _.get(event, ['promise'], '') + ''; // 稳稳的 [object Promise]
reason = _.get(event, ['reason'], '') + '';
}
var message = _.get(event, ['reason', 'message'], '');
var stack = _.get(event, ['reason', 'stack'], '');
var desc = "Unhandled_Rejection:" + promiseErrorInfo; // 这里也去调用
if (desc && stack) {
var _context;
window.addEventListener('unhandledrejection', function (event) {
// reason可能是正常的字符串, 也可能会有message和stack信息
// 如果有的话, 就抓一下
var promiseErrorInfo = '';
var reason = '';
try {
promiseErrorInfo = _JSON$stringify(_.get(event, ['promise'], ''));
reason = _JSON$stringify(_.get(event, ['reason'], ''));
} catch (e) {
console.log('promise stringify出错===>' + e);
promiseErrorInfo = _.get(event, ['promise'], '') + ''; // 稳稳的 [object Promise]
reason = _.get(event, ['reason'], '') + '';
}
var message = _.get(event, ['reason', 'message'], '');
var stack = _.get(event, ['reason', 'stack'], '');
var desc = "Unhandled_Rejection:" + promiseErrorInfo; // 这里也去调用
if (desc && stack) {
var _context;
if (_typeof(extra) !== 'object') {
return 'third argument extra required object';
} // 字段校验
var ruleItem = rule[code];
if (ruleItem) {
// 消费字段必填
var requireFields = _toConsumableArray(ruleItem.df);
var realFields = _Object$keys(detail);
var needFields = [];
_forEachInstanceProperty(requireFields).call(requireFields, function (field) {
// 缺字端
if (_indexOfInstanceProperty(realFields).call(realFields, field) === -1) {
needFields.push(field);
}
});
if (needFields.length) {
var _context2;
return _concatInstanceProperty(_context2 = "code: ".concat(code, " \u8981\u6C42 ")).call(_context2, needFields.join(','), "\u5B57\u6BB5\u5FC5\u586B");
}
}
return '';
};
export var detailAdapter = function detailAdapter(code) {