|
|
@ -3,7 +3,19 @@ |
|
|
|
* Create By GUY 2014\11\17 |
|
|
|
* Create By GUY 2014\11\17 |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function traverse (func, context) { |
|
|
|
import _ from "./1.lodash"; |
|
|
|
|
|
|
|
import { Widget } from "./4.widget"; |
|
|
|
|
|
|
|
import { createWidget } from "./5.inject"; |
|
|
|
|
|
|
|
import { prepares, _global } from "./0.foundation"; |
|
|
|
|
|
|
|
import { CRYPT_TYPE, aesDecrypt, aesEncrypt } from "./structure/aes"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* todo: 理论这么写,逻辑没问题,摇个人把这个 BI 干掉 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const BI = { _ }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function traverse(func, context) { |
|
|
|
return function (value, key, obj) { |
|
|
|
return function (value, key, obj) { |
|
|
|
return func.call(context, key, value, obj); |
|
|
|
return func.call(context, key, value, obj); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -16,7 +28,9 @@ function _apply(name) { |
|
|
|
function _applyFunc(name) { |
|
|
|
function _applyFunc(name) { |
|
|
|
return function () { |
|
|
|
return function () { |
|
|
|
const args = Array.prototype.slice.call(arguments, 0); |
|
|
|
const args = Array.prototype.slice.call(arguments, 0); |
|
|
|
args[1] = BI._.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1]; |
|
|
|
args[1] = BI._.isFunction(args[1]) |
|
|
|
|
|
|
|
? traverse(args[1], args[2]) |
|
|
|
|
|
|
|
: args[1]; |
|
|
|
|
|
|
|
|
|
|
|
return BI._[name](...args); |
|
|
|
return BI._[name](...args); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -45,7 +59,24 @@ export function warn(message) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function UUID() { |
|
|
|
export function UUID() { |
|
|
|
const f = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; |
|
|
|
const f = [ |
|
|
|
|
|
|
|
"0", |
|
|
|
|
|
|
|
"1", |
|
|
|
|
|
|
|
"2", |
|
|
|
|
|
|
|
"3", |
|
|
|
|
|
|
|
"4", |
|
|
|
|
|
|
|
"5", |
|
|
|
|
|
|
|
"6", |
|
|
|
|
|
|
|
"7", |
|
|
|
|
|
|
|
"8", |
|
|
|
|
|
|
|
"9", |
|
|
|
|
|
|
|
"a", |
|
|
|
|
|
|
|
"b", |
|
|
|
|
|
|
|
"c", |
|
|
|
|
|
|
|
"d", |
|
|
|
|
|
|
|
"e", |
|
|
|
|
|
|
|
"f" |
|
|
|
|
|
|
|
]; |
|
|
|
let str = ""; |
|
|
|
let str = ""; |
|
|
|
for (let i = 0; i < 16; i++) { |
|
|
|
for (let i = 0; i < 16; i++) { |
|
|
|
const r = _global.parseInt(f.length * Math.random(), 10); |
|
|
|
const r = _global.parseInt(f.length * Math.random(), 10); |
|
|
@ -56,7 +87,7 @@ export function UUID() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function isWidget(widget) { |
|
|
|
export function isWidget(widget) { |
|
|
|
return widget instanceof BI.Widget; |
|
|
|
return widget instanceof Widget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function createWidgets(items, options, context) { |
|
|
|
export function createWidgets(items, options, context) { |
|
|
@ -70,31 +101,37 @@ export function createWidgets(items, options, context) { |
|
|
|
options || (options = {}); |
|
|
|
options || (options = {}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return map(flatten(items), (i, item) => BI.createWidget(item, deepClone(options), context)); |
|
|
|
return map(flatten(items), (i, item) => |
|
|
|
|
|
|
|
createWidget(item, deepClone(options), context) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function createItems(data, innerAttr, outerAttr) { |
|
|
|
export function createItems(data, innerAttr, outerAttr) { |
|
|
|
innerAttr = isArray(innerAttr) ? innerAttr : makeArray(flatten(data).length, innerAttr || {}); |
|
|
|
innerAttr = isArray(innerAttr) |
|
|
|
outerAttr = isArray(outerAttr) ? outerAttr : makeArray(flatten(data).length, outerAttr || {}); |
|
|
|
? innerAttr |
|
|
|
|
|
|
|
: makeArray(flatten(data).length, innerAttr || {}); |
|
|
|
|
|
|
|
outerAttr = isArray(outerAttr) |
|
|
|
|
|
|
|
? outerAttr |
|
|
|
|
|
|
|
: makeArray(flatten(data).length, outerAttr || {}); |
|
|
|
|
|
|
|
|
|
|
|
return map(data, (i, item) => { |
|
|
|
return map(data, (i, item) => { |
|
|
|
if (isArray(item)) { |
|
|
|
if (isArray(item)) { |
|
|
|
return createItems(item, innerAttr, outerAttr); |
|
|
|
return createItems(item, innerAttr, outerAttr); |
|
|
|
} |
|
|
|
} |
|
|
|
if (item instanceof BI.Widget) { |
|
|
|
if (item instanceof Widget) { |
|
|
|
return extend({}, innerAttr.shift(), outerAttr.shift(), { |
|
|
|
return extend({}, innerAttr.shift(), outerAttr.shift(), { |
|
|
|
type: null, |
|
|
|
type: null, |
|
|
|
el: item, |
|
|
|
el: item, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (innerAttr[0] instanceof BI.Widget) { |
|
|
|
if (innerAttr[0] instanceof Widget) { |
|
|
|
outerAttr.shift(); |
|
|
|
outerAttr.shift(); |
|
|
|
|
|
|
|
|
|
|
|
return extend({}, item, { |
|
|
|
return extend({}, item, { |
|
|
|
el: innerAttr.shift(), |
|
|
|
el: innerAttr.shift(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (item.el instanceof BI.Widget) { |
|
|
|
if (item.el instanceof Widget) { |
|
|
|
innerAttr.shift(); |
|
|
|
innerAttr.shift(); |
|
|
|
|
|
|
|
|
|
|
|
return extend({}, outerAttr.shift(), { type: null }, item); |
|
|
|
return extend({}, outerAttr.shift(), { type: null }, item); |
|
|
@ -114,13 +151,15 @@ export function createItems(data, innerAttr, outerAttr) { |
|
|
|
// 用容器包装items
|
|
|
|
// 用容器包装items
|
|
|
|
export function packageItems(items, layouts) { |
|
|
|
export function packageItems(items, layouts) { |
|
|
|
for (let i = layouts.length - 1; i >= 0; i--) { |
|
|
|
for (let i = layouts.length - 1; i >= 0; i--) { |
|
|
|
items = map(items, (k, it) => extend({}, layouts[i], { |
|
|
|
items = map(items, (k, it) => |
|
|
|
items: [ |
|
|
|
extend({}, layouts[i], { |
|
|
|
extend({}, layouts[i].el, { |
|
|
|
items: [ |
|
|
|
el: it, |
|
|
|
extend({}, layouts[i].el, { |
|
|
|
}) |
|
|
|
el: it, |
|
|
|
], |
|
|
|
}) |
|
|
|
})); |
|
|
|
], |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return items; |
|
|
|
return items; |
|
|
@ -138,7 +177,7 @@ export function formatEL(obj) { |
|
|
|
|
|
|
|
|
|
|
|
// 剥开EL
|
|
|
|
// 剥开EL
|
|
|
|
export function stripEL(obj) { |
|
|
|
export function stripEL(obj) { |
|
|
|
return obj.type && obj || obj.el || obj; |
|
|
|
return (obj.type && obj) || obj.el || obj; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function trans2Element(widgets) { |
|
|
|
export function trans2Element(widgets) { |
|
|
@ -146,19 +185,53 @@ export function trans2Element(widgets) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 集合相关方法
|
|
|
|
// 集合相关方法
|
|
|
|
BI._.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], name => { |
|
|
|
BI._.each( |
|
|
|
BI[name] = _apply(name); |
|
|
|
[ |
|
|
|
}); |
|
|
|
"where", |
|
|
|
BI._.each([ |
|
|
|
"findWhere", |
|
|
|
"get", "set", "each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min", |
|
|
|
"invoke", |
|
|
|
"sortBy", "groupBy", "indexBy", "countBy", "partition", "clamp" |
|
|
|
"pluck", |
|
|
|
], name => { |
|
|
|
"shuffle", |
|
|
|
if (name === "any") { |
|
|
|
"sample", |
|
|
|
BI[name] = _applyFunc("some"); |
|
|
|
"toArray", |
|
|
|
} else { |
|
|
|
"size" |
|
|
|
BI[name] = _applyFunc(name); |
|
|
|
], |
|
|
|
|
|
|
|
name => { |
|
|
|
|
|
|
|
BI[name] = _apply(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
BI._.each( |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
"get", |
|
|
|
|
|
|
|
"set", |
|
|
|
|
|
|
|
"each", |
|
|
|
|
|
|
|
"map", |
|
|
|
|
|
|
|
"reduce", |
|
|
|
|
|
|
|
"reduceRight", |
|
|
|
|
|
|
|
"find", |
|
|
|
|
|
|
|
"filter", |
|
|
|
|
|
|
|
"reject", |
|
|
|
|
|
|
|
"every", |
|
|
|
|
|
|
|
"all", |
|
|
|
|
|
|
|
"some", |
|
|
|
|
|
|
|
"any", |
|
|
|
|
|
|
|
"max", |
|
|
|
|
|
|
|
"min", |
|
|
|
|
|
|
|
"sortBy", |
|
|
|
|
|
|
|
"groupBy", |
|
|
|
|
|
|
|
"indexBy", |
|
|
|
|
|
|
|
"countBy", |
|
|
|
|
|
|
|
"partition", |
|
|
|
|
|
|
|
"clamp" |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
name => { |
|
|
|
|
|
|
|
if (name === "any") { |
|
|
|
|
|
|
|
BI[name] = _applyFunc("some"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
BI[name] = _applyFunc(name); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
); |
|
|
|
export const where = BI.where; |
|
|
|
export const where = BI.where; |
|
|
|
export const findWhere = BI.findWhere; |
|
|
|
export const findWhere = BI.findWhere; |
|
|
|
export const invoke = BI.invoke; |
|
|
|
export const invoke = BI.invoke; |
|
|
@ -323,13 +396,23 @@ export function remove(obj, target, context) { |
|
|
|
let i; |
|
|
|
let i; |
|
|
|
if (isArray(obj)) { |
|
|
|
if (isArray(obj)) { |
|
|
|
for (i = 0; i < obj.length; i++) { |
|
|
|
for (i = 0; i < obj.length; i++) { |
|
|
|
if ((targetIsFunction && (target === obj[i] || target.apply(context, [i, obj[i]]) === true)) || (!targetIsFunction && contains(target, obj[i]))) { |
|
|
|
if ( |
|
|
|
|
|
|
|
(targetIsFunction && |
|
|
|
|
|
|
|
(target === obj[i] || |
|
|
|
|
|
|
|
target.apply(context, [i, obj[i]]) === true)) || |
|
|
|
|
|
|
|
(!targetIsFunction && contains(target, obj[i])) |
|
|
|
|
|
|
|
) { |
|
|
|
obj.splice(i--, 1); |
|
|
|
obj.splice(i--, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
each(obj, (i, v) => { |
|
|
|
each(obj, (i, v) => { |
|
|
|
if ((targetIsFunction && (target === obj[i] || target.apply(context, [i, obj[i]]) === true)) || (!targetIsFunction && contains(target, obj[i]))) { |
|
|
|
if ( |
|
|
|
|
|
|
|
(targetIsFunction && |
|
|
|
|
|
|
|
(target === obj[i] || |
|
|
|
|
|
|
|
target.apply(context, [i, obj[i]]) === true)) || |
|
|
|
|
|
|
|
(!targetIsFunction && contains(target, obj[i])) |
|
|
|
|
|
|
|
) { |
|
|
|
delete obj[i]; |
|
|
|
delete obj[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -362,10 +445,15 @@ export function array2String(array) { |
|
|
|
|
|
|
|
|
|
|
|
export function abc2Int(string) { |
|
|
|
export function abc2Int(string) { |
|
|
|
let idx = 0; |
|
|
|
let idx = 0; |
|
|
|
const start = "A", str = string.toUpperCase(); |
|
|
|
const start = "A", |
|
|
|
|
|
|
|
str = string.toUpperCase(); |
|
|
|
for (let i = 0, len = str.length; i < len; ++i) { |
|
|
|
for (let i = 0, len = str.length; i < len; ++i) { |
|
|
|
idx = str.charAt(i).charCodeAt(0) - start.charCodeAt(0) + 26 * idx + 1; |
|
|
|
idx = str.charAt(i).charCodeAt(0) - start.charCodeAt(0) + 26 * idx + 1; |
|
|
|
if (idx > (2147483646 - str.charAt(i).charCodeAt(0) + start.charCodeAt(0)) / 26) { |
|
|
|
if ( |
|
|
|
|
|
|
|
idx > |
|
|
|
|
|
|
|
(2147483646 - str.charAt(i).charCodeAt(0) + start.charCodeAt(0)) / |
|
|
|
|
|
|
|
26 |
|
|
|
|
|
|
|
) { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -374,8 +462,36 @@ export function abc2Int(string) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function int2Abc(num) { |
|
|
|
export function int2Abc(num) { |
|
|
|
const DIGITS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; |
|
|
|
const DIGITS = [ |
|
|
|
let idx = num, str = ""; |
|
|
|
"A", |
|
|
|
|
|
|
|
"B", |
|
|
|
|
|
|
|
"C", |
|
|
|
|
|
|
|
"D", |
|
|
|
|
|
|
|
"E", |
|
|
|
|
|
|
|
"F", |
|
|
|
|
|
|
|
"G", |
|
|
|
|
|
|
|
"H", |
|
|
|
|
|
|
|
"I", |
|
|
|
|
|
|
|
"J", |
|
|
|
|
|
|
|
"K", |
|
|
|
|
|
|
|
"L", |
|
|
|
|
|
|
|
"M", |
|
|
|
|
|
|
|
"N", |
|
|
|
|
|
|
|
"O", |
|
|
|
|
|
|
|
"P", |
|
|
|
|
|
|
|
"Q", |
|
|
|
|
|
|
|
"R", |
|
|
|
|
|
|
|
"S", |
|
|
|
|
|
|
|
"T", |
|
|
|
|
|
|
|
"U", |
|
|
|
|
|
|
|
"V", |
|
|
|
|
|
|
|
"W", |
|
|
|
|
|
|
|
"X", |
|
|
|
|
|
|
|
"Y", |
|
|
|
|
|
|
|
"Z" |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
let idx = num, |
|
|
|
|
|
|
|
str = ""; |
|
|
|
if (num === 0) { |
|
|
|
if (num === 0) { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
@ -392,12 +508,33 @@ export function int2Abc(num) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 数组相关的方法
|
|
|
|
// 数组相关的方法
|
|
|
|
BI._.each([ |
|
|
|
BI._.each( |
|
|
|
"first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection", |
|
|
|
[ |
|
|
|
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy" |
|
|
|
"first", |
|
|
|
], name => { |
|
|
|
"initial", |
|
|
|
BI[name] = _apply(name); |
|
|
|
"last", |
|
|
|
}); |
|
|
|
"rest", |
|
|
|
|
|
|
|
"compact", |
|
|
|
|
|
|
|
"flatten", |
|
|
|
|
|
|
|
"without", |
|
|
|
|
|
|
|
"union", |
|
|
|
|
|
|
|
"intersection", |
|
|
|
|
|
|
|
"difference", |
|
|
|
|
|
|
|
"zip", |
|
|
|
|
|
|
|
"unzip", |
|
|
|
|
|
|
|
"object", |
|
|
|
|
|
|
|
"indexOf", |
|
|
|
|
|
|
|
"lastIndexOf", |
|
|
|
|
|
|
|
"sortedIndex", |
|
|
|
|
|
|
|
"range", |
|
|
|
|
|
|
|
"take", |
|
|
|
|
|
|
|
"takeRight", |
|
|
|
|
|
|
|
"uniqBy" |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
name => { |
|
|
|
|
|
|
|
BI[name] = _apply(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
BI._.each(["findIndex", "findLastIndex"], name => { |
|
|
|
BI._.each(["findIndex", "findLastIndex"], name => { |
|
|
|
BI[name] = _applyFunc(name); |
|
|
|
BI[name] = _applyFunc(name); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -484,14 +621,48 @@ export function uniq(array, isSorted, iteratee, context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 对象相关方法
|
|
|
|
// 对象相关方法
|
|
|
|
BI._.each([ |
|
|
|
BI._.each( |
|
|
|
"keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn", |
|
|
|
[ |
|
|
|
"defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty", |
|
|
|
"keys", |
|
|
|
"isElement", "isNumber", "isString", "isArray", "isObject", "isPlainObject", "isArguments", "isFunction", "isFinite", |
|
|
|
"allKeys", |
|
|
|
"isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep", "pickBy" |
|
|
|
"values", |
|
|
|
], name => { |
|
|
|
"pairs", |
|
|
|
BI[name] = _apply(name); |
|
|
|
"invert", |
|
|
|
}); |
|
|
|
"create", |
|
|
|
|
|
|
|
"functions", |
|
|
|
|
|
|
|
"extend", |
|
|
|
|
|
|
|
"extendOwn", |
|
|
|
|
|
|
|
"defaults", |
|
|
|
|
|
|
|
"clone", |
|
|
|
|
|
|
|
"property", |
|
|
|
|
|
|
|
"propertyOf", |
|
|
|
|
|
|
|
"matcher", |
|
|
|
|
|
|
|
"isEqual", |
|
|
|
|
|
|
|
"isMatch", |
|
|
|
|
|
|
|
"isEmpty", |
|
|
|
|
|
|
|
"isElement", |
|
|
|
|
|
|
|
"isNumber", |
|
|
|
|
|
|
|
"isString", |
|
|
|
|
|
|
|
"isArray", |
|
|
|
|
|
|
|
"isObject", |
|
|
|
|
|
|
|
"isPlainObject", |
|
|
|
|
|
|
|
"isArguments", |
|
|
|
|
|
|
|
"isFunction", |
|
|
|
|
|
|
|
"isFinite", |
|
|
|
|
|
|
|
"isBoolean", |
|
|
|
|
|
|
|
"isDate", |
|
|
|
|
|
|
|
"isRegExp", |
|
|
|
|
|
|
|
"isError", |
|
|
|
|
|
|
|
"isNaN", |
|
|
|
|
|
|
|
"isUndefined", |
|
|
|
|
|
|
|
"zipObject", |
|
|
|
|
|
|
|
"cloneDeep", |
|
|
|
|
|
|
|
"pickBy" |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
name => { |
|
|
|
|
|
|
|
BI[name] = _apply(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
export const keys = BI.keys; |
|
|
|
export const keys = BI.keys; |
|
|
|
export const allKeys = BI.allKeys; |
|
|
|
export const allKeys = BI.allKeys; |
|
|
|
export const values = BI.values; |
|
|
|
export const values = BI.values; |
|
|
@ -538,10 +709,10 @@ export const omit = BI.omit; |
|
|
|
export const tap = BI.tap; |
|
|
|
export const tap = BI.tap; |
|
|
|
|
|
|
|
|
|
|
|
export function inherit(sp, overrides) { |
|
|
|
export function inherit(sp, overrides) { |
|
|
|
function sb () { |
|
|
|
function sb() { |
|
|
|
return sp.apply(this, arguments); |
|
|
|
return sp.apply(this, arguments); |
|
|
|
} |
|
|
|
} |
|
|
|
function F () {} |
|
|
|
function F() {} |
|
|
|
const spp = sp.prototype; |
|
|
|
const spp = sp.prototype; |
|
|
|
F.prototype = spp; |
|
|
|
F.prototype = spp; |
|
|
|
sb.prototype = new F(); |
|
|
|
sb.prototype = new F(); |
|
|
@ -555,10 +726,13 @@ export function inherit(sp, overrides) { |
|
|
|
|
|
|
|
|
|
|
|
export function init() { |
|
|
|
export function init() { |
|
|
|
// 先把准备环境准备好
|
|
|
|
// 先把准备环境准备好
|
|
|
|
while (BI.prepares && BI.prepares.length > 0) { |
|
|
|
while (prepares && prepares.length > 0) { |
|
|
|
BI.prepares.shift()(); |
|
|
|
prepares.shift()(); |
|
|
|
} |
|
|
|
} |
|
|
|
while (_global.___fineuiExposedFunction && _global.___fineuiExposedFunction.length > 0) { |
|
|
|
while ( |
|
|
|
|
|
|
|
_global.___fineuiExposedFunction && |
|
|
|
|
|
|
|
_global.___fineuiExposedFunction.length > 0 |
|
|
|
|
|
|
|
) { |
|
|
|
_global.___fineuiExposedFunction.shift()(); |
|
|
|
_global.___fineuiExposedFunction.shift()(); |
|
|
|
} |
|
|
|
} |
|
|
|
BI.initialized = true; |
|
|
|
BI.initialized = true; |
|
|
@ -593,8 +767,8 @@ export function isKey(key) { |
|
|
|
|
|
|
|
|
|
|
|
// 忽略大小写的等于
|
|
|
|
// 忽略大小写的等于
|
|
|
|
export function isCapitalEqual(a, b) { |
|
|
|
export function isCapitalEqual(a, b) { |
|
|
|
a = isNull(a) ? a : (`${a}`).toLowerCase(); |
|
|
|
a = isNull(a) ? a : `${a}`.toLowerCase(); |
|
|
|
b = isNull(b) ? b : (`${b}`).toLowerCase(); |
|
|
|
b = isNull(b) ? b : `${b}`.toLowerCase(); |
|
|
|
|
|
|
|
|
|
|
|
return isEqual(a, b); |
|
|
|
return isEqual(a, b); |
|
|
|
} |
|
|
|
} |
|
|
@ -603,7 +777,12 @@ export function isWidthOrHeight(w) { |
|
|
|
if (typeof w === "number") { |
|
|
|
if (typeof w === "number") { |
|
|
|
return w >= 0; |
|
|
|
return w >= 0; |
|
|
|
} else if (typeof w === "string") { |
|
|
|
} else if (typeof w === "string") { |
|
|
|
return /^\d{1,3}(\.\d)?%$/.test(w) || w === "auto" || /^\d+(\.\d+)?px$/.test(w) || /^calc/.test(w); |
|
|
|
return ( |
|
|
|
|
|
|
|
/^\d{1,3}(\.\d)?%$/.test(w) || |
|
|
|
|
|
|
|
w === "auto" || |
|
|
|
|
|
|
|
/^\d+(\.\d+)?px$/.test(w) || |
|
|
|
|
|
|
|
/^calc/.test(w) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -643,7 +822,8 @@ export const deepClone = BI._.cloneDeep; |
|
|
|
export const deepExtend = BI._.merge; |
|
|
|
export const deepExtend = BI._.merge; |
|
|
|
|
|
|
|
|
|
|
|
export function isDeepMatch(object, attrs) { |
|
|
|
export function isDeepMatch(object, attrs) { |
|
|
|
const attrsKeys = keys(attrs), length = attrsKeys.length; |
|
|
|
const attrsKeys = keys(attrs), |
|
|
|
|
|
|
|
length = attrsKeys.length; |
|
|
|
if (object === null) { |
|
|
|
if (object === null) { |
|
|
|
return !length; |
|
|
|
return !length; |
|
|
|
} |
|
|
|
} |
|
|
@ -661,7 +841,9 @@ export function isDeepMatch(object, attrs) { |
|
|
|
export function contains(obj, target, fromIndex) { |
|
|
|
export function contains(obj, target, fromIndex) { |
|
|
|
if (!BI._.isArrayLike(obj)) obj = values(obj); |
|
|
|
if (!BI._.isArrayLike(obj)) obj = values(obj); |
|
|
|
|
|
|
|
|
|
|
|
return indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0; |
|
|
|
return ( |
|
|
|
|
|
|
|
indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0 |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function deepContains(obj, copy) { |
|
|
|
export function deepContains(obj, copy) { |
|
|
@ -760,9 +942,21 @@ export function deepDiff(object, other) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 通用方法
|
|
|
|
// 通用方法
|
|
|
|
BI._.each(["uniqueId", "result", "chain", "iteratee", "unescape", "before", "after", "chunk"], name => { |
|
|
|
BI._.each( |
|
|
|
BI[name] = (...args) => BI._[name](...args); |
|
|
|
[ |
|
|
|
}); |
|
|
|
"uniqueId", |
|
|
|
|
|
|
|
"result", |
|
|
|
|
|
|
|
"chain", |
|
|
|
|
|
|
|
"iteratee", |
|
|
|
|
|
|
|
"unescape", |
|
|
|
|
|
|
|
"before", |
|
|
|
|
|
|
|
"after", |
|
|
|
|
|
|
|
"chunk" |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
name => { |
|
|
|
|
|
|
|
BI[name] = (...args) => BI._[name](...args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
export const uniqueId = BI.uniqueId; |
|
|
|
export const uniqueId = BI.uniqueId; |
|
|
|
export const result = BI.result; |
|
|
|
export const result = BI.result; |
|
|
|
export const chain = BI.chain; |
|
|
|
export const chain = BI.chain; |
|
|
@ -773,9 +967,21 @@ export const after = BI.after; |
|
|
|
export const chunk = BI.chunk; |
|
|
|
export const chunk = BI.chunk; |
|
|
|
|
|
|
|
|
|
|
|
// 事件相关方法
|
|
|
|
// 事件相关方法
|
|
|
|
BI._.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], name => { |
|
|
|
BI._.each( |
|
|
|
BI[name] = (...args) => BI._[name](...args); |
|
|
|
[ |
|
|
|
}); |
|
|
|
"bind", |
|
|
|
|
|
|
|
"once", |
|
|
|
|
|
|
|
"partial", |
|
|
|
|
|
|
|
"debounce", |
|
|
|
|
|
|
|
"throttle", |
|
|
|
|
|
|
|
"delay", |
|
|
|
|
|
|
|
"defer", |
|
|
|
|
|
|
|
"wrap" |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
name => { |
|
|
|
|
|
|
|
BI[name] = (...args) => BI._[name](...args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
export const bind = BI.bind; |
|
|
|
export const bind = BI.bind; |
|
|
|
export const once = BI.once; |
|
|
|
export const once = BI.once; |
|
|
|
export const partial = BI.partial; |
|
|
|
export const partial = BI.partial; |
|
|
@ -846,9 +1052,9 @@ export const nextTick = (function () { |
|
|
|
} |
|
|
|
} |
|
|
|
// $flow-disable-line
|
|
|
|
// $flow-disable-line
|
|
|
|
if (!cb && typeof Promise !== "undefined") { |
|
|
|
if (!cb && typeof Promise !== "undefined") { |
|
|
|
return new Promise(((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
_resolve = resolve; |
|
|
|
_resolve = resolve; |
|
|
|
})); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
}()); |
|
|
|
}()); |
|
|
@ -876,7 +1082,9 @@ export function parseSafeInt(value) { |
|
|
|
|
|
|
|
|
|
|
|
return value |
|
|
|
return value |
|
|
|
? clamp(parseInt(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) |
|
|
|
? clamp(parseInt(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) |
|
|
|
: (value === 0 ? value : 0); |
|
|
|
: value === 0 |
|
|
|
|
|
|
|
? value |
|
|
|
|
|
|
|
: 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function parseFloat(number) { |
|
|
|
export function parseFloat(number) { |
|
|
@ -904,7 +1112,9 @@ export function isInteger(number) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function isNumeric(number) { |
|
|
|
export function isNumeric(number) { |
|
|
|
return !_global.isNaN(_global.parseFloat(number)) && _global.isFinite(number); |
|
|
|
return ( |
|
|
|
|
|
|
|
!_global.isNaN(_global.parseFloat(number)) && _global.isFinite(number) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function isFloat(number) { |
|
|
|
export function isFloat(number) { |
|
|
@ -951,11 +1161,11 @@ export function trim(...args) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function toUpperCase(string) { |
|
|
|
export function toUpperCase(string) { |
|
|
|
return (`${string}`).toLocaleUpperCase(); |
|
|
|
return `${string}`.toLocaleUpperCase(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function toLowerCase(string) { |
|
|
|
export function toLowerCase(string) { |
|
|
|
return (`${string}`).toLocaleLowerCase(); |
|
|
|
return `${string}`.toLocaleLowerCase(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function isEndWithBlank(string) { |
|
|
|
export function isEndWithBlank(string) { |
|
|
@ -970,9 +1180,7 @@ export function stripQuotes(str) { |
|
|
|
const a = str.charCodeAt(0); |
|
|
|
const a = str.charCodeAt(0); |
|
|
|
const b = str.charCodeAt(str.length - 1); |
|
|
|
const b = str.charCodeAt(str.length - 1); |
|
|
|
|
|
|
|
|
|
|
|
return a === b && (a === 0x22 || a === 0x27) |
|
|
|
return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str; |
|
|
|
? str.slice(1, -1) |
|
|
|
|
|
|
|
: str; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// background-color => backgroundColor
|
|
|
|
// background-color => backgroundColor
|
|
|
@ -1002,9 +1210,9 @@ export function isEmptyString(str) { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export function encrypt(type, text, key) { |
|
|
|
export function encrypt(type, text, key) { |
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
|
case BI.CRYPT_TYPE.AES: |
|
|
|
case CRYPT_TYPE.AES: |
|
|
|
default: |
|
|
|
default: |
|
|
|
return BI.aesEncrypt(text, key); |
|
|
|
return aesEncrypt(text, key); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1017,9 +1225,9 @@ export function encrypt(type, text, key) { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export function decrypt(type, text, key) { |
|
|
|
export function decrypt(type, text, key) { |
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
|
case BI.CRYPT_TYPE.AES: |
|
|
|
case CRYPT_TYPE.AES: |
|
|
|
default: |
|
|
|
default: |
|
|
|
return BI.aesDecrypt(text, key); |
|
|
|
return aesDecrypt(text, key); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1033,7 +1241,6 @@ export function escape(string) { |
|
|
|
return string.replace(/('|\\)/g, "\\$1"); |
|
|
|
return string.replace(/('|\\)/g, "\\$1"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 让字符串通过指定字符做补齐的函数 |
|
|
|
* 让字符串通过指定字符做补齐的函数 |
|
|
|
* |
|
|
|
* |
|
|
@ -1130,7 +1337,9 @@ export function checkDateVoid(YY, MM, DD, minDate, maxDate) { |
|
|
|
|
|
|
|
|
|
|
|
export function checkDateLegal(str) { |
|
|
|
export function checkDateLegal(str) { |
|
|
|
const ar = str.match(/\d+/g); |
|
|
|
const ar = str.match(/\d+/g); |
|
|
|
const YY = ar[0] | 0, MM = ar[1] | 0, DD = ar[2] | 0; |
|
|
|
const YY = ar[0] | 0, |
|
|
|
|
|
|
|
MM = ar[1] | 0, |
|
|
|
|
|
|
|
DD = ar[2] | 0; |
|
|
|
if (ar.length <= 1) { |
|
|
|
if (ar.length <= 1) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -1162,69 +1371,77 @@ export function parseDateTime(str, fmt) { |
|
|
|
const otherlength = 2; |
|
|
|
const otherlength = 2; |
|
|
|
a[0] = str.substring(0, yearlength); |
|
|
|
a[0] = str.substring(0, yearlength); |
|
|
|
a[1] = str.substring(yearlength, yearlength + otherlength); |
|
|
|
a[1] = str.substring(yearlength, yearlength + otherlength); |
|
|
|
a[2] = str.substring(yearlength + otherlength, yearlength + otherlength * 2); |
|
|
|
a[2] = str.substring( |
|
|
|
|
|
|
|
yearlength + otherlength, |
|
|
|
|
|
|
|
yearlength + otherlength * 2 |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
const b = fmt.match(/%./g); |
|
|
|
const b = fmt.match(/%./g); |
|
|
|
let i = 0, j = 0; |
|
|
|
let i = 0, |
|
|
|
|
|
|
|
j = 0; |
|
|
|
let hr = 0; |
|
|
|
let hr = 0; |
|
|
|
let min = 0; |
|
|
|
let min = 0; |
|
|
|
let sec = 0; |
|
|
|
let sec = 0; |
|
|
|
for (i = 0; i < a.length; ++i) { |
|
|
|
for (i = 0; i < a.length; ++i) { |
|
|
|
switch (b[i]) { |
|
|
|
switch (b[i]) { |
|
|
|
case "%d": |
|
|
|
case "%d": |
|
|
|
case "%e": |
|
|
|
case "%e": |
|
|
|
d = _global.parseInt(a[i], 10); |
|
|
|
d = _global.parseInt(a[i], 10); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case "%X": |
|
|
|
case "%X": |
|
|
|
m = _global.parseInt(a[i], 10) - 1; |
|
|
|
m = _global.parseInt(a[i], 10) - 1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "%x": |
|
|
|
case "%x": |
|
|
|
m = _global.parseInt(a[i], 10) - 1; |
|
|
|
m = _global.parseInt(a[i], 10) - 1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case "%Y": |
|
|
|
case "%Y": |
|
|
|
case "%y": |
|
|
|
case "%y": |
|
|
|
y = _global.parseInt(a[i], 10); |
|
|
|
y = _global.parseInt(a[i], 10); |
|
|
|
(y < 100) && (y += (y > 29) ? 1900 : 2000); |
|
|
|
y < 100 && (y += y > 29 ? 1900 : 2000); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case "%b": |
|
|
|
case "%b": |
|
|
|
case "%B": |
|
|
|
case "%B": |
|
|
|
for (j = 0; j < 12; ++j) { |
|
|
|
for (j = 0; j < 12; ++j) { |
|
|
|
if (BI.getMonthName(j).substr(0, a[i].length).toLowerCase() === a[i].toLowerCase()) { |
|
|
|
if ( |
|
|
|
m = j; |
|
|
|
BI.getMonthName(j) |
|
|
|
break; |
|
|
|
.substr(0, a[i].length) |
|
|
|
|
|
|
|
.toLowerCase() === a[i].toLowerCase() |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
m = j; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case "%H": |
|
|
|
case "%H": |
|
|
|
case "%I": |
|
|
|
case "%I": |
|
|
|
case "%k": |
|
|
|
case "%k": |
|
|
|
case "%l": |
|
|
|
case "%l": |
|
|
|
hr = _global.parseInt(a[i], 10); |
|
|
|
hr = _global.parseInt(a[i], 10); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case "%P": |
|
|
|
case "%P": |
|
|
|
case "%p": |
|
|
|
case "%p": |
|
|
|
if (/pm/i.test(a[i]) && hr < 12) { |
|
|
|
if (/pm/i.test(a[i]) && hr < 12) { |
|
|
|
hr += 12; |
|
|
|
hr += 12; |
|
|
|
} else if (/am/i.test(a[i]) && hr >= 12) { |
|
|
|
} else if (/am/i.test(a[i]) && hr >= 12) { |
|
|
|
hr -= 12; |
|
|
|
hr -= 12; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "%Q": |
|
|
|
case "%Q": |
|
|
|
case "%q": |
|
|
|
case "%q": |
|
|
|
m = (_global.parseInt(a[i], 10) - 1) * 3; |
|
|
|
m = (_global.parseInt(a[i], 10) - 1) * 3; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "%M": |
|
|
|
case "%M": |
|
|
|
min = _global.parseInt(a[i], 10); |
|
|
|
min = _global.parseInt(a[i], 10); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "%S": |
|
|
|
case "%S": |
|
|
|
sec = _global.parseInt(a[i], 10); |
|
|
|
sec = _global.parseInt(a[i], 10); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// if (!a[i]) {
|
|
|
|
// if (!a[i]) {
|
|
|
@ -1258,7 +1475,10 @@ export function parseDateTime(str, fmt) { |
|
|
|
if (a[i].search(/[a-zA-Z]+/) !== -1) { |
|
|
|
if (a[i].search(/[a-zA-Z]+/) !== -1) { |
|
|
|
let t = -1; |
|
|
|
let t = -1; |
|
|
|
for (j = 0; j < 12; ++j) { |
|
|
|
for (j = 0; j < 12; ++j) { |
|
|
|
if (BI.getMonthName(j).substr(0, a[i].length).toLowerCase() === a[i].toLowerCase()) { |
|
|
|
if ( |
|
|
|
|
|
|
|
BI.getMonthName(j).substr(0, a[i].length).toLowerCase() === |
|
|
|
|
|
|
|
a[i].toLowerCase() |
|
|
|
|
|
|
|
) { |
|
|
|
t = j; |
|
|
|
t = j; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -1273,7 +1493,7 @@ export function parseDateTime(str, fmt) { |
|
|
|
m = a[i] - 1; |
|
|
|
m = a[i] - 1; |
|
|
|
} else if (_global.parseInt(a[i], 10) > 31 && y === 0) { |
|
|
|
} else if (_global.parseInt(a[i], 10) > 31 && y === 0) { |
|
|
|
y = _global.parseInt(a[i], 10); |
|
|
|
y = _global.parseInt(a[i], 10); |
|
|
|
(y < 100) && (y += (y > 29) ? 1900 : 2000); |
|
|
|
y < 100 && (y += y > 29 ? 1900 : 2000); |
|
|
|
} else if (d === 0) { |
|
|
|
} else if (d === 0) { |
|
|
|
d = a[i]; |
|
|
|
d = a[i]; |
|
|
|
} |
|
|
|
} |
|
|
@ -1295,49 +1515,61 @@ export function getDate(...args) { |
|
|
|
const length = args.length; |
|
|
|
const length = args.length; |
|
|
|
let dt; |
|
|
|
let dt; |
|
|
|
switch (length) { |
|
|
|
switch (length) { |
|
|
|
// new Date()
|
|
|
|
// new Date()
|
|
|
|
case 0: |
|
|
|
case 0: |
|
|
|
dt = new Date(); |
|
|
|
dt = new Date(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(long)
|
|
|
|
// new Date(long)
|
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
dt = new Date(args[0]); |
|
|
|
dt = new Date(args[0]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month)
|
|
|
|
// new Date(year, month)
|
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
dt = new Date(args[0], args[1]); |
|
|
|
dt = new Date(args[0], args[1]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day)
|
|
|
|
// new Date(year, month, day)
|
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
dt = new Date(args[0], args[1], args[2]); |
|
|
|
dt = new Date(args[0], args[1], args[2]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day, hour)
|
|
|
|
// new Date(year, month, day, hour)
|
|
|
|
case 4: |
|
|
|
case 4: |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3]); |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day, hour, minute)
|
|
|
|
// new Date(year, month, day, hour, minute)
|
|
|
|
case 5: |
|
|
|
case 5: |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4]); |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day, hour, minute, second)
|
|
|
|
// new Date(year, month, day, hour, minute, second)
|
|
|
|
case 6: |
|
|
|
case 6: |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4], args[5]); |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4], args[5]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day, hour, minute, second, millisecond)
|
|
|
|
// new Date(year, month, day, hour, minute, second, millisecond)
|
|
|
|
case 7: |
|
|
|
case 7: |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); |
|
|
|
dt = new Date( |
|
|
|
break; |
|
|
|
args[0], |
|
|
|
default: |
|
|
|
args[1], |
|
|
|
dt = new Date(); |
|
|
|
args[2], |
|
|
|
break; |
|
|
|
args[3], |
|
|
|
} |
|
|
|
args[4], |
|
|
|
if (isNotNull(BI.timeZone) && (arguments.length === 0 || (arguments.length === 1 && isNumber(arguments[0])))) { |
|
|
|
args[5], |
|
|
|
|
|
|
|
args[6] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
dt = new Date(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
isNotNull(BI.timeZone) && |
|
|
|
|
|
|
|
(arguments.length === 0 || |
|
|
|
|
|
|
|
(arguments.length === 1 && isNumber(arguments[0]))) |
|
|
|
|
|
|
|
) { |
|
|
|
const localTime = dt.getTime(); |
|
|
|
const localTime = dt.getTime(); |
|
|
|
// BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准
|
|
|
|
// BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准
|
|
|
|
const localOffset = dt.getTimezoneOffset() * 60000; // 获得当地时间偏移的毫秒数
|
|
|
|
const localOffset = dt.getTimezoneOffset() * 60000; // 获得当地时间偏移的毫秒数
|
|
|
|
const utc = localTime + localOffset; // utc即GMT时间标准时区
|
|
|
|
const utc = localTime + localOffset; // utc即GMT时间标准时区
|
|
|
|
|
|
|
|
|
|
|
|
return new Date(utc + BI.timeZone);// + Pool.timeZone.offset);
|
|
|
|
return new Date(utc + BI.timeZone); // + Pool.timeZone.offset);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return dt; |
|
|
|
return dt; |
|
|
@ -1348,47 +1580,59 @@ export function getTime() { |
|
|
|
const args = arguments; |
|
|
|
const args = arguments; |
|
|
|
let dt; |
|
|
|
let dt; |
|
|
|
switch (length) { |
|
|
|
switch (length) { |
|
|
|
// new Date()
|
|
|
|
// new Date()
|
|
|
|
case 0: |
|
|
|
case 0: |
|
|
|
dt = new Date(); |
|
|
|
dt = new Date(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(long)
|
|
|
|
// new Date(long)
|
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
dt = new Date(args[0]); |
|
|
|
dt = new Date(args[0]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month)
|
|
|
|
// new Date(year, month)
|
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
dt = new Date(args[0], args[1]); |
|
|
|
dt = new Date(args[0], args[1]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day)
|
|
|
|
// new Date(year, month, day)
|
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
dt = new Date(args[0], args[1], args[2]); |
|
|
|
dt = new Date(args[0], args[1], args[2]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day, hour)
|
|
|
|
// new Date(year, month, day, hour)
|
|
|
|
case 4: |
|
|
|
case 4: |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3]); |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day, hour, minute)
|
|
|
|
// new Date(year, month, day, hour, minute)
|
|
|
|
case 5: |
|
|
|
case 5: |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4]); |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day, hour, minute, second)
|
|
|
|
// new Date(year, month, day, hour, minute, second)
|
|
|
|
case 6: |
|
|
|
case 6: |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4], args[5]); |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4], args[5]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
// new Date(year, month, day, hour, minute, second, millisecond)
|
|
|
|
// new Date(year, month, day, hour, minute, second, millisecond)
|
|
|
|
case 7: |
|
|
|
case 7: |
|
|
|
dt = new Date(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); |
|
|
|
dt = new Date( |
|
|
|
break; |
|
|
|
args[0], |
|
|
|
default: |
|
|
|
args[1], |
|
|
|
dt = new Date(); |
|
|
|
args[2], |
|
|
|
break; |
|
|
|
args[3], |
|
|
|
|
|
|
|
args[4], |
|
|
|
|
|
|
|
args[5], |
|
|
|
|
|
|
|
args[6] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
dt = new Date(); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isNotNull(BI.timeZone)) { |
|
|
|
if (isNotNull(BI.timeZone)) { |
|
|
|
// BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准
|
|
|
|
// BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准
|
|
|
|
return dt.getTime() - BI.timeZone - new Date().getTimezoneOffset() * 60000; |
|
|
|
return ( |
|
|
|
|
|
|
|
dt.getTime() - BI.timeZone - new Date().getTimezoneOffset() * 60000 |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return dt.getTime(); |
|
|
|
return dt.getTime(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const lodashUtils = BI._; |
|
|
|