dlt-for-react 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/lib/index.js +344 -14
- package/lib/layouts/LeftMenu/index.js +322 -296
- package/lib/utils/NHCore.js +174 -1
- package/lib/utils/common.js +1 -52
- package/lib/utils/index.js +23 -230
- package/package.json +1 -1
package/lib/utils/NHCore.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setCookie = exports.getCookie = exports.validateCode = exports.getOffset = exports.computeFontSize = exports.browserJudge = exports.getLoginUser = exports.hasAuthList = exports.hasAuth = exports.getStyle = exports.createUuid = exports.getSuitHeight = exports.getSize = undefined;
|
|
6
|
+
exports.download = exports.getBase64 = exports.createScript = exports.compatibleAnimationFrame = exports.setCookie = exports.getCookie = exports.validateCode = exports.getOffset = exports.computeFontSize = exports.browserJudge = exports.getLoginUser = exports.hasAuthList = exports.hasAuth = exports.getStyle = exports.createUuid = exports.getSuitHeight = exports.getSize = undefined;
|
|
7
|
+
|
|
8
|
+
var _promise = require('babel-runtime/core-js/promise');
|
|
9
|
+
|
|
10
|
+
var _promise2 = _interopRequireDefault(_promise);
|
|
7
11
|
|
|
8
12
|
var _regenerator = require('babel-runtime/regenerator');
|
|
9
13
|
|
|
@@ -17,8 +21,12 @@ var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
|
|
17
21
|
|
|
18
22
|
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
19
23
|
|
|
24
|
+
exports.loadScript = loadScript;
|
|
25
|
+
exports.animationFramePolyfill = animationFramePolyfill;
|
|
26
|
+
|
|
20
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
28
|
|
|
29
|
+
// 获取窗口信息
|
|
22
30
|
var getSize = exports.getSize = function getSize() {
|
|
23
31
|
var setting = sessionStorage.getItem('setting');
|
|
24
32
|
var breadcrumbHeight = 0; //面包屑高度
|
|
@@ -324,4 +332,169 @@ var setCookie = exports.setCookie = function setCookie(key, value) {
|
|
|
324
332
|
d.setTime(d.getTime() + day * 24 * 60 * 60 * 1000);
|
|
325
333
|
var expires = 'expires=' + d.toGMTString();
|
|
326
334
|
document.cookie = key + '=' + value + '; ' + expires;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
function loadScript(src) {
|
|
338
|
+
return new _promise2.default(function (resolve, reject) {
|
|
339
|
+
var script = document.createElement('script');
|
|
340
|
+
script.type = 'text/javascript';
|
|
341
|
+
script.src = src;
|
|
342
|
+
script.onload = resolve;
|
|
343
|
+
script.onerror = reject;
|
|
344
|
+
document.head.appendChild(script);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* 兼容requestAnimationFrame
|
|
350
|
+
*
|
|
351
|
+
* @export
|
|
352
|
+
*/
|
|
353
|
+
function animationFramePolyfill() {
|
|
354
|
+
var lastTime = 0;
|
|
355
|
+
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
|
356
|
+
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
|
357
|
+
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
|
358
|
+
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (!window.requestAnimationFrame) {
|
|
362
|
+
window.requestAnimationFrame = function (callback, element) {
|
|
363
|
+
var currTime = new Date().getTime();
|
|
364
|
+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
|
365
|
+
var id = window.setTimeout(function () {
|
|
366
|
+
callback(currTime + timeToCall);
|
|
367
|
+
}, timeToCall);
|
|
368
|
+
lastTime = currTime + timeToCall;
|
|
369
|
+
return id;
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (!window.cancelAnimationFrame) {
|
|
374
|
+
window.cancelAnimationFrame = function (id) {
|
|
375
|
+
clearTimeout(id);
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// 兼容requestAnimationFrame
|
|
381
|
+
var compatibleAnimationFrame = exports.compatibleAnimationFrame = function compatibleAnimationFrame() {
|
|
382
|
+
var lastTime = 0;
|
|
383
|
+
var vendors = ['webkit', 'moz'];
|
|
384
|
+
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
|
385
|
+
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
|
386
|
+
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback, element) {
|
|
390
|
+
var currTime = new Date().getTime();
|
|
391
|
+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
|
392
|
+
var id = window.setTimeout(function () {
|
|
393
|
+
callback(currTime + timeToCall);
|
|
394
|
+
}, timeToCall);
|
|
395
|
+
lastTime = currTime + timeToCall;
|
|
396
|
+
return id;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) {
|
|
400
|
+
clearTimeout(id);
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* 创建script标签加载js
|
|
406
|
+
* @param {string} [url='']
|
|
407
|
+
* @returns
|
|
408
|
+
*/
|
|
409
|
+
var createScript = exports.createScript = function createScript() {
|
|
410
|
+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
411
|
+
|
|
412
|
+
var scriptTags = window.document.querySelectorAll('script');
|
|
413
|
+
var len = scriptTags.length;
|
|
414
|
+
var i = 0;
|
|
415
|
+
// 截取字符串,去掉可能url是相对路径的
|
|
416
|
+
url = url.indexOf('.') === 0 ? url.substr(1) : url;
|
|
417
|
+
var _url = location.origin + url;
|
|
418
|
+
return new _promise2.default(function (resolve, reject) {
|
|
419
|
+
var isHas = false;
|
|
420
|
+
for (i = 0; i < len; i++) {
|
|
421
|
+
var src = scriptTags[i].src;
|
|
422
|
+
if (src && src === _url) {
|
|
423
|
+
isHas = true;
|
|
424
|
+
resolve();
|
|
425
|
+
// scriptTags[i].parentElement.removeChild(scriptTags[i]);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (!isHas) {
|
|
429
|
+
var node = document.createElement('script');
|
|
430
|
+
node.type = 'text/javascript';
|
|
431
|
+
node.src = url;
|
|
432
|
+
node.onload = resolve;
|
|
433
|
+
document.body.appendChild(node);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* 图片转化
|
|
440
|
+
* @param {*} file
|
|
441
|
+
* @returns
|
|
442
|
+
*/
|
|
443
|
+
var getBase64 = exports.getBase64 = function getBase64(file) {
|
|
444
|
+
return new _promise2.default(function (resolve, reject) {
|
|
445
|
+
var reader = new FileReader();
|
|
446
|
+
reader.readAsDataURL(file);
|
|
447
|
+
reader.onload = function () {
|
|
448
|
+
return resolve(reader.result);
|
|
449
|
+
};
|
|
450
|
+
reader.onerror = function (error) {
|
|
451
|
+
return reject(error);
|
|
452
|
+
};
|
|
453
|
+
});
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
// 下载成绩单
|
|
457
|
+
var download = exports.download = function download(res) {
|
|
458
|
+
var blob = new Blob([res.data]);
|
|
459
|
+
// 提取文件名
|
|
460
|
+
var contentDisposition = '';
|
|
461
|
+
if (res.headers['content-disposition']) {
|
|
462
|
+
contentDisposition = res.headers['content-disposition'];
|
|
463
|
+
}
|
|
464
|
+
if (res.headers['Content-disposition']) {
|
|
465
|
+
contentDisposition = res.headers['Content-disposition'];
|
|
466
|
+
}
|
|
467
|
+
var err = contentDisposition.match(/err=(.*)/);
|
|
468
|
+
if (err && err[1]) {
|
|
469
|
+
message.error(decodeURI(err[1]));
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
var fileNameArr = contentDisposition.match(/filename=(.*)/);
|
|
473
|
+
if (!fileNameArr || !fileNameArr.length) {
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
|
+
var fileName = fileNameArr[1];
|
|
477
|
+
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
|
478
|
+
// 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
|
|
479
|
+
window.navigator.msSaveBlob(blob, decodeURI(fileName));
|
|
480
|
+
} else {
|
|
481
|
+
// 创建新的URL并指向File对象或者Blob对象的地址
|
|
482
|
+
var blobURL = window.URL.createObjectURL(blob);
|
|
483
|
+
// 创建a标签,用于跳转至下载链接
|
|
484
|
+
var tempLink = document.createElement('a');
|
|
485
|
+
tempLink.style.display = 'none';
|
|
486
|
+
tempLink.href = blobURL;
|
|
487
|
+
tempLink.setAttribute('download', decodeURI(fileName));
|
|
488
|
+
// 兼容:某些浏览器不支持HTML5的download属性
|
|
489
|
+
if (typeof tempLink.download === 'undefined') {
|
|
490
|
+
tempLink.setAttribute('target', '_blank');
|
|
491
|
+
}
|
|
492
|
+
// 挂载a标签
|
|
493
|
+
document.body.appendChild(tempLink);
|
|
494
|
+
tempLink.click();
|
|
495
|
+
document.body.removeChild(tempLink);
|
|
496
|
+
// 释放blob URL地址
|
|
497
|
+
window.URL.revokeObjectURL(blobURL);
|
|
498
|
+
}
|
|
499
|
+
return true;
|
|
327
500
|
};
|
package/lib/utils/common.js
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var _message2 = require('antd/lib/message');
|
|
9
|
-
|
|
10
|
-
var _message3 = _interopRequireDefault(_message2);
|
|
6
|
+
exports.specialParams = exports.isArrayFn = exports.deepCopy = exports.filterAuthMenus = exports.filterChildrenMenus = exports.findAuth = exports.handleMenus = exports.deepCheckField = exports.isEmpty = exports.updateDataSource = exports.exactAdd = exports.exactAdd1 = exports.summation = exports.deepTreeChildSum = exports.calcAfterBudgetSum = exports.setBudget = exports.setRowId = exports.deepTreeEditing = exports.deepTree = exports.removeTreeListItem = exports.formatFloat = exports.keepDecimal = exports.convertSmallHump = exports.ellipsis = exports.getOptions = exports.commonDataSource = exports.zipCodeRegExp = exports.emailRegExp = exports.officePhoneRegExp = exports.phoneRegExp = undefined;
|
|
11
7
|
|
|
12
8
|
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
13
9
|
|
|
@@ -31,8 +27,6 @@ var _select2 = _interopRequireDefault(_select);
|
|
|
31
27
|
|
|
32
28
|
var _arguments = arguments;
|
|
33
29
|
|
|
34
|
-
require('antd/lib/message/style');
|
|
35
|
-
|
|
36
30
|
require('antd/lib/select/style');
|
|
37
31
|
|
|
38
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -466,49 +460,4 @@ var specialParams = exports.specialParams = {
|
|
|
466
460
|
specialFunc: function specialFunc(dataIndex, record) {
|
|
467
461
|
return record.authorType === '1' && ['workCompany', 'title', 'degree'].includes(dataIndex);
|
|
468
462
|
}
|
|
469
|
-
|
|
470
|
-
// 下载成绩单
|
|
471
|
-
};var download = exports.download = function download(res) {
|
|
472
|
-
var blob = new Blob([res.data]);
|
|
473
|
-
// 提取文件名
|
|
474
|
-
var contentDisposition = '';
|
|
475
|
-
if (res.headers['content-disposition']) {
|
|
476
|
-
contentDisposition = res.headers['content-disposition'];
|
|
477
|
-
}
|
|
478
|
-
if (res.headers['Content-disposition']) {
|
|
479
|
-
contentDisposition = res.headers['Content-disposition'];
|
|
480
|
-
}
|
|
481
|
-
var err = contentDisposition.match(/err=(.*)/);
|
|
482
|
-
if (err && err[1]) {
|
|
483
|
-
_message3.default.error(decodeURI(err[1]));
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
var fileNameArr = contentDisposition.match(/filename=(.*)/);
|
|
487
|
-
if (!fileNameArr || !fileNameArr.length) {
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
var fileName = fileNameArr[1];
|
|
491
|
-
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
|
492
|
-
// 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
|
|
493
|
-
window.navigator.msSaveBlob(blob, decodeURI(fileName));
|
|
494
|
-
} else {
|
|
495
|
-
// 创建新的URL并指向File对象或者Blob对象的地址
|
|
496
|
-
var blobURL = window.URL.createObjectURL(blob);
|
|
497
|
-
// 创建a标签,用于跳转至下载链接
|
|
498
|
-
var tempLink = document.createElement('a');
|
|
499
|
-
tempLink.style.display = 'none';
|
|
500
|
-
tempLink.href = blobURL;
|
|
501
|
-
tempLink.setAttribute('download', decodeURI(fileName));
|
|
502
|
-
// 兼容:某些浏览器不支持HTML5的download属性
|
|
503
|
-
if (typeof tempLink.download === 'undefined') {
|
|
504
|
-
tempLink.setAttribute('target', '_blank');
|
|
505
|
-
}
|
|
506
|
-
// 挂载a标签
|
|
507
|
-
document.body.appendChild(tempLink);
|
|
508
|
-
tempLink.click();
|
|
509
|
-
document.body.removeChild(tempLink);
|
|
510
|
-
// 释放blob URL地址
|
|
511
|
-
window.URL.revokeObjectURL(blobURL);
|
|
512
|
-
}
|
|
513
|
-
return true;
|
|
514
463
|
};
|
package/lib/utils/index.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
9
|
-
|
|
10
|
-
var _stringify2 = _interopRequireDefault(_stringify);
|
|
6
|
+
exports.keyToLower = exports.randomNumEnum = exports.getValueFromArray = exports.getLabelValueTree = exports.cutArray = exports.arrayMove = exports.arrayMoveMutate = exports.checkPassword = exports.matchParamsPath = exports.urlToList = exports.getHashParam = exports.isUrl = exports.getRouterAuthority = exports.transformDate = exports.getStrLength = exports.DateUtil = exports._utf8_encode = exports.encode = exports.decode = undefined;
|
|
11
7
|
|
|
12
8
|
var _promise = require('babel-runtime/core-js/promise');
|
|
13
9
|
|
|
14
10
|
var _promise2 = _interopRequireDefault(_promise);
|
|
15
11
|
|
|
12
|
+
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
13
|
+
|
|
14
|
+
var _stringify2 = _interopRequireDefault(_stringify);
|
|
15
|
+
|
|
16
16
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
17
17
|
|
|
18
18
|
var _keys2 = _interopRequireDefault(_keys);
|
|
@@ -22,12 +22,10 @@ exports.queryArray = queryArray;
|
|
|
22
22
|
exports.arrayToTree = arrayToTree;
|
|
23
23
|
exports.delay = delay;
|
|
24
24
|
exports.transformFileToText = transformFileToText;
|
|
25
|
-
exports.animationFramePolyfill = animationFramePolyfill;
|
|
26
25
|
exports.isAccordReg = isAccordReg;
|
|
27
26
|
exports.isSearchKeyReg = isSearchKeyReg;
|
|
28
27
|
exports.toThousands = toThousands;
|
|
29
28
|
exports.findValueFormObject = findValueFormObject;
|
|
30
|
-
exports.loadScript = loadScript;
|
|
31
29
|
|
|
32
30
|
var _pathToRegexp = require('path-to-regexp');
|
|
33
31
|
|
|
@@ -35,55 +33,6 @@ var _pathToRegexp2 = _interopRequireDefault(_pathToRegexp);
|
|
|
35
33
|
|
|
36
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
35
|
|
|
38
|
-
/**
|
|
39
|
-
* 获取元素距离可视区域顶部、左部的距离
|
|
40
|
-
* @param {*} ele
|
|
41
|
-
* @returns
|
|
42
|
-
*/
|
|
43
|
-
var getOffset = exports.getOffset = function getOffset(ele) {
|
|
44
|
-
var top = ele.offsetTop;
|
|
45
|
-
var left = ele.offsetLeft;
|
|
46
|
-
while (ele.offsetParent) {
|
|
47
|
-
ele = ele.offsetParent;
|
|
48
|
-
if (window.navigator.userAgent.indexOf('MSTE 8') > -1) {
|
|
49
|
-
top += ele.offsetTop;
|
|
50
|
-
left += ele.offsetLeft;
|
|
51
|
-
} else {
|
|
52
|
-
top += ele.offsetTop + ele.clientTop;
|
|
53
|
-
left += ele.offsetLeft + ele.clientLeft;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
left: left,
|
|
58
|
-
top: top
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 获取窗口信息
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
/*
|
|
67
|
-
* @Description: 通用工具类
|
|
68
|
-
* @Author: admin
|
|
69
|
-
* @Date: 2020-03-06 09:45:52
|
|
70
|
-
* @LastEditors: jiangzhongxin
|
|
71
|
-
* @LastEditTime: 2023-10-17 09:46:26
|
|
72
|
-
*/
|
|
73
|
-
var getSize = exports.getSize = function getSize() {
|
|
74
|
-
var windowW = void 0,
|
|
75
|
-
windowH = void 0,
|
|
76
|
-
contentH = void 0,
|
|
77
|
-
contentW = void 0,
|
|
78
|
-
scrollT = void 0;
|
|
79
|
-
windowH = window.innerHeight;
|
|
80
|
-
windowW = window.innerWidth;
|
|
81
|
-
scrollT = document.documentElement.scrollTop || document.body.scrollTop;
|
|
82
|
-
contentH = document.documentElement.scrollHeight > document.body.scrollHeight ? document.documentElement.scrollHeight : document.body.scrollHeight;
|
|
83
|
-
contentW = document.documentElement.scrollWidth > document.body.scrollWidth ? document.documentElement.scrollWidth : document.body.scrollWidth;
|
|
84
|
-
return { windowW: windowW, windowH: windowH, contentH: contentH, contentW: contentW, scrollT: scrollT };
|
|
85
|
-
};
|
|
86
|
-
|
|
87
36
|
var decode = exports.decode = function decode(input) {
|
|
88
37
|
var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
89
38
|
var output = '';
|
|
@@ -114,8 +63,13 @@ var decode = exports.decode = function decode(input) {
|
|
|
114
63
|
}
|
|
115
64
|
output = _utf8_decode(output);
|
|
116
65
|
return output;
|
|
117
|
-
};
|
|
118
|
-
|
|
66
|
+
}; /*
|
|
67
|
+
* @Description: 通用工具类
|
|
68
|
+
* @Author: admin
|
|
69
|
+
* @Date: 2020-03-06 09:45:52
|
|
70
|
+
* @LastEditors: jiangzhongxin
|
|
71
|
+
* @LastEditTime: 2023-10-17 09:46:26
|
|
72
|
+
*/
|
|
119
73
|
var encode = exports.encode = function encode(input) {
|
|
120
74
|
var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
121
75
|
var output = '';
|
|
@@ -408,121 +362,6 @@ function splitString(str, num) {
|
|
|
408
362
|
return array;
|
|
409
363
|
}
|
|
410
364
|
|
|
411
|
-
// 兼容requestAnimationFrame
|
|
412
|
-
var compatibleAnimationFrame = exports.compatibleAnimationFrame = function compatibleAnimationFrame() {
|
|
413
|
-
var lastTime = 0;
|
|
414
|
-
var vendors = ['webkit', 'moz'];
|
|
415
|
-
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
|
416
|
-
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
|
417
|
-
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback, element) {
|
|
421
|
-
var currTime = new Date().getTime();
|
|
422
|
-
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
|
423
|
-
var id = window.setTimeout(function () {
|
|
424
|
-
callback(currTime + timeToCall);
|
|
425
|
-
}, timeToCall);
|
|
426
|
-
lastTime = currTime + timeToCall;
|
|
427
|
-
return id;
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) {
|
|
431
|
-
clearTimeout(id);
|
|
432
|
-
};
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* 图片转化
|
|
437
|
-
* @param {*} file
|
|
438
|
-
* @returns
|
|
439
|
-
*/
|
|
440
|
-
var getBase64 = exports.getBase64 = function getBase64(file) {
|
|
441
|
-
return new _promise2.default(function (resolve, reject) {
|
|
442
|
-
var reader = new FileReader();
|
|
443
|
-
reader.readAsDataURL(file);
|
|
444
|
-
reader.onload = function () {
|
|
445
|
-
return resolve(reader.result);
|
|
446
|
-
};
|
|
447
|
-
reader.onerror = function (error) {
|
|
448
|
-
return reject(error);
|
|
449
|
-
};
|
|
450
|
-
});
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* 创建script标签加载js
|
|
455
|
-
* @param {string} [url='']
|
|
456
|
-
* @returns
|
|
457
|
-
*/
|
|
458
|
-
var createScript = exports.createScript = function createScript() {
|
|
459
|
-
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
460
|
-
|
|
461
|
-
var scriptTags = window.document.querySelectorAll('script');
|
|
462
|
-
var len = scriptTags.length;
|
|
463
|
-
var i = 0;
|
|
464
|
-
// 截取字符串,去掉可能url是相对路径的
|
|
465
|
-
url = url.indexOf('.') === 0 ? url.substr(1) : url;
|
|
466
|
-
var _url = location.origin + url;
|
|
467
|
-
return new _promise2.default(function (resolve, reject) {
|
|
468
|
-
var isHas = false;
|
|
469
|
-
for (i = 0; i < len; i++) {
|
|
470
|
-
var src = scriptTags[i].src;
|
|
471
|
-
if (src && src === _url) {
|
|
472
|
-
isHas = true;
|
|
473
|
-
resolve();
|
|
474
|
-
// scriptTags[i].parentElement.removeChild(scriptTags[i]);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
if (!isHas) {
|
|
478
|
-
var node = document.createElement('script');
|
|
479
|
-
node.type = 'text/javascript';
|
|
480
|
-
node.src = url;
|
|
481
|
-
node.onload = resolve;
|
|
482
|
-
document.body.appendChild(node);
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* 获取UUID
|
|
489
|
-
* @returns
|
|
490
|
-
*/
|
|
491
|
-
var createUuid = exports.createUuid = function createUuid() {
|
|
492
|
-
var len = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 32;
|
|
493
|
-
var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16;
|
|
494
|
-
|
|
495
|
-
var chars = '0123456789abcdefghijklmnopqrstuvwxyz'.split('');
|
|
496
|
-
var uuid = [],
|
|
497
|
-
i;
|
|
498
|
-
radix = radix || chars.length;
|
|
499
|
-
|
|
500
|
-
if (len) {
|
|
501
|
-
// Compact form
|
|
502
|
-
for (i = 0; i < len; i++) {
|
|
503
|
-
uuid[i] = chars[0 | Math.random() * radix];
|
|
504
|
-
}
|
|
505
|
-
} else {
|
|
506
|
-
// rfc4122, version 4 form
|
|
507
|
-
var r;
|
|
508
|
-
|
|
509
|
-
// rfc4122 requires these characters
|
|
510
|
-
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
511
|
-
uuid[14] = '4';
|
|
512
|
-
|
|
513
|
-
// Fill in random data. At i==19 set the high bits of clock sequence as
|
|
514
|
-
// per rfc4122, sec. 4.1.5
|
|
515
|
-
for (i = 0; i < 36; i++) {
|
|
516
|
-
if (!uuid[i]) {
|
|
517
|
-
r = 0 | Math.random() * 16;
|
|
518
|
-
uuid[i] = chars[i == 19 ? r & 0x3 | 0x8 : r];
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
return uuid.join('');
|
|
524
|
-
};
|
|
525
|
-
|
|
526
365
|
/**
|
|
527
366
|
* 数组内查询
|
|
528
367
|
* @param {array} array
|
|
@@ -632,20 +471,6 @@ var getValueFromArray = exports.getValueFromArray = function getValueFromArray()
|
|
|
632
471
|
return res;
|
|
633
472
|
};
|
|
634
473
|
|
|
635
|
-
/**
|
|
636
|
-
* 获取元素的属性
|
|
637
|
-
* @version 171221 1.0
|
|
638
|
-
* @param {node} obj 元素
|
|
639
|
-
* @param {string} name 属性key
|
|
640
|
-
*/
|
|
641
|
-
var getStyle = exports.getStyle = function getStyle(obj, name) {
|
|
642
|
-
if (obj.currentStyle) {
|
|
643
|
-
return obj.currentStyle[name];
|
|
644
|
-
} else {
|
|
645
|
-
return getComputedStyle(obj, false)[name];
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
|
|
649
474
|
/**
|
|
650
475
|
* 延时
|
|
651
476
|
* @export
|
|
@@ -677,38 +502,6 @@ function transformFileToText(file) {
|
|
|
677
502
|
});
|
|
678
503
|
}
|
|
679
504
|
|
|
680
|
-
/**
|
|
681
|
-
* 兼容requestAnimationFrame
|
|
682
|
-
*
|
|
683
|
-
* @export
|
|
684
|
-
*/
|
|
685
|
-
function animationFramePolyfill() {
|
|
686
|
-
var lastTime = 0;
|
|
687
|
-
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
|
688
|
-
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
|
689
|
-
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
|
690
|
-
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
if (!window.requestAnimationFrame) {
|
|
694
|
-
window.requestAnimationFrame = function (callback, element) {
|
|
695
|
-
var currTime = new Date().getTime();
|
|
696
|
-
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
|
697
|
-
var id = window.setTimeout(function () {
|
|
698
|
-
callback(currTime + timeToCall);
|
|
699
|
-
}, timeToCall);
|
|
700
|
-
lastTime = currTime + timeToCall;
|
|
701
|
-
return id;
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
if (!window.cancelAnimationFrame) {
|
|
706
|
-
window.cancelAnimationFrame = function (id) {
|
|
707
|
-
clearTimeout(id);
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
505
|
/**
|
|
713
506
|
* 是否符合(中文、英文、汉字、汉字符号和 - _ 字符)
|
|
714
507
|
* @param {*} text
|
|
@@ -772,17 +565,6 @@ function findValueFormObject(source, findStr) {
|
|
|
772
565
|
return data;
|
|
773
566
|
}
|
|
774
567
|
|
|
775
|
-
function loadScript(src) {
|
|
776
|
-
return new _promise2.default(function (resolve, reject) {
|
|
777
|
-
var script = document.createElement('script');
|
|
778
|
-
script.type = 'text/javascript';
|
|
779
|
-
script.src = src;
|
|
780
|
-
script.onload = resolve;
|
|
781
|
-
script.onerror = reject;
|
|
782
|
-
document.head.appendChild(script);
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
|
|
786
568
|
/*******
|
|
787
569
|
* @description: 随机抽取数组中的n个值
|
|
788
570
|
* @author: 琴时
|
|
@@ -803,4 +585,15 @@ var randomNumEnum = exports.randomNumEnum = function randomNumEnum(array, num) {
|
|
|
803
585
|
shuffled[i] = temp;
|
|
804
586
|
}
|
|
805
587
|
return shuffled.slice(min);
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
// 将数组对象的key转成小写
|
|
591
|
+
var keyToLower = exports.keyToLower = function keyToLower(arr) {
|
|
592
|
+
return arr.map(function (obj) {
|
|
593
|
+
var newObj = {};
|
|
594
|
+
(0, _keys2.default)(obj).forEach(function (key) {
|
|
595
|
+
newObj[key.toLowerCase()] = obj[key];
|
|
596
|
+
});
|
|
597
|
+
return newObj;
|
|
598
|
+
});
|
|
806
599
|
};
|