@ray-js/api 1.5.48-alpha.5 → 1.5.48
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.
- package/lib/cloud/alarm.js +2 -2
- package/lib/cloud/core.js +1 -1
- package/lib/cloud/device.js +7 -7
- package/lib/cloud/doorlock/auth.js +8 -8
- package/lib/cloud/doorlock/device.js +7 -7
- package/lib/cloud/doorlock/log.js +4 -4
- package/lib/cloud/doorlock/member-opmode.js +7 -7
- package/lib/cloud/doorlock/member.js +7 -7
- package/lib/cloud/doorlock/offline-pwd.js +4 -4
- package/lib/cloud/doorlock/old.js +6 -6
- package/lib/cloud/doorlock/temp-pwd.js +8 -8
- package/lib/cloud/doorlock/unlock-method.js +3 -3
- package/lib/cloud/doorlock/unlock.js +5 -5
- package/lib/cloud/linkage.js +17 -17
- package/lib/cloud/outdoor.js +1 -1
- package/lib/cloud/recipe/basket.js +10 -11
- package/lib/cloud/recipe/category-list.js +2 -2
- package/lib/cloud/recipe/custom.js +4 -5
- package/lib/cloud/recipe/menu.js +3 -4
- package/lib/cloud/recipe/query.js +3 -4
- package/lib/cloud/recipe/record.js +3 -3
- package/lib/cloud/recipe/score.js +3 -4
- package/lib/cloud/recipe/star.js +5 -6
- package/lib/cloud/remoteGroup.js +2 -2
- package/lib/cloud/statistic.js +9 -9
- package/lib/cloud/timer.js +14 -14
- package/lib/getBoundingClientRect/index.thing.js +0 -1
- package/lib/getBoundingClientRect/index.wechat.js +0 -1
- package/lib/getCdnUrl/index.d.ts +22 -2
- package/lib/getCdnUrl/index.js +18 -0
- package/lib/getCdnUrl/index.thing.d.ts +23 -3
- package/lib/getCdnUrl/index.thing.js +73 -33
- package/lib/getCdnUrl/index.wechat.d.ts +22 -2
- package/lib/getCdnUrl/index.wechat.js +60 -5
- package/lib/getElementById/index.thing.js +1 -1
- package/lib/getElementById/index.wechat.js +1 -1
- package/lib/panel/i18n/index.js +12 -16
- package/lib/panel/i18n/index.wechat.js +12 -16
- package/lib/panel/publishDps.js +1 -1
- package/lib/redirectTo/index.js +0 -2
- package/lib/utils.js +9 -9
- package/lib/utils.wechat.js +5 -6
- package/package.json +5 -5
package/lib/cloud/timer.js
CHANGED
@@ -15,7 +15,7 @@ import { THING } from '../constants';
|
|
15
15
|
*/
|
16
16
|
const addSingleTimer = params => {
|
17
17
|
return requestCloud({
|
18
|
-
api:
|
18
|
+
api: `${THING}.m.clock.dps.add`,
|
19
19
|
version: '1.0',
|
20
20
|
data: _objectSpread({}, params)
|
21
21
|
});
|
@@ -29,7 +29,7 @@ const addSingleTimer = params => {
|
|
29
29
|
*/
|
30
30
|
const queryTimerTasks = params => {
|
31
31
|
return requestCloud({
|
32
|
-
api:
|
32
|
+
api: `${THING}.m.clock.dps.list`,
|
33
33
|
version: '1.0',
|
34
34
|
data: _objectSpread({}, params)
|
35
35
|
});
|
@@ -48,7 +48,7 @@ const queryTimerTasks = params => {
|
|
48
48
|
*/
|
49
49
|
const modifySingleTimer = params => {
|
50
50
|
return requestCloud({
|
51
|
-
api:
|
51
|
+
api: `${THING}.m.clock.dps.update`,
|
52
52
|
version: '1.0',
|
53
53
|
data: _objectSpread({}, params)
|
54
54
|
});
|
@@ -67,7 +67,7 @@ const modifySingleTimer = params => {
|
|
67
67
|
*/
|
68
68
|
const addGroupTimer = params => {
|
69
69
|
return requestCloud({
|
70
|
-
api:
|
70
|
+
api: `${THING}.m.clock.dps.group.add`,
|
71
71
|
version: '1.0',
|
72
72
|
data: _objectSpread({}, params)
|
73
73
|
});
|
@@ -81,7 +81,7 @@ const addGroupTimer = params => {
|
|
81
81
|
*/
|
82
82
|
const queryGroupTimerTasks = params => {
|
83
83
|
return requestCloud({
|
84
|
-
api:
|
84
|
+
api: `${THING}.m.clock.dps.group.list`,
|
85
85
|
version: '1.0',
|
86
86
|
data: _objectSpread({}, params)
|
87
87
|
});
|
@@ -99,7 +99,7 @@ const queryGroupTimerTasks = params => {
|
|
99
99
|
*/
|
100
100
|
const modifyGroupTimer = params => {
|
101
101
|
return requestCloud({
|
102
|
-
api:
|
102
|
+
api: `${THING}.m.clock.dps.group.update`,
|
103
103
|
version: '1.0',
|
104
104
|
data: _objectSpread({}, params)
|
105
105
|
});
|
@@ -114,7 +114,7 @@ const modifyGroupTimer = params => {
|
|
114
114
|
*/
|
115
115
|
const modDeleteTaskByIds = params => {
|
116
116
|
return requestCloud({
|
117
|
-
api:
|
117
|
+
api: `${THING}.m.clock.batch.status.update`,
|
118
118
|
version: '1.0',
|
119
119
|
data: _objectSpread({}, params)
|
120
120
|
});
|
@@ -129,7 +129,7 @@ const modDeleteTaskByIds = params => {
|
|
129
129
|
*/
|
130
130
|
const modDeleteTaskByCategory = params => {
|
131
131
|
return requestCloud({
|
132
|
-
api:
|
132
|
+
api: `${THING}.m.clock.category.status.update`,
|
133
133
|
version: '1.0',
|
134
134
|
data: _objectSpread({}, params)
|
135
135
|
});
|
@@ -170,7 +170,7 @@ const getDpsLastTimer = params => {
|
|
170
170
|
*/
|
171
171
|
const getLastTimerPeriod = params => {
|
172
172
|
return requestCloud({
|
173
|
-
api:
|
173
|
+
api: `${THING}.m.timer.nearest.get`,
|
174
174
|
version: '1.0',
|
175
175
|
data: _objectSpread({}, params)
|
176
176
|
});
|
@@ -181,7 +181,7 @@ const getLastTimerPeriod = params => {
|
|
181
181
|
*/
|
182
182
|
const getAstronomicalList = params => {
|
183
183
|
return requestCloud({
|
184
|
-
api:
|
184
|
+
api: `${THING}.m.timer.astronomical.list`,
|
185
185
|
version: '1.0',
|
186
186
|
data: _objectSpread({}, params)
|
187
187
|
});
|
@@ -203,7 +203,7 @@ const getAstronomicalList = params => {
|
|
203
203
|
*/
|
204
204
|
const addAstronomical = params => {
|
205
205
|
return requestCloud({
|
206
|
-
api:
|
206
|
+
api: `${THING}.m.timer.astronomical.add`,
|
207
207
|
version: '1.0',
|
208
208
|
data: _objectSpread({}, params)
|
209
209
|
});
|
@@ -225,7 +225,7 @@ const addAstronomical = params => {
|
|
225
225
|
*/
|
226
226
|
const updateAstronomical = params => {
|
227
227
|
return requestCloud({
|
228
|
-
api:
|
228
|
+
api: `${THING}.m.timer.astronomical.update`,
|
229
229
|
version: '1.0',
|
230
230
|
data: _objectSpread({}, params)
|
231
231
|
});
|
@@ -238,7 +238,7 @@ const updateAstronomical = params => {
|
|
238
238
|
*/
|
239
239
|
const updateAstronomicalStatus = params => {
|
240
240
|
return requestCloud({
|
241
|
-
api:
|
241
|
+
api: `${THING}.m.timer.astronomical.status.update`,
|
242
242
|
version: '1.0',
|
243
243
|
data: _objectSpread({}, params)
|
244
244
|
});
|
@@ -250,7 +250,7 @@ const updateAstronomicalStatus = params => {
|
|
250
250
|
*/
|
251
251
|
const removeAstronomical = params => {
|
252
252
|
return requestCloud({
|
253
|
-
api:
|
253
|
+
api: `${THING}.m.timer.astronomical.remove`,
|
254
254
|
version: '1.0',
|
255
255
|
data: _objectSpread({}, params)
|
256
256
|
});
|
package/lib/getCdnUrl/index.d.ts
CHANGED
@@ -1,2 +1,22 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
type IRegionCode = 'AY' | 'AZ' | 'EU' | 'IN' | 'UE' | 'WE' | 'RU';
|
2
|
+
type ICdnMap = Record<string, string> | Record<IRegionCode, Record<string, string>>;
|
3
|
+
/**
|
4
|
+
* 获取 CDN 地址
|
5
|
+
* @description 基础库 2.26.0 及以上版本推荐使用此方法,可以准确获取区域码。
|
6
|
+
* 基础库 2.26.0 以下版本请使用 getCdnUrlAsync 方法,以避免区域码获取不准确的问题。
|
7
|
+
* @param path - 图片路径
|
8
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
9
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
10
|
+
* @returns CDN 完整地址
|
11
|
+
*/
|
12
|
+
export default function getCdnUrl(path: string, cdnMap?: ICdnMap, region?: IRegionCode): string;
|
13
|
+
/**
|
14
|
+
* 获取 CDN 地址
|
15
|
+
* @description 基础库 2.26.0 以下版本请使用此方法,以避免区域码获取不准确的问题。
|
16
|
+
* @param path - 图片路径
|
17
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
18
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
19
|
+
* @returns CDN 完整地址
|
20
|
+
*/
|
21
|
+
export declare function getCdnUrlAsync(path: string, cdnMap?: ICdnMap, region?: IRegionCode): Promise<string>;
|
22
|
+
export {};
|
package/lib/getCdnUrl/index.js
CHANGED
@@ -1,6 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* 获取 CDN 地址
|
3
|
+
* @description 基础库 2.26.0 及以上版本推荐使用此方法,可以准确获取区域码。
|
4
|
+
* 基础库 2.26.0 以下版本请使用 getCdnUrlAsync 方法,以避免区域码获取不准确的问题。
|
5
|
+
* @param path - 图片路径
|
6
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
7
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
8
|
+
* @returns CDN 完整地址
|
9
|
+
*/
|
1
10
|
export default function getCdnUrl(path) {
|
2
11
|
return path;
|
3
12
|
}
|
13
|
+
|
14
|
+
/**
|
15
|
+
* 获取 CDN 地址
|
16
|
+
* @description 基础库 2.26.0 以下版本请使用此方法,以避免区域码获取不准确的问题。
|
17
|
+
* @param path - 图片路径
|
18
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
19
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
20
|
+
* @returns CDN 完整地址
|
21
|
+
*/
|
4
22
|
export async function getCdnUrlAsync(path) {
|
5
23
|
// 暂未实现获取cdn方法,将直接返回path
|
6
24
|
return Promise.resolve(path);
|
@@ -1,3 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
export declare function
|
1
|
+
type IRegionCode = 'AY' | 'AZ' | 'EU' | 'IN' | 'UE' | 'WE' | 'RU';
|
2
|
+
type ICdnMap = Record<string, string> | Record<IRegionCode, Record<string, string>>;
|
3
|
+
export declare function getRegionCode(): Promise<IRegionCode>;
|
4
|
+
/**
|
5
|
+
* 获取 CDN 地址
|
6
|
+
* @description 基础库 2.26.0 及以上版本推荐使用此方法,可以准确获取区域码。
|
7
|
+
* 基础库 2.26.0 以下版本请使用 getCdnUrlAsync 方法,以避免区域码获取不准确的问题。
|
8
|
+
* @param path - 图片路径
|
9
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
10
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
11
|
+
* @returns CDN 完整地址
|
12
|
+
*/
|
13
|
+
export default function getCdnUrl(path: string, cdnMap?: ICdnMap, region?: IRegionCode): string;
|
14
|
+
/**
|
15
|
+
* 获取 CDN 地址
|
16
|
+
* @description 基础库 2.26.0 以下版本请使用此方法,以避免区域码获取不准确的问题。
|
17
|
+
* @param path - 图片路径
|
18
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
19
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
20
|
+
* @returns CDN 完整地址
|
21
|
+
*/
|
22
|
+
export declare function getCdnUrlAsync(path: string, cdnMap?: ICdnMap, region?: IRegionCode): Promise<string>;
|
23
|
+
export {};
|
@@ -1,54 +1,100 @@
|
|
1
|
+
import get from 'lodash/get';
|
1
2
|
const regionMap = {
|
2
|
-
AY: 'images.tuyacn.com',
|
3
|
-
AZ: 'usimagesd1448c85ulz2o4.cdn5th.com',
|
4
|
-
EU: 'euimagesd2h2yqnfpu4gl5.cdn5th.com',
|
5
|
-
IN: 'inimagesd1jqokb9wptk2t.cdn5th.com',
|
6
|
-
RU: 'euimagesd2h2yqnfpu4gl5.cdn5th.com',
|
7
|
-
WE: '
|
8
|
-
UE: '
|
3
|
+
AY: 'https://images.tuyacn.com',
|
4
|
+
AZ: 'https://usimagesd1448c85ulz2o4.cdn5th.com',
|
5
|
+
EU: 'https://euimagesd2h2yqnfpu4gl5.cdn5th.com',
|
6
|
+
IN: 'https://inimagesd1jqokb9wptk2t.cdn5th.com',
|
7
|
+
RU: 'https://euimagesd2h2yqnfpu4gl5.cdn5th.com',
|
8
|
+
WE: 'https://weimages57vdxnr.cdn5th.com',
|
9
|
+
UE: 'https://ueimages58yny2.cdn5th.com'
|
9
10
|
};
|
10
|
-
let
|
11
|
-
|
12
|
-
if (!
|
11
|
+
let _globalRegionCode;
|
12
|
+
const getInternalRegionCode = () => {
|
13
|
+
if (!_globalRegionCode) {
|
14
|
+
// 2.26.0 基础库才加上的方法
|
15
|
+
|
16
|
+
if (typeof ty.getRegionCode === 'function') {
|
17
|
+
_globalRegionCode = ty.getRegionCode();
|
18
|
+
return _globalRegionCode || 'EU';
|
19
|
+
}
|
13
20
|
ty.getAppInfo({
|
14
|
-
success
|
15
|
-
|
21
|
+
success(res) {
|
22
|
+
_globalRegionCode = res.regionCode;
|
16
23
|
}
|
17
24
|
});
|
18
25
|
}
|
19
|
-
|
26
|
+
// FIXME: 第一次调用时,_regionCode 为 undefined 时,返回 'EU'
|
27
|
+
return _globalRegionCode || 'EU';
|
20
28
|
};
|
21
29
|
export function getRegionCode() {
|
22
30
|
return new Promise((resolve, reject) => {
|
23
31
|
ty.getAppInfo({
|
24
|
-
success
|
25
|
-
|
32
|
+
success(res) {
|
33
|
+
_globalRegionCode = res.regionCode;
|
26
34
|
resolve(res.regionCode);
|
27
35
|
},
|
28
|
-
fail
|
36
|
+
fail(err) {
|
29
37
|
reject(err);
|
30
38
|
}
|
31
39
|
});
|
32
40
|
});
|
33
41
|
}
|
42
|
+
const concatRegionOrigin = (regionCode, path) => {
|
43
|
+
const regionOrigin = get(regionMap, [regionCode]) || get(regionMap, ['EU']);
|
44
|
+
if (path.indexOf('/') === 0) {
|
45
|
+
return `${regionOrigin}${path}`;
|
46
|
+
}
|
47
|
+
return `${regionOrigin}/${path}`;
|
48
|
+
};
|
49
|
+
const isEmptyOrUndefined = obj => {
|
50
|
+
return !obj || Object.keys(obj).length === 0;
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* 获取 CDN 地址
|
55
|
+
* @description 基础库 2.26.0 及以上版本推荐使用此方法,可以准确获取区域码。
|
56
|
+
* 基础库 2.26.0 以下版本请使用 getCdnUrlAsync 方法,以避免区域码获取不准确的问题。
|
57
|
+
* @param path - 图片路径
|
58
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
59
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
60
|
+
* @returns CDN 完整地址
|
61
|
+
*/
|
34
62
|
export default function getCdnUrl(path, cdnMap, region) {
|
35
|
-
|
36
|
-
|
37
|
-
|
63
|
+
const regionCode = region || getInternalRegionCode();
|
64
|
+
if (isEmptyOrUndefined(cdnMap)) {
|
65
|
+
// 如果未提供 cdnMap,则使用 regionMap 直接与 path 进行拼接
|
66
|
+
return concatRegionOrigin(regionCode, path);
|
38
67
|
}
|
39
|
-
|
68
|
+
|
69
|
+
// 总是使用 EU 进行兜底
|
70
|
+
const cdnShortPath = get(cdnMap, [regionCode, path]) || get(cdnMap, ['EU', path]) || get(cdnMap, [path]);
|
40
71
|
if (!cdnShortPath) {
|
41
|
-
console.warn(
|
72
|
+
console.warn(`[App] cdn "${path}" is not exist.`);
|
42
73
|
return path;
|
43
74
|
}
|
44
|
-
|
75
|
+
if (cdnShortPath.indexOf('http') === 0 || cdnShortPath.indexOf('//') === 0) {
|
76
|
+
return cdnShortPath;
|
77
|
+
}
|
78
|
+
if (cdnShortPath.indexOf('/') === 0) {
|
79
|
+
return `${regionMap[regionCode]}${cdnShortPath}`;
|
80
|
+
}
|
81
|
+
return `${regionMap[regionCode]}/${cdnShortPath}`;
|
45
82
|
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* 获取 CDN 地址
|
86
|
+
* @description 基础库 2.26.0 以下版本请使用此方法,以避免区域码获取不准确的问题。
|
87
|
+
* @param path - 图片路径
|
88
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
89
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
90
|
+
* @returns CDN 完整地址
|
91
|
+
*/
|
46
92
|
export async function getCdnUrlAsync(path, cdnMap, region) {
|
47
|
-
|
48
|
-
|
49
|
-
|
93
|
+
let _regionCode = _globalRegionCode || 'EU';
|
94
|
+
if (isEmptyOrUndefined(cdnMap)) {
|
95
|
+
// 如果未提供 cdnMap,则使用 regionMap 直接与 path 进行拼接
|
96
|
+
return concatRegionOrigin(_regionCode, path);
|
50
97
|
}
|
51
|
-
let _regionCode = 'EU';
|
52
98
|
if (region) {
|
53
99
|
_regionCode = region;
|
54
100
|
} else {
|
@@ -58,11 +104,5 @@ export async function getCdnUrlAsync(path, cdnMap, region) {
|
|
58
104
|
console.warn('[App] getRegionCode error, use default region EU', error);
|
59
105
|
}
|
60
106
|
}
|
61
|
-
|
62
|
-
if (!cdnShortPath) {
|
63
|
-
console.warn('[App] cdn "' + path + '" is not exist.');
|
64
|
-
return path;
|
65
|
-
}
|
66
|
-
const cdnPath = 'https://' + regionMap[_regionCode] + '/' + cdnShortPath;
|
67
|
-
return cdnPath;
|
107
|
+
return getCdnUrl(path, cdnMap, _regionCode);
|
68
108
|
}
|
@@ -1,2 +1,22 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
type IRegionCode = 'AY' | 'AZ' | 'EU' | 'IN' | 'UE' | 'WE' | 'RU';
|
2
|
+
type ICdnMap = Record<string, string> | Record<IRegionCode, Record<string, string>>;
|
3
|
+
/**
|
4
|
+
* 获取 CDN 地址
|
5
|
+
* @description 基础库 2.26.0 及以上版本推荐使用此方法,可以准确获取区域码。
|
6
|
+
* 基础库 2.26.0 以下版本请使用 getCdnUrlAsync 方法,以避免区域码获取不准确的问题。
|
7
|
+
* @param path - 图片路径
|
8
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
9
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
10
|
+
* @returns CDN 完整地址
|
11
|
+
*/
|
12
|
+
export default function getCdnUrl(path: string, cdnMap?: ICdnMap, region?: IRegionCode): string;
|
13
|
+
/**
|
14
|
+
* 获取 CDN 地址
|
15
|
+
* @description 基础库 2.26.0 以下版本请使用此方法,以避免区域码获取不准确的问题。
|
16
|
+
* @param path - 图片路径
|
17
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
18
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
19
|
+
* @returns CDN 完整地址
|
20
|
+
*/
|
21
|
+
export declare function getCdnUrlAsync(path: string, cdnMap?: ICdnMap, region?: IRegionCode): Promise<string>;
|
22
|
+
export {};
|
@@ -1,7 +1,62 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import get from 'lodash/get';
|
2
|
+
const regionMap = {
|
3
|
+
AY: 'https://images.tuyacn.com'
|
4
|
+
};
|
5
|
+
const concatRegionOrigin = (regionCode, path) => {
|
6
|
+
const regionOrigin = get(regionMap, [regionCode]) || get(regionMap, ['EU']);
|
7
|
+
if (path.indexOf('/') === 0) {
|
8
|
+
return `${regionOrigin}${path}`;
|
9
|
+
}
|
10
|
+
return `${regionOrigin}/${path}`;
|
11
|
+
};
|
12
|
+
const isEmptyOrUndefined = obj => {
|
13
|
+
return !obj || Object.keys(obj).length === 0;
|
14
|
+
};
|
15
|
+
|
16
|
+
/**
|
17
|
+
* 获取 CDN 地址
|
18
|
+
* @description 基础库 2.26.0 及以上版本推荐使用此方法,可以准确获取区域码。
|
19
|
+
* 基础库 2.26.0 以下版本请使用 getCdnUrlAsync 方法,以避免区域码获取不准确的问题。
|
20
|
+
* @param path - 图片路径
|
21
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
22
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
23
|
+
* @returns CDN 完整地址
|
24
|
+
*/
|
25
|
+
export default function getCdnUrl(path, cdnMap) {
|
26
|
+
const regionCode = 'AY';
|
27
|
+
if (isEmptyOrUndefined(cdnMap)) {
|
28
|
+
// 如果未提供 cdnMap,则使用 regionMap 直接与 path 进行拼接
|
29
|
+
return concatRegionOrigin(regionCode, path);
|
30
|
+
}
|
31
|
+
|
32
|
+
// 总是使用 EU 进行兜底
|
33
|
+
const cdnShortPath = get(cdnMap, [regionCode, path]) || get(cdnMap, ['AY', path]) || get(cdnMap, [path]);
|
34
|
+
if (!cdnShortPath) {
|
35
|
+
console.warn(`[App] cdn "${path}" is not exist.`);
|
36
|
+
return path;
|
37
|
+
}
|
38
|
+
if (cdnShortPath.indexOf('http') === 0 || cdnShortPath.indexOf('//') === 0) {
|
39
|
+
return cdnShortPath;
|
40
|
+
}
|
41
|
+
if (cdnShortPath.indexOf('/') === 0) {
|
42
|
+
return `${regionMap[regionCode]}${cdnShortPath}`;
|
43
|
+
}
|
44
|
+
return `${regionMap[regionCode]}/${cdnShortPath}`;
|
3
45
|
}
|
4
|
-
|
5
|
-
|
6
|
-
|
46
|
+
|
47
|
+
/**
|
48
|
+
* 获取 CDN 地址
|
49
|
+
* @description 基础库 2.26.0 以下版本请使用此方法,以避免区域码获取不准确的问题。
|
50
|
+
* @param path - 图片路径
|
51
|
+
* @param cdnMap - CDN 地址映射表,若未提供,则使用内置 regionMap 直接与 path 进行拼接
|
52
|
+
* @param region - 区域代码,若未提供,则使用内置方法获取,EU 兜底
|
53
|
+
* @returns CDN 完整地址
|
54
|
+
*/
|
55
|
+
export async function getCdnUrlAsync(path, cdnMap) {
|
56
|
+
let _regionCode = 'AY';
|
57
|
+
if (isEmptyOrUndefined(cdnMap)) {
|
58
|
+
// 如果未提供 cdnMap,则使用 regionMap 直接与 path 进行拼接
|
59
|
+
return concatRegionOrigin(_regionCode, path);
|
60
|
+
}
|
61
|
+
return getCdnUrl(path, cdnMap, _regionCode);
|
7
62
|
}
|
package/lib/panel/i18n/index.js
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
import "core-js/modules/es.regexp.constructor.js";
|
2
|
-
import "core-js/modules/es.regexp.dot-all.js";
|
3
|
-
import "core-js/modules/es.regexp.exec.js";
|
4
|
-
import "core-js/modules/es.string.replace.js";
|
5
1
|
import "core-js/modules/esnext.iterator.map.js";
|
6
2
|
import { requestCloud, getSystemInfoSync, THING } from '../..';
|
7
3
|
import { getBitValue } from '../utils';
|
@@ -30,7 +26,7 @@ export default class I18N {
|
|
30
26
|
}
|
31
27
|
forceUpdateNetworkLang(productId) {
|
32
28
|
requestCloud({
|
33
|
-
api:
|
29
|
+
api: `${THING}.m.i18n.get`,
|
34
30
|
version: '1.0',
|
35
31
|
data: {
|
36
32
|
productId,
|
@@ -121,14 +117,14 @@ export default class I18N {
|
|
121
117
|
formatString(str) {
|
122
118
|
let res = str;
|
123
119
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
124
|
-
res = this._replaceAll(
|
120
|
+
res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
125
121
|
}
|
126
122
|
return res;
|
127
123
|
}
|
128
124
|
formatValue(key) {
|
129
125
|
let res = this.getLang(key);
|
130
126
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
131
|
-
res = this._replaceAll(
|
127
|
+
res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
132
128
|
}
|
133
129
|
return res;
|
134
130
|
}
|
@@ -141,17 +137,17 @@ export default class I18N {
|
|
141
137
|
getDpLang(code, value) {
|
142
138
|
let key;
|
143
139
|
if (typeof value === 'undefined') {
|
144
|
-
key =
|
140
|
+
key = `dp_${code}`.toLowerCase();
|
145
141
|
} else if (typeof value === 'boolean') {
|
146
142
|
const valStr = value ? 'on' : 'off';
|
147
|
-
key =
|
143
|
+
key = `dp_${code}_${valStr}`.toLowerCase();
|
148
144
|
} else {
|
149
|
-
key =
|
145
|
+
key = `dp_${code}_${value}`.toLowerCase();
|
150
146
|
}
|
151
147
|
return hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
152
148
|
}
|
153
149
|
getDpName(code, defaultName) {
|
154
|
-
const key =
|
150
|
+
const key = `dp_${code}`.toLowerCase();
|
155
151
|
return hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
|
156
152
|
}
|
157
153
|
getDpsLang(key) {
|
@@ -183,7 +179,7 @@ export default class I18N {
|
|
183
179
|
if (typeof schema === 'undefined') return result;
|
184
180
|
const lists = schema.range;
|
185
181
|
lists.map(v => {
|
186
|
-
const key =
|
182
|
+
const key = `dp_${dpCode}_${v}`.toLowerCase();
|
187
183
|
result[v] = hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
188
184
|
return null;
|
189
185
|
});
|
@@ -197,12 +193,12 @@ export default class I18N {
|
|
197
193
|
* @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
|
198
194
|
*/
|
199
195
|
parseCountdown(t, power) {
|
200
|
-
const h = parseFloat(
|
201
|
-
const m = parseFloat(
|
196
|
+
const h = parseFloat(`${t / 3600}`);
|
197
|
+
const m = parseFloat(`${t / 60 - h * 60}`);
|
202
198
|
const tHour = hasKey('t_hour') ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
|
203
199
|
const tMinute = hasKey('t_minute') ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
|
204
|
-
const time = h >= 1.0 ?
|
205
|
-
const key =
|
200
|
+
const time = h >= 1.0 ? `${Math.round(h)}${tHour}` : `${Math.round(m)}${tMinute}`;
|
201
|
+
const key = `countdown_${power ? 'on' : 'off'}`;
|
206
202
|
const str = hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
207
203
|
return this.formatString(str, time);
|
208
204
|
}
|
@@ -1,7 +1,3 @@
|
|
1
|
-
import "core-js/modules/es.regexp.constructor.js";
|
2
|
-
import "core-js/modules/es.regexp.dot-all.js";
|
3
|
-
import "core-js/modules/es.regexp.exec.js";
|
4
|
-
import "core-js/modules/es.string.replace.js";
|
5
1
|
import "core-js/modules/esnext.iterator.map.js";
|
6
2
|
import { requestCloud, getSystemInfoSync, THING } from '../..';
|
7
3
|
import { getBitValue } from '../utils';
|
@@ -20,7 +16,7 @@ export default class I18N {
|
|
20
16
|
}
|
21
17
|
forceUpdateNetworkLang(productId) {
|
22
18
|
requestCloud({
|
23
|
-
api:
|
19
|
+
api: `${THING}.m.i18n.get`,
|
24
20
|
version: '1.0',
|
25
21
|
data: {
|
26
22
|
productId,
|
@@ -111,14 +107,14 @@ export default class I18N {
|
|
111
107
|
formatString(str) {
|
112
108
|
let res = str;
|
113
109
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
114
|
-
res = this._replaceAll(
|
110
|
+
res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
115
111
|
}
|
116
112
|
return res;
|
117
113
|
}
|
118
114
|
formatValue(key) {
|
119
115
|
let res = typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
120
116
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
121
|
-
res = this._replaceAll(
|
117
|
+
res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
122
118
|
}
|
123
119
|
return res;
|
124
120
|
}
|
@@ -131,17 +127,17 @@ export default class I18N {
|
|
131
127
|
getDpLang(code, value) {
|
132
128
|
let key;
|
133
129
|
if (typeof value === 'undefined') {
|
134
|
-
key =
|
130
|
+
key = `dp_${code}`.toLowerCase();
|
135
131
|
} else if (typeof value === 'boolean') {
|
136
132
|
const valStr = value ? 'on' : 'off';
|
137
|
-
key =
|
133
|
+
key = `dp_${code}_${valStr}`.toLowerCase();
|
138
134
|
} else {
|
139
|
-
key =
|
135
|
+
key = `dp_${code}_${value}`.toLowerCase();
|
140
136
|
}
|
141
137
|
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
142
138
|
}
|
143
139
|
getDpName(code, defaultName) {
|
144
|
-
const key =
|
140
|
+
const key = `dp_${code}`.toLowerCase();
|
145
141
|
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
|
146
142
|
}
|
147
143
|
getDpsLang(key) {
|
@@ -173,7 +169,7 @@ export default class I18N {
|
|
173
169
|
if (typeof schema === 'undefined') return result;
|
174
170
|
const lists = schema.range;
|
175
171
|
lists.map(v => {
|
176
|
-
const key =
|
172
|
+
const key = `dp_${dpCode}_${v}`.toLowerCase();
|
177
173
|
result[v] = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
178
174
|
return null;
|
179
175
|
});
|
@@ -187,12 +183,12 @@ export default class I18N {
|
|
187
183
|
* @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
|
188
184
|
*/
|
189
185
|
parseCountdown(t, power) {
|
190
|
-
const h = parseFloat(
|
191
|
-
const m = parseFloat(
|
186
|
+
const h = parseFloat(`${t / 3600}`);
|
187
|
+
const m = parseFloat(`${t / 60 - h * 60}`);
|
192
188
|
const tHour = I18n.t('t_hour') !== 't_hour' ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
|
193
189
|
const tMinute = I18n.t('t_minute') !== 't_minute' ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
|
194
|
-
const time = h >= 1.0 ?
|
195
|
-
const key =
|
190
|
+
const time = h >= 1.0 ? `${Math.round(h)}${tHour}` : `${Math.round(m)}${tMinute}`;
|
191
|
+
const key = `countdown_${power ? 'on' : 'off'}`;
|
196
192
|
const str = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
197
193
|
return this.formatString(str, time);
|
198
194
|
}
|
package/lib/panel/publishDps.js
CHANGED
@@ -27,7 +27,7 @@ export function sendDps(data) {
|
|
27
27
|
const codeIds = (devInfo === null || devInfo === void 0 ? void 0 : devInfo.codeIds) || {};
|
28
28
|
Object.keys(data).forEach(code => {
|
29
29
|
if (codeIds[code] !== undefined) {
|
30
|
-
dps[
|
30
|
+
dps[`${codeIds[code]}`] = data[code];
|
31
31
|
} else {
|
32
32
|
dps[code] = data[code];
|
33
33
|
}
|