@ray-js/api 1.6.19 → 1.6.20
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 +13 -13
- package/lib/cloud/doorlock/fittings.js +4 -4
- package/lib/cloud/doorlock/log.js +7 -7
- package/lib/cloud/doorlock/member-opmode.js +6 -6
- package/lib/cloud/doorlock/member.js +13 -13
- package/lib/cloud/doorlock/offline-pwd.js +4 -4
- package/lib/cloud/doorlock/sence.js +3 -3
- package/lib/cloud/doorlock/service.js +1 -1
- package/lib/cloud/doorlock/setting.js +11 -11
- package/lib/cloud/doorlock/temp-pwd.js +7 -7
- package/lib/cloud/doorlock/unlock-method.js +3 -3
- package/lib/cloud/doorlock/unlock.js +3 -3
- package/lib/cloud/interface.js +3 -2
- 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.thing.js +5 -5
- package/lib/getCdnUrl/index.wechat.js +5 -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/recipe/star.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3
3
|
const _excluded = ["query"];
|
4
|
-
import "core-js/modules/es.json.stringify.js";
|
5
4
|
import { THING } from '../../constants';
|
6
5
|
import requestCloud from '../../requestCloud';
|
7
6
|
// #region 获取食谱收藏列表
|
@@ -37,7 +36,7 @@ export const getRecipeCollectionList = params => {
|
|
37
36
|
} = params,
|
38
37
|
rest = _objectWithoutProperties(params, _excluded);
|
39
38
|
return requestCloud({
|
40
|
-
api:
|
39
|
+
api: `${THING}.m.menu.star.list`,
|
41
40
|
version: '2.0',
|
42
41
|
data: _objectSpread({
|
43
42
|
queryJson: JSON.stringify(query)
|
@@ -66,7 +65,7 @@ export const getRecipeCollectionList = params => {
|
|
66
65
|
*/
|
67
66
|
export const addRecipeToFavorites = params => {
|
68
67
|
return requestCloud({
|
69
|
-
api:
|
68
|
+
api: `${THING}.m.menu.star.add`,
|
70
69
|
version: '1.0',
|
71
70
|
data: params
|
72
71
|
});
|
@@ -93,7 +92,7 @@ export const addRecipeToFavorites = params => {
|
|
93
92
|
*/
|
94
93
|
export const removeRecipeFromFavorites = params => {
|
95
94
|
return requestCloud({
|
96
|
-
api:
|
95
|
+
api: `${THING}.m.menu.star.delete`,
|
97
96
|
version: '1.0',
|
98
97
|
data: params
|
99
98
|
});
|
@@ -118,7 +117,7 @@ export const removeRecipeFromFavorites = params => {
|
|
118
117
|
*/
|
119
118
|
export const checkRecipeIsStarred = params => {
|
120
119
|
return requestCloud({
|
121
|
-
api:
|
120
|
+
api: `${THING}.m.menu.star.check`,
|
122
121
|
version: '1.0',
|
123
122
|
data: params
|
124
123
|
});
|
@@ -143,7 +142,7 @@ export const checkRecipeIsStarred = params => {
|
|
143
142
|
*/
|
144
143
|
export const getRecipeStarCount = params => {
|
145
144
|
return requestCloud({
|
146
|
-
api:
|
145
|
+
api: `${THING}.m.menu.star.count`,
|
147
146
|
version: '1.0',
|
148
147
|
data: params
|
149
148
|
});
|
package/lib/cloud/remoteGroup.js
CHANGED
@@ -6,7 +6,7 @@ import { THING } from '../constants';
|
|
6
6
|
*/
|
7
7
|
const getZigbeeLocalGroupRelation = params => {
|
8
8
|
return requestCloud({
|
9
|
-
api:
|
9
|
+
api: `${THING}.p.remote.local.relation.get`,
|
10
10
|
version: '1.0',
|
11
11
|
data: {
|
12
12
|
devId: params.devId,
|
@@ -20,7 +20,7 @@ const getZigbeeLocalGroupRelation = params => {
|
|
20
20
|
*/
|
21
21
|
const getZigbeeLocalGroupDeviceList = params => {
|
22
22
|
return requestCloud({
|
23
|
-
api:
|
23
|
+
api: `${THING}.m.device.group.dev.list`,
|
24
24
|
version: '1.0',
|
25
25
|
data: params,
|
26
26
|
extData: {
|
package/lib/cloud/statistic.js
CHANGED
@@ -14,7 +14,7 @@ import { THING } from '../constants';
|
|
14
14
|
*/
|
15
15
|
const getLogInSpecifiedTime = params => {
|
16
16
|
return requestCloud({
|
17
|
-
api:
|
17
|
+
api: `${THING}.m.smart.operate.all.log`,
|
18
18
|
version: '1.0',
|
19
19
|
data: _objectSpread({}, params)
|
20
20
|
});
|
@@ -62,7 +62,7 @@ const getLogUserAction = params => {
|
|
62
62
|
*/
|
63
63
|
const getDpLogDays = params => {
|
64
64
|
return requestCloud({
|
65
|
-
api:
|
65
|
+
api: `${THING}.m.dp.stat.days.list`,
|
66
66
|
version: '1.0',
|
67
67
|
data: _objectSpread({}, params)
|
68
68
|
});
|
@@ -76,7 +76,7 @@ const getDpLogDays = params => {
|
|
76
76
|
*/
|
77
77
|
const getDpResultByMonth = params => {
|
78
78
|
return requestCloud({
|
79
|
-
api:
|
79
|
+
api: `${THING}.m.dp.stat.month.list`,
|
80
80
|
version: '1.0',
|
81
81
|
data: _objectSpread({}, params)
|
82
82
|
});
|
@@ -93,7 +93,7 @@ const getDpResultByMonth = params => {
|
|
93
93
|
*/
|
94
94
|
const getDpResultByHour = params => {
|
95
95
|
return requestCloud({
|
96
|
-
api:
|
96
|
+
api: `${THING}.m.dp.rang.stat.hour.list`,
|
97
97
|
version: '1.0',
|
98
98
|
data: _objectSpread({}, params)
|
99
99
|
});
|
@@ -111,7 +111,7 @@ const getDpResultByHour = params => {
|
|
111
111
|
*/
|
112
112
|
const getDataWithSpecified = params => {
|
113
113
|
return requestCloud({
|
114
|
-
api:
|
114
|
+
api: `${THING}.m.dp.rang.stat.day.list`,
|
115
115
|
version: '2.0',
|
116
116
|
data: _objectSpread({}, params)
|
117
117
|
});
|
@@ -127,7 +127,7 @@ const getDataWithSpecified = params => {
|
|
127
127
|
*/
|
128
128
|
const getWeekWithSpecified = params => {
|
129
129
|
return requestCloud({
|
130
|
-
api:
|
130
|
+
api: `${THING}.m.dp.rang.stat.week.list`,
|
131
131
|
version: '1.0',
|
132
132
|
data: _objectSpread({}, params)
|
133
133
|
});
|
@@ -145,7 +145,7 @@ const getWeekWithSpecified = params => {
|
|
145
145
|
*/
|
146
146
|
const getMonthWithSpecified = params => {
|
147
147
|
return requestCloud({
|
148
|
-
api:
|
148
|
+
api: `${THING}.m.dp.rang.stat.month.list`,
|
149
149
|
version: '2.0',
|
150
150
|
data: _objectSpread({}, params)
|
151
151
|
});
|
@@ -159,7 +159,7 @@ const getMonthWithSpecified = params => {
|
|
159
159
|
*/
|
160
160
|
const getDpAllStatistResult = params => {
|
161
161
|
return requestCloud({
|
162
|
-
api:
|
162
|
+
api: `${THING}.m.dp.stat.total`,
|
163
163
|
version: '1.0',
|
164
164
|
data: _objectSpread({}, params)
|
165
165
|
});
|
@@ -179,7 +179,7 @@ const getDpAllStatistResult = params => {
|
|
179
179
|
*/
|
180
180
|
const getMultiDpsAllResult = params => {
|
181
181
|
return requestCloud({
|
182
|
-
api:
|
182
|
+
api: `${THING}.m.device.query.device.log`,
|
183
183
|
version: '1.0',
|
184
184
|
data: _objectSpread({}, params)
|
185
185
|
});
|
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
|
});
|
@@ -42,9 +42,9 @@ export function getRegionCode() {
|
|
42
42
|
const concatRegionOrigin = (regionCode, path) => {
|
43
43
|
const regionOrigin = get(regionMap, [regionCode]) || get(regionMap, ['EU']);
|
44
44
|
if (path.indexOf('/') === 0) {
|
45
|
-
return
|
45
|
+
return `${regionOrigin}${path}`;
|
46
46
|
}
|
47
|
-
return
|
47
|
+
return `${regionOrigin}/${path}`;
|
48
48
|
};
|
49
49
|
const isEmptyOrUndefined = obj => {
|
50
50
|
return !obj || Object.keys(obj).length === 0;
|
@@ -69,16 +69,16 @@ export default function getCdnUrl(path, cdnMap, region) {
|
|
69
69
|
// 总是使用 EU 进行兜底
|
70
70
|
const cdnShortPath = get(cdnMap, [regionCode, path]) || get(cdnMap, ['EU', path]) || get(cdnMap, [path]);
|
71
71
|
if (!cdnShortPath) {
|
72
|
-
console.warn(
|
72
|
+
console.warn(`[App] cdn "${path}" is not exist.`);
|
73
73
|
return path;
|
74
74
|
}
|
75
75
|
if (cdnShortPath.indexOf('http') === 0 || cdnShortPath.indexOf('//') === 0) {
|
76
76
|
return cdnShortPath;
|
77
77
|
}
|
78
78
|
if (cdnShortPath.indexOf('/') === 0) {
|
79
|
-
return
|
79
|
+
return `${regionMap[regionCode]}${cdnShortPath}`;
|
80
80
|
}
|
81
|
-
return
|
81
|
+
return `${regionMap[regionCode]}/${cdnShortPath}`;
|
82
82
|
}
|
83
83
|
|
84
84
|
/**
|
@@ -5,9 +5,9 @@ const regionMap = {
|
|
5
5
|
const concatRegionOrigin = (regionCode, path) => {
|
6
6
|
const regionOrigin = get(regionMap, [regionCode]) || get(regionMap, ['EU']);
|
7
7
|
if (path.indexOf('/') === 0) {
|
8
|
-
return
|
8
|
+
return `${regionOrigin}${path}`;
|
9
9
|
}
|
10
|
-
return
|
10
|
+
return `${regionOrigin}/${path}`;
|
11
11
|
};
|
12
12
|
const isEmptyOrUndefined = obj => {
|
13
13
|
return !obj || Object.keys(obj).length === 0;
|
@@ -32,16 +32,16 @@ export default function getCdnUrl(path, cdnMap) {
|
|
32
32
|
// 总是使用 EU 进行兜底
|
33
33
|
const cdnShortPath = get(cdnMap, [regionCode, path]) || get(cdnMap, ['AY', path]) || get(cdnMap, [path]);
|
34
34
|
if (!cdnShortPath) {
|
35
|
-
console.warn(
|
35
|
+
console.warn(`[App] cdn "${path}" is not exist.`);
|
36
36
|
return path;
|
37
37
|
}
|
38
38
|
if (cdnShortPath.indexOf('http') === 0 || cdnShortPath.indexOf('//') === 0) {
|
39
39
|
return cdnShortPath;
|
40
40
|
}
|
41
41
|
if (cdnShortPath.indexOf('/') === 0) {
|
42
|
-
return
|
42
|
+
return `${regionMap[regionCode]}${cdnShortPath}`;
|
43
43
|
}
|
44
|
-
return
|
44
|
+
return `${regionMap[regionCode]}/${cdnShortPath}`;
|
45
45
|
}
|
46
46
|
|
47
47
|
/**
|
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
|
}
|
package/lib/redirectTo/index.js
CHANGED
package/lib/utils.js
CHANGED
@@ -4,15 +4,15 @@ export function createFactory(kitName) {
|
|
4
4
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5
5
|
return function () {
|
6
6
|
var _inst$opts$namespace;
|
7
|
-
const methodName =
|
7
|
+
const methodName = `ty.${opts.namespace ? opts.namespace + '.' : ''}${name}`;
|
8
8
|
if (opts.deprecated) {
|
9
|
-
console.warn("
|
9
|
+
console.warn(`"${methodName}" method has been deprecated.`);
|
10
10
|
}
|
11
11
|
const inst = typeof ty === 'undefined' ? {} : ty;
|
12
12
|
const method = opts.namespace ? ((_inst$opts$namespace = inst[opts.namespace]) !== null && _inst$opts$namespace !== void 0 ? _inst$opts$namespace : {})[name] : inst[name];
|
13
13
|
if (!method) {
|
14
|
-
console.warn('tips:', "
|
15
|
-
console.warn('tips:',
|
14
|
+
console.warn('tips:', `"${methodName}" method not exits.`);
|
15
|
+
console.warn('tips:', `Please check kit "${kitName}" dependency is enabled.`);
|
16
16
|
return;
|
17
17
|
}
|
18
18
|
// eslint-disable-next-line prefer-rest-params
|
@@ -24,14 +24,14 @@ export function factory(name) {
|
|
24
24
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
25
25
|
return function () {
|
26
26
|
var _inst$opts$namespace2;
|
27
|
-
const methodName =
|
27
|
+
const methodName = `ty.${opts.namespace ? opts.namespace + '.' : ''}${name}`;
|
28
28
|
if (opts.deprecated) {
|
29
|
-
console.warn("
|
29
|
+
console.warn(`"${methodName}" method has been deprecated.`);
|
30
30
|
}
|
31
31
|
const inst = typeof ty === 'undefined' ? {} : ty;
|
32
32
|
const method = opts.namespace ? ((_inst$opts$namespace2 = inst[opts.namespace]) !== null && _inst$opts$namespace2 !== void 0 ? _inst$opts$namespace2 : {})[name] : inst[name];
|
33
33
|
if (!method) {
|
34
|
-
console.warn('tips:', "
|
34
|
+
console.warn('tips:', `"${methodName}" method not exits.`);
|
35
35
|
return;
|
36
36
|
}
|
37
37
|
// eslint-disable-next-line prefer-rest-params
|
@@ -41,11 +41,11 @@ export function factory(name) {
|
|
41
41
|
export function factoryConstants(name) {
|
42
42
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
43
43
|
if (opts.deprecated) {
|
44
|
-
console.warn("
|
44
|
+
console.warn(`"ty.${name}" constant has been deprecated.`);
|
45
45
|
}
|
46
46
|
const inst = typeof ty === 'undefined' ? {} : ty;
|
47
47
|
if (!inst[name]) {
|
48
|
-
console.warn('tips', "
|
48
|
+
console.warn('tips', `"ty.${name}" constant not exits.`);
|
49
49
|
return;
|
50
50
|
}
|
51
51
|
return inst[name];
|
package/lib/utils.wechat.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import "core-js/modules/es.regexp.exec.js";
|
2
1
|
// @ts-ignore
|
3
2
|
import * as tyWx from '@ray-js/wechat';
|
4
3
|
import { stringifyUrl as _stringifyUrl, parseUrl as _parseUrl } from 'query-string';
|
@@ -14,7 +13,7 @@ export function factory(name) {
|
|
14
13
|
if (/(set|get|remove|clear)+Storage(Sync)?$/.test(name)) {
|
15
14
|
return function (option) {
|
16
15
|
if (opts.deprecated) {
|
17
|
-
console.warn(
|
16
|
+
console.warn(`该方法 ${name} 已弃用`);
|
18
17
|
}
|
19
18
|
// eslint-disable-next-line prefer-rest-params
|
20
19
|
return wx[name].call(this, option.key, option.data);
|
@@ -22,10 +21,10 @@ export function factory(name) {
|
|
22
21
|
}
|
23
22
|
return function () {
|
24
23
|
if (opts.deprecated) {
|
25
|
-
console.warn(
|
24
|
+
console.warn(`该方法 ${name} 已弃用`);
|
26
25
|
}
|
27
26
|
if (!tyWx[name] && !wx[name]) {
|
28
|
-
console.warn(
|
27
|
+
console.warn(`// TODO 暂未实现方法 wx.${name}`);
|
29
28
|
return;
|
30
29
|
}
|
31
30
|
// 优先取得 TTT 能力的方法
|
@@ -39,11 +38,11 @@ export function factory(name) {
|
|
39
38
|
export function factoryConstants(name) {
|
40
39
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
41
40
|
if (opts.deprecated) {
|
42
|
-
console.warn(
|
41
|
+
console.warn(`该变量 ${name} 已弃用`);
|
43
42
|
}
|
44
43
|
const inst = typeof wx === 'undefined' ? {} : wx;
|
45
44
|
if (!inst[name]) {
|
46
|
-
console.warn(
|
45
|
+
console.warn(`// TODO 暂未实现变量 ${name}`);
|
47
46
|
return;
|
48
47
|
}
|
49
48
|
return inst[name];
|