@ray-js/api 1.5.44-beta.0 → 1.5.45

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.
@@ -7,11 +7,22 @@ const regionMap = {
7
7
  WE: 'd2h2yqnfpu4gl5.cdn5th.com',
8
8
  UE: 'usimagesd1448c85ulz2o4.cdn5th.com'
9
9
  };
10
- let regionCode = 'EU';
10
+ let _regionCode;
11
+ let getInternalRegionCode = () => {
12
+ if (!_regionCode) {
13
+ ty.getAppInfo({
14
+ success: function (res) {
15
+ _regionCode = res.regionCode;
16
+ }
17
+ });
18
+ }
19
+ return 'EU';
20
+ };
11
21
  export function getRegionCode() {
12
22
  return new Promise((resolve, reject) => {
13
23
  ty.getAppInfo({
14
24
  success: function (res) {
25
+ _regionCode = res.regionCode;
15
26
  resolve(res.regionCode);
16
27
  },
17
28
  fail: function (err) {
@@ -20,11 +31,6 @@ export function getRegionCode() {
20
31
  });
21
32
  });
22
33
  }
23
- ty.getAppInfo({
24
- success: function (res) {
25
- regionCode = res.regionCode;
26
- }
27
- });
28
34
  export default function getCdnUrl(path, cdnMap, region) {
29
35
  if (!cdnMap) {
30
36
  console.warn('请传入cdnMap');
@@ -35,8 +41,7 @@ export default function getCdnUrl(path, cdnMap, region) {
35
41
  console.warn('[App] cdn "' + path + '" is not exist.');
36
42
  return path;
37
43
  }
38
- const cdnPath = 'https://' + regionMap[region || regionCode] + '/' + cdnShortPath;
39
- return cdnPath;
44
+ return 'https://' + regionMap[region || getInternalRegionCode()] + '/' + cdnShortPath;
40
45
  }
41
46
  export async function getCdnUrlAsync(path, cdnMap, region) {
42
47
  if (!cdnMap) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/api",
3
- "version": "1.5.44-beta.0",
3
+ "version": "1.5.45",
4
4
  "description": "Ray universal api",
5
5
  "keywords": [
6
6
  "ray"
@@ -29,14 +29,14 @@
29
29
  "watch": "ray start --type=component"
30
30
  },
31
31
  "dependencies": {
32
- "@ray-js/framework": "^1.5.44-beta.0",
33
- "@ray-js/router": "^1.5.44-beta.0",
32
+ "@ray-js/framework": "1.5.45",
33
+ "@ray-js/router": "1.5.45",
34
34
  "@ray-js/wechat": "^0.2.19",
35
35
  "base64-browser": "^1.0.1",
36
36
  "query-string": "^7.1.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@ray-js/cli": "^1.5.44-beta.0",
39
+ "@ray-js/cli": "1.5.45",
40
40
  "art-template": "^4.13.2",
41
41
  "fs-extra": "^10.1.0",
42
42
  "miniprogram-api-typings": "^3.12.3",
@@ -46,5 +46,5 @@
46
46
  "access": "public",
47
47
  "registry": "https://registry.npmjs.com"
48
48
  },
49
- "gitHead": "f7ab69b393a7162439be4a19793c15b773e03848"
49
+ "gitHead": "4839da28164b7fdee7bfe4a9bb61d8cab98ce909"
50
50
  }