Skip to content

Commit fc1df01

Browse files
committed
fix ICL-986 增加 SuperMap.CORS SuperMap.RequestTimeout两个配置
1 parent 91f9444 commit fc1df01

File tree

10 files changed

+123
-50
lines changed

10 files changed

+123
-50
lines changed

dist/iclient-classic.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,7 +2825,7 @@ _SuperMap.SuperMap.CommonServiceBase = CommonServiceBase;
28252825
Object.defineProperty(exports, "__esModule", {
28262826
value: true
28272827
});
2828-
exports.FetchRequest = exports.Support = undefined;
2828+
exports.FetchRequest = exports.RequestTimeout = exports.CORS = undefined;
28292829

28302830
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
28312831

@@ -2845,9 +2845,18 @@ var _Util = __webpack_require__(1);
28452845

28462846
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28472847

2848-
var Support = exports.Support = _SuperMap.SuperMap.Support = _SuperMap.SuperMap.Support || {
2849-
cors: window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest()
2850-
};
2848+
/**
2849+
* @member SuperMap.CORS
2850+
* @description 是否支持跨域
2851+
* @type {boolean}
2852+
*/
2853+
var CORS = exports.CORS = _SuperMap.SuperMap.CORS = _SuperMap.SuperMap.CORS || window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest();
2854+
/**
2855+
* @member SuperMap.RequestTimeout
2856+
* @description 请求超时时间,默认45s
2857+
* @type {number}
2858+
*/
2859+
var RequestTimeout = exports.RequestTimeout = _SuperMap.SuperMap.RequestTimeout = _SuperMap.SuperMap.RequestTimeout || 45000;
28512860
var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
28522861
commit: function commit(method, url, params, options) {
28532862
method = method ? method.toUpperCase() : method;
@@ -2871,7 +2880,7 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
28712880
url = this._processUrl(url, options);
28722881
url = _Util.Util.urlAppend(url, this._getParameterString(params || {}));
28732882
if (!this.urlIsLong(url)) {
2874-
if (_Util.Util.isInTheSameDomain(url) || Support.cors || options.proxy) {
2883+
if (_Util.Util.isInTheSameDomain(url) || CORS || options.proxy) {
28752884
return this._fetch(url, params, options, type);
28762885
}
28772886
if (!_Util.Util.isInTheSameDomain(url)) {
@@ -2887,7 +2896,7 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
28872896
var type = 'DELETE';
28882897
url = this._processUrl(url, options);
28892898
url = _Util.Util.urlAppend(url, this._getParameterString(params || {}));
2890-
if (!this.urlIsLong(url) && Support.cors) {
2899+
if (!this.urlIsLong(url) && CORS) {
28912900
return this._fetch(url, params, options, type);
28922901
}
28932902
return this._postSimulatie(type, url.substring(0, url.indexOf('?') - 1), params, options);
@@ -2966,7 +2975,8 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
29662975
headers: options.headers,
29672976
body: type === 'PUT' || type === 'POST' ? params : undefined,
29682977
credentials: options.withCredentials ? 'include' : 'omit',
2969-
mode: 'cors'
2978+
mode: 'cors',
2979+
timeout: RequestTimeout
29702980
}).then(function (response) {
29712981
return response;
29722982
}));
@@ -2976,7 +2986,8 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
29762986
body: type === 'PUT' || type === 'POST' ? params : undefined,
29772987
headers: options.headers,
29782988
credentials: options.withCredentials ? 'include' : 'omit',
2979-
mode: 'cors'
2989+
mode: 'cors',
2990+
timeout: RequestTimeout
29802991
}).then(function (response) {
29812992
return response;
29822993
});

dist/iclient-classic.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-leaflet.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8087,7 +8087,7 @@ _SuperMap.SuperMap.Feature.ShapeFactory = ShapeFactory;
80878087
Object.defineProperty(exports, "__esModule", {
80888088
value: true
80898089
});
8090-
exports.FetchRequest = exports.Support = undefined;
8090+
exports.FetchRequest = exports.RequestTimeout = exports.CORS = undefined;
80918091

80928092
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
80938093

@@ -8107,9 +8107,18 @@ var _Util = __webpack_require__(1);
81078107

81088108
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
81098109

8110-
var Support = exports.Support = _SuperMap.SuperMap.Support = _SuperMap.SuperMap.Support || {
8111-
cors: window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest()
8112-
};
8110+
/**
8111+
* @member SuperMap.CORS
8112+
* @description 是否支持跨域
8113+
* @type {boolean}
8114+
*/
8115+
var CORS = exports.CORS = _SuperMap.SuperMap.CORS = _SuperMap.SuperMap.CORS || window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest();
8116+
/**
8117+
* @member SuperMap.RequestTimeout
8118+
* @description 请求超时时间,默认45s
8119+
* @type {number}
8120+
*/
8121+
var RequestTimeout = exports.RequestTimeout = _SuperMap.SuperMap.RequestTimeout = _SuperMap.SuperMap.RequestTimeout || 45000;
81138122
var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
81148123
commit: function commit(method, url, params, options) {
81158124
method = method ? method.toUpperCase() : method;
@@ -8133,7 +8142,7 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
81338142
url = this._processUrl(url, options);
81348143
url = _Util.Util.urlAppend(url, this._getParameterString(params || {}));
81358144
if (!this.urlIsLong(url)) {
8136-
if (_Util.Util.isInTheSameDomain(url) || Support.cors || options.proxy) {
8145+
if (_Util.Util.isInTheSameDomain(url) || CORS || options.proxy) {
81378146
return this._fetch(url, params, options, type);
81388147
}
81398148
if (!_Util.Util.isInTheSameDomain(url)) {
@@ -8149,7 +8158,7 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
81498158
var type = 'DELETE';
81508159
url = this._processUrl(url, options);
81518160
url = _Util.Util.urlAppend(url, this._getParameterString(params || {}));
8152-
if (!this.urlIsLong(url) && Support.cors) {
8161+
if (!this.urlIsLong(url) && CORS) {
81538162
return this._fetch(url, params, options, type);
81548163
}
81558164
return this._postSimulatie(type, url.substring(0, url.indexOf('?') - 1), params, options);
@@ -8228,7 +8237,8 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
82288237
headers: options.headers,
82298238
body: type === 'PUT' || type === 'POST' ? params : undefined,
82308239
credentials: options.withCredentials ? 'include' : 'omit',
8231-
mode: 'cors'
8240+
mode: 'cors',
8241+
timeout: RequestTimeout
82328242
}).then(function (response) {
82338243
return response;
82348244
}));
@@ -8238,7 +8248,8 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
82388248
body: type === 'PUT' || type === 'POST' ? params : undefined,
82398249
headers: options.headers,
82408250
credentials: options.withCredentials ? 'include' : 'omit',
8241-
mode: 'cors'
8251+
mode: 'cors',
8252+
timeout: RequestTimeout
82428253
}).then(function (response) {
82438254
return response;
82448255
});
@@ -86903,10 +86914,16 @@ Object.defineProperty(exports, "__esModule", {
8690386914

8690486915
var _FetchRequest = __webpack_require__(21);
8690586916

86906-
Object.defineProperty(exports, 'Support', {
86917+
Object.defineProperty(exports, 'CORS', {
86918+
enumerable: true,
86919+
get: function get() {
86920+
return _FetchRequest.CORS;
86921+
}
86922+
});
86923+
Object.defineProperty(exports, 'RequestTimeout', {
8690786924
enumerable: true,
8690886925
get: function get() {
86909-
return _FetchRequest.Support;
86926+
return _FetchRequest.RequestTimeout;
8691086927
}
8691186928
});
8691286929
Object.defineProperty(exports, 'FetchRequest', {

dist/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-mapboxgl.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8062,7 +8062,7 @@ _SuperMap.SuperMap.Feature.ShapeFactory = ShapeFactory;
80628062
Object.defineProperty(exports, "__esModule", {
80638063
value: true
80648064
});
8065-
exports.FetchRequest = exports.Support = undefined;
8065+
exports.FetchRequest = exports.RequestTimeout = exports.CORS = undefined;
80668066

80678067
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
80688068

@@ -8082,9 +8082,18 @@ var _Util = __webpack_require__(1);
80828082

80838083
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
80848084

8085-
var Support = exports.Support = _SuperMap.SuperMap.Support = _SuperMap.SuperMap.Support || {
8086-
cors: window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest()
8087-
};
8085+
/**
8086+
* @member SuperMap.CORS
8087+
* @description 是否支持跨域
8088+
* @type {boolean}
8089+
*/
8090+
var CORS = exports.CORS = _SuperMap.SuperMap.CORS = _SuperMap.SuperMap.CORS || window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest();
8091+
/**
8092+
* @member SuperMap.RequestTimeout
8093+
* @description 请求超时时间,默认45s
8094+
* @type {number}
8095+
*/
8096+
var RequestTimeout = exports.RequestTimeout = _SuperMap.SuperMap.RequestTimeout = _SuperMap.SuperMap.RequestTimeout || 45000;
80888097
var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
80898098
commit: function commit(method, url, params, options) {
80908099
method = method ? method.toUpperCase() : method;
@@ -8108,7 +8117,7 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
81088117
url = this._processUrl(url, options);
81098118
url = _Util.Util.urlAppend(url, this._getParameterString(params || {}));
81108119
if (!this.urlIsLong(url)) {
8111-
if (_Util.Util.isInTheSameDomain(url) || Support.cors || options.proxy) {
8120+
if (_Util.Util.isInTheSameDomain(url) || CORS || options.proxy) {
81128121
return this._fetch(url, params, options, type);
81138122
}
81148123
if (!_Util.Util.isInTheSameDomain(url)) {
@@ -8124,7 +8133,7 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
81248133
var type = 'DELETE';
81258134
url = this._processUrl(url, options);
81268135
url = _Util.Util.urlAppend(url, this._getParameterString(params || {}));
8127-
if (!this.urlIsLong(url) && Support.cors) {
8136+
if (!this.urlIsLong(url) && CORS) {
81288137
return this._fetch(url, params, options, type);
81298138
}
81308139
return this._postSimulatie(type, url.substring(0, url.indexOf('?') - 1), params, options);
@@ -8203,7 +8212,8 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
82038212
headers: options.headers,
82048213
body: type === 'PUT' || type === 'POST' ? params : undefined,
82058214
credentials: options.withCredentials ? 'include' : 'omit',
8206-
mode: 'cors'
8215+
mode: 'cors',
8216+
timeout: RequestTimeout
82078217
}).then(function (response) {
82088218
return response;
82098219
}));
@@ -8213,7 +8223,8 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
82138223
body: type === 'PUT' || type === 'POST' ? params : undefined,
82148224
headers: options.headers,
82158225
credentials: options.withCredentials ? 'include' : 'omit',
8216-
mode: 'cors'
8226+
mode: 'cors',
8227+
timeout: RequestTimeout
82178228
}).then(function (response) {
82188229
return response;
82198230
});
@@ -80902,10 +80913,16 @@ Object.defineProperty(exports, "__esModule", {
8090280913

8090380914
var _FetchRequest = __webpack_require__(20);
8090480915

80905-
Object.defineProperty(exports, 'Support', {
80916+
Object.defineProperty(exports, 'CORS', {
80917+
enumerable: true,
80918+
get: function get() {
80919+
return _FetchRequest.CORS;
80920+
}
80921+
});
80922+
Object.defineProperty(exports, 'RequestTimeout', {
8090680923
enumerable: true,
8090780924
get: function get() {
80908-
return _FetchRequest.Support;
80925+
return _FetchRequest.RequestTimeout;
8090980926
}
8091080927
});
8091180928
Object.defineProperty(exports, 'FetchRequest', {

dist/iclient9-mapboxgl.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-openlayers.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8369,7 +8369,7 @@ _SuperMap.SuperMap.Feature.ShapeFactory = ShapeFactory;
83698369
Object.defineProperty(exports, "__esModule", {
83708370
value: true
83718371
});
8372-
exports.FetchRequest = exports.Support = undefined;
8372+
exports.FetchRequest = exports.RequestTimeout = exports.CORS = undefined;
83738373

83748374
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
83758375

@@ -8389,9 +8389,18 @@ var _Util = __webpack_require__(1);
83898389

83908390
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
83918391

8392-
var Support = exports.Support = _SuperMap.SuperMap.Support = _SuperMap.SuperMap.Support || {
8393-
cors: window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest()
8394-
};
8392+
/**
8393+
* @member SuperMap.CORS
8394+
* @description 是否支持跨域
8395+
* @type {boolean}
8396+
*/
8397+
var CORS = exports.CORS = _SuperMap.SuperMap.CORS = _SuperMap.SuperMap.CORS || window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest();
8398+
/**
8399+
* @member SuperMap.RequestTimeout
8400+
* @description 请求超时时间,默认45s
8401+
* @type {number}
8402+
*/
8403+
var RequestTimeout = exports.RequestTimeout = _SuperMap.SuperMap.RequestTimeout = _SuperMap.SuperMap.RequestTimeout || 45000;
83958404
var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
83968405
commit: function commit(method, url, params, options) {
83978406
method = method ? method.toUpperCase() : method;
@@ -8415,7 +8424,7 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
84158424
url = this._processUrl(url, options);
84168425
url = _Util.Util.urlAppend(url, this._getParameterString(params || {}));
84178426
if (!this.urlIsLong(url)) {
8418-
if (_Util.Util.isInTheSameDomain(url) || Support.cors || options.proxy) {
8427+
if (_Util.Util.isInTheSameDomain(url) || CORS || options.proxy) {
84198428
return this._fetch(url, params, options, type);
84208429
}
84218430
if (!_Util.Util.isInTheSameDomain(url)) {
@@ -8431,7 +8440,7 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
84318440
var type = 'DELETE';
84328441
url = this._processUrl(url, options);
84338442
url = _Util.Util.urlAppend(url, this._getParameterString(params || {}));
8434-
if (!this.urlIsLong(url) && Support.cors) {
8443+
if (!this.urlIsLong(url) && CORS) {
84358444
return this._fetch(url, params, options, type);
84368445
}
84378446
return this._postSimulatie(type, url.substring(0, url.indexOf('?') - 1), params, options);
@@ -8510,7 +8519,8 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
85108519
headers: options.headers,
85118520
body: type === 'PUT' || type === 'POST' ? params : undefined,
85128521
credentials: options.withCredentials ? 'include' : 'omit',
8513-
mode: 'cors'
8522+
mode: 'cors',
8523+
timeout: RequestTimeout
85148524
}).then(function (response) {
85158525
return response;
85168526
}));
@@ -8520,7 +8530,8 @@ var FetchRequest = exports.FetchRequest = _SuperMap.SuperMap.FetchRequest = {
85208530
body: type === 'PUT' || type === 'POST' ? params : undefined,
85218531
headers: options.headers,
85228532
credentials: options.withCredentials ? 'include' : 'omit',
8523-
mode: 'cors'
8533+
mode: 'cors',
8534+
timeout: RequestTimeout
85248535
}).then(function (response) {
85258536
return response;
85268537
});
@@ -86213,10 +86224,16 @@ Object.defineProperty(exports, "__esModule", {
8621386224

8621486225
var _FetchRequest = __webpack_require__(21);
8621586226

86216-
Object.defineProperty(exports, 'Support', {
86227+
Object.defineProperty(exports, 'CORS', {
86228+
enumerable: true,
86229+
get: function get() {
86230+
return _FetchRequest.CORS;
86231+
}
86232+
});
86233+
Object.defineProperty(exports, 'RequestTimeout', {
8621786234
enumerable: true,
8621886235
get: function get() {
86219-
return _FetchRequest.Support;
86236+
return _FetchRequest.RequestTimeout;
8622086237
}
8622186238
});
8622286239
Object.defineProperty(exports, 'FetchRequest', {

dist/iclient9-openlayers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/util/FetchRequest.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@ import fetchJsonp from 'fetch-jsonp';
44
import {SuperMap} from '../SuperMap';
55
import {Util} from '../commontypes/Util';
66

7-
export var Support = SuperMap.Support = SuperMap.Support || {
8-
cors: (window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest())
9-
};
7+
/**
8+
* @member SuperMap.CORS
9+
* @description 是否支持跨域
10+
* @type {boolean}
11+
*/
12+
export var CORS = SuperMap.CORS = SuperMap.CORS || (window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest());
13+
/**
14+
* @member SuperMap.RequestTimeout
15+
* @description 请求超时时间,默认45s
16+
* @type {number}
17+
*/
18+
export var RequestTimeout = SuperMap.RequestTimeout = SuperMap.RequestTimeout || 45000;
1019
export var FetchRequest = SuperMap.FetchRequest = {
1120
commit: function (method, url, params, options) {
1221
method = method ? method.toUpperCase() : method;
@@ -30,7 +39,7 @@ export var FetchRequest = SuperMap.FetchRequest = {
3039
url = this._processUrl(url, options);
3140
url = Util.urlAppend(url, this._getParameterString(params || {}));
3241
if (!this.urlIsLong(url)) {
33-
if (Util.isInTheSameDomain(url) || Support.cors || options.proxy) {
42+
if (Util.isInTheSameDomain(url) || CORS || options.proxy) {
3443
return this._fetch(url, params, options, type);
3544
}
3645
if (!Util.isInTheSameDomain(url)) {
@@ -46,7 +55,7 @@ export var FetchRequest = SuperMap.FetchRequest = {
4655
var type = 'DELETE';
4756
url = this._processUrl(url, options);
4857
url = Util.urlAppend(url, this._getParameterString(params || {}));
49-
if (!this.urlIsLong(url) && Support.cors) {
58+
if (!this.urlIsLong(url) && CORS) {
5059
return this._fetch(url, params, options, type);
5160
}
5261
return this._postSimulatie(type, url.substring(0, url.indexOf('?') - 1), params, options);
@@ -125,7 +134,8 @@ export var FetchRequest = SuperMap.FetchRequest = {
125134
headers: options.headers,
126135
body: type === 'PUT' || type === 'POST' ? params : undefined,
127136
credentials: options.withCredentials ? 'include' : 'omit',
128-
mode: 'cors'
137+
mode: 'cors',
138+
timeout:RequestTimeout
129139
}).then(function (response) {
130140
return response;
131141
}));
@@ -135,7 +145,8 @@ export var FetchRequest = SuperMap.FetchRequest = {
135145
body: type === 'PUT' || type === 'POST' ? params : undefined,
136146
headers: options.headers,
137147
credentials: options.withCredentials ? 'include' : 'omit',
138-
mode: 'cors'
148+
mode: 'cors',
149+
timeout:RequestTimeout
139150
}).then(function (response) {
140151
return response;
141152
});

src/common/util/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export {Support, FetchRequest} from './FetchRequest';
1+
export {CORS, RequestTimeout, FetchRequest} from './FetchRequest';

0 commit comments

Comments
 (0)