@aliyun-obv/api 0.3.13 → 0.3.15

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.
Files changed (2) hide show
  1. package/dist/api.es.js +14 -11
  2. package/package.json +1 -1
package/dist/api.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
- import urijs from 'urijs';
3
2
  import errorPrompt from '@alicloud/console-base-error-prompt-proxy';
4
3
  import i18n, { getMsg } from '@aliyun-obv/i18n';
4
+ import urijs from 'urijs';
5
5
  import { Dialog, Button, Message } from '@alifd/next';
6
6
  import { slsConsoleRuntime, commonUtil, urlUtil, addStubForSearch, addRUMLog, slsConsoleUtil } from '@aliyun-obv/utils';
7
7
  import React from 'react';
@@ -60,6 +60,7 @@ var __async$9 = (__this, __arguments, generator) => {
60
60
  };
61
61
  const isTest = process.env.NODE_ENV === "test";
62
62
  const matchProxyApiReg = /common\/(getApi|postApi|putApi)/;
63
+ const workspaceReg = /\/region\/(.+?)\/workspace\/(.+?)\//;
63
64
  class BaseFetch {
64
65
  constructor(fetchApi) {
65
66
  __publicField(this, "fetchApi");
@@ -89,9 +90,11 @@ class BaseFetch {
89
90
  }
90
91
  beforeRequest(api, params, init, options) {
91
92
  const hasBaseURL = typeof this.defaults.baseURL === "string" && this.defaults.baseURL.trim().length > 0;
92
- const parseQuery = urijs(decodeURIComponent(location.search)).escapeQuerySpace(false).query(true);
93
- if ((params == null ? void 0 : params.product) === "CMS" && (parseQuery == null ? void 0 : parseQuery.cmsRegion) && params.region == null) {
94
- params.region = parseQuery.cmsRegion;
93
+ if ((params == null ? void 0 : params.product) === "CMS" && params.region == null) {
94
+ const re = workspaceReg.exec(window.location.pathname);
95
+ if (re && re[1]) {
96
+ params.region = re[1];
97
+ }
95
98
  }
96
99
  let url = api;
97
100
  let newInit = init;
@@ -220,7 +223,11 @@ function getSLSdomain() {
220
223
  if ((_a2 = window == null ? void 0 : window.__CONSOLE_OBVIZ_DOMAIN__) == null ? void 0 : _a2.getSlsDomain) {
221
224
  return window.__CONSOLE_OBVIZ_DOMAIN__.getSlsDomain();
222
225
  }
226
+ const { slsHost } = urijs(window.location.search).escapeQuerySpace(false).query(true);
223
227
  if (isLocal) {
228
+ if (slsHost != null && slsHost != "") {
229
+ return slsHost;
230
+ }
224
231
  if (window.location.hostname.includes("stg")) {
225
232
  return `http://sls-stg:${window.location.port}`;
226
233
  }
@@ -234,6 +241,9 @@ function getSLSdomain() {
234
241
  return void 0;
235
242
  }
236
243
  if (isPre) {
244
+ if (slsHost != null && slsHost != "") {
245
+ return slsHost;
246
+ }
237
247
  if (is4Service(window.location)) {
238
248
  return `https://pre-sls4service.console.aliyun.com`;
239
249
  }
@@ -252,11 +262,7 @@ function getObvDomain() {
252
262
  if ((_a2 = window == null ? void 0 : window.__CONSOLE_OBVIZ_DOMAIN__) == null ? void 0 : _a2.getObvDomain) {
253
263
  return window.__CONSOLE_OBVIZ_DOMAIN__.getObvDomain();
254
264
  }
255
- const { slsHost } = urijs(window.location.search).escapeQuerySpace(false).query(true);
256
265
  if ((_b2 = window.ALIYUN_CONSOLE_CONFIG) == null ? void 0 : _b2.LOCAL) {
257
- if (slsHost != null && slsHost != "") {
258
- return slsHost;
259
- }
260
266
  if (location.hostname === "localhost") {
261
267
  return `http://pre-observability:${window.location.port}`;
262
268
  }
@@ -269,9 +275,6 @@ function getObvDomain() {
269
275
  return `http://pre-observability:${window.location.port}`;
270
276
  }
271
277
  if (isPre) {
272
- if (slsHost != null && slsHost != "") {
273
- return slsHost;
274
- }
275
278
  if (is4Service(window.location)) {
276
279
  return `https://pre-observability4service.console.aliyun.com`;
277
280
  }
package/package.json CHANGED
@@ -15,5 +15,5 @@
15
15
  "styled-components": "^5.2.0"
16
16
  },
17
17
  "devDependencies": {},
18
- "version": "0.3.13"
18
+ "version": "0.3.15"
19
19
  }