feat: 调整基础类库加载
This commit is contained in:
@ -3,24 +3,6 @@
|
||||
*/
|
||||
|
||||
(function () {
|
||||
// Java格式化方法
|
||||
var str = Java.type('java.lang.String');
|
||||
String.prototype.format = function () {
|
||||
return str.format(this, Array.prototype.slice.call(arguments, 0))
|
||||
};
|
||||
|
||||
// ========== 暂不扩展Object ==========
|
||||
// // JSON快捷方法
|
||||
// Object.prototype.toJson = function () {
|
||||
// return JSON.stringify(this);
|
||||
// };
|
||||
|
||||
// // YAML快速生成
|
||||
// var yaml = require('modules/yaml');
|
||||
// Object.prototype.toYaml = function () {
|
||||
// return yaml.safeDump(this);
|
||||
// };
|
||||
|
||||
/**
|
||||
* 日期格式化
|
||||
* 例: new Date().format('yyyy-MM-dd hh:mm:ss.s') => "2017-08-24 16:15:40.693"
|
50
src/main/resources/core/ext/Object.js
Normal file
50
src/main/resources/core/ext/Object.js
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 补丁和方法扩展
|
||||
*/
|
||||
|
||||
(function () {
|
||||
// Object.assign Polyfill
|
||||
if (!Object.assign) {
|
||||
Object.defineProperty(Object, "assign", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function(target) {
|
||||
"use strict";
|
||||
if (target === undefined || target === null)
|
||||
throw new TypeError("Cannot convert first argument to object");
|
||||
var to = Object(target);
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var nextSource = arguments[i];
|
||||
if (nextSource === undefined || nextSource === null) continue;
|
||||
var keysArray = Object.keys(Object(nextSource));
|
||||
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
|
||||
var nextKey = keysArray[nextIndex];
|
||||
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
||||
if (desc !== undefined && desc.enumerable) to[nextKey] = nextSource[nextKey];
|
||||
}
|
||||
}
|
||||
return to;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// // JSON快捷方法
|
||||
if(!Object.toJson){
|
||||
Object.defineProperty(Object, "toJson", {
|
||||
enumerable: false,
|
||||
value: function() {
|
||||
return JSON.stringify(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Object.prototype.toJson = function () {
|
||||
// return JSON.stringify(this);
|
||||
// };
|
||||
|
||||
// // YAML快速生成
|
||||
// var yaml = require('modules/yaml');
|
||||
// Object.prototype.toYaml = function () {
|
||||
// return yaml.safeDump(this);
|
||||
// };
|
||||
})();
|
11
src/main/resources/core/ext/String.js
Normal file
11
src/main/resources/core/ext/String.js
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* 补丁和方法扩展
|
||||
*/
|
||||
|
||||
(function () {
|
||||
// Java格式化方法
|
||||
var str = Java.type('java.lang.String');
|
||||
String.prototype.format = function () {
|
||||
return str.format(this, Array.prototype.slice.call(arguments, 0))
|
||||
};
|
||||
})();
|
Reference in New Issue
Block a user