@alicloud/alfa-core 1.5.0-alpha.3 → 1.5.0-alpha.5

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.
@@ -114,10 +114,10 @@ export var getConfigV2 = /*#__PURE__*/function () {
114
114
  case 7:
115
115
  _context2.prev = 7;
116
116
  _context2.next = 10;
117
- return request.get("//fecs.console.".concat(parseEnv().MAIN_DOMAIN, "/api/alfa/console/config?=appId=").concat(relatedConsoleAppId));
117
+ return request.get("https://".concat(config.env !== 'prod' ? 'pre-' : '', "fecs.console.").concat(parseEnv().MAIN_DOMAIN, "/api/alfa/console/config?appId=").concat(relatedConsoleAppId));
118
118
  case 10:
119
119
  res = _context2.sent;
120
- return _context2.abrupt("return", res.data);
120
+ return _context2.abrupt("return", res.data.data);
121
121
  case 14:
122
122
  _context2.prev = 14;
123
123
  _context2.t0 = _context2["catch"](7);
@@ -1,5 +1,4 @@
1
1
  import instance from '../request';
2
- var requestList = [];
3
2
  export var addRequestInterceptor = function addRequestInterceptor(fn) {
4
3
  var interceptor = function interceptor(config) {
5
4
  try {
@@ -21,10 +21,13 @@ function _requestInterceptor() {
21
21
  return _regeneratorRuntime.wrap(function _callee$(_context) {
22
22
  while (1) switch (_context.prev = _context.next) {
23
23
  case 0:
24
- hostname = getCurrentCdnHost(); // if cdn is not alicdn, replace it
25
- if (hostname && config.url) {
26
- // 非公有云下无 cws2
27
- config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(hostname)).replace('cws2.', 'cws.');
24
+ hostname = getCurrentCdnHost();
25
+ if (hostname !== 'alicdn.com') {
26
+ // if cdn is not alicdn, replace it
27
+ if (hostname && config.url) {
28
+ // 非公有云下无 cws2
29
+ config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(hostname)).replace('cws2.', 'cws.');
30
+ }
28
31
  }
29
32
  return _context.abrupt("return", config);
30
33
  case 3:
@@ -43,6 +43,13 @@ function isConfig(url, data) {
43
43
  }
44
44
  return false;
45
45
  }
46
+ function isFecs(url, data) {
47
+ var _data$data;
48
+ if (/\/(pre-)?fecs\./.test(url) && data !== null && data !== void 0 && (_data$data = data.data) !== null && _data$data !== void 0 && _data$data.ALIYUN_CONSOLE_CONFIG) {
49
+ return true;
50
+ }
51
+ return false;
52
+ }
46
53
  function isLocale(url) {
47
54
  // will not check locale file content
48
55
  if (/\/(zh_CN|zh_TW|ja_JP|en_US)/.exec(url)) return true;
@@ -51,7 +58,7 @@ function isLocale(url) {
51
58
  function isLegal(url, data) {
52
59
  // data is an object and not empty
53
60
  if (url && data && Object.prototype.toString.call(data) === '[object Object]' && Object.keys(data).length > 0) {
54
- if (isManifest(url, data) || isRelease(url, data) || isConfig(url, data) || isLocale(url)) {
61
+ if (isManifest(url, data) || isRelease(url, data) || isConfig(url, data) || isLocale(url) || isFecs(url, data)) {
55
62
  return true;
56
63
  }
57
64
  }
@@ -121,10 +121,10 @@ var getConfigV2 = exports.getConfigV2 = /*#__PURE__*/function () {
121
121
  case 7:
122
122
  _context2.prev = 7;
123
123
  _context2.next = 10;
124
- return _request.default.get("//fecs.console.".concat((0, _consoleBaseConfParseEnv.default)().MAIN_DOMAIN, "/api/alfa/console/config?=appId=").concat(relatedConsoleAppId));
124
+ return _request.default.get("https://".concat(config.env !== 'prod' ? 'pre-' : '', "fecs.console.").concat((0, _consoleBaseConfParseEnv.default)().MAIN_DOMAIN, "/api/alfa/console/config?appId=").concat(relatedConsoleAppId));
125
125
  case 10:
126
126
  res = _context2.sent;
127
- return _context2.abrupt("return", res.data);
127
+ return _context2.abrupt("return", res.data.data);
128
128
  case 14:
129
129
  _context2.prev = 14;
130
130
  _context2.t0 = _context2["catch"](7);
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.addRequestInterceptor = void 0;
8
8
  var _request = _interopRequireDefault(require("../request"));
9
- var requestList = [];
10
9
  var addRequestInterceptor = exports.addRequestInterceptor = function addRequestInterceptor(fn) {
11
10
  var interceptor = function interceptor(config) {
12
11
  try {
@@ -28,10 +28,13 @@ function _requestInterceptor() {
28
28
  return _regenerator.default.wrap(function _callee$(_context) {
29
29
  while (1) switch (_context.prev = _context.next) {
30
30
  case 0:
31
- hostname = getCurrentCdnHost(); // if cdn is not alicdn, replace it
32
- if (hostname && config.url) {
33
- // 非公有云下无 cws2
34
- config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(hostname)).replace('cws2.', 'cws.');
31
+ hostname = getCurrentCdnHost();
32
+ if (hostname !== 'alicdn.com') {
33
+ // if cdn is not alicdn, replace it
34
+ if (hostname && config.url) {
35
+ // 非公有云下无 cws2
36
+ config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(hostname)).replace('cws2.', 'cws.');
37
+ }
35
38
  }
36
39
  return _context.abrupt("return", config);
37
40
  case 3:
@@ -50,6 +50,13 @@ function isConfig(url, data) {
50
50
  }
51
51
  return false;
52
52
  }
53
+ function isFecs(url, data) {
54
+ var _data$data;
55
+ if (/\/(pre-)?fecs\./.test(url) && data !== null && data !== void 0 && (_data$data = data.data) !== null && _data$data !== void 0 && _data$data.ALIYUN_CONSOLE_CONFIG) {
56
+ return true;
57
+ }
58
+ return false;
59
+ }
53
60
  function isLocale(url) {
54
61
  // will not check locale file content
55
62
  if (/\/(zh_CN|zh_TW|ja_JP|en_US)/.exec(url)) return true;
@@ -58,7 +65,7 @@ function isLocale(url) {
58
65
  function isLegal(url, data) {
59
66
  // data is an object and not empty
60
67
  if (url && data && Object.prototype.toString.call(data) === '[object Object]' && Object.keys(data).length > 0) {
61
- if (isManifest(url, data) || isRelease(url, data) || isConfig(url, data) || isLocale(url)) {
68
+ if (isManifest(url, data) || isRelease(url, data) || isConfig(url, data) || isLocale(url) || isFecs(url, data)) {
62
69
  return true;
63
70
  }
64
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-core",
3
- "version": "1.5.0-alpha.3",
3
+ "version": "1.5.0-alpha.5",
4
4
  "description": "MicroFront End SDK for alicloud",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",