@ray-js/api 1.4.30 → 1.4.32
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/cloud/alarm.js +2 -2
- package/lib/cloud/core.js +1 -1
- package/lib/cloud/device.js +5 -5
- package/lib/cloud/linkage.js +8 -8
- package/lib/cloud/statistic.js +9 -9
- package/lib/cloud/timer.js +14 -14
- package/lib/getElementById/index.thing.js +1 -1
- package/lib/getElementById/index.wechat.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/nativeRouters/device.d.ts +80 -0
- package/lib/nativeRouters/device.js +163 -0
- package/lib/nativeRouters/index.d.ts +2 -1
- package/lib/nativeRouters/index.js +3 -2
- package/lib/nativeRouters/outdoors.d.ts +3 -3
- package/lib/nativeRouters/outdoors.js +33 -35
- package/lib/nativeRouters/root.d.ts +23 -0
- package/lib/nativeRouters/root.js +36 -0
- package/lib/panel/i18n/index.js +12 -13
- package/lib/panel/i18n/index.wechat.js +12 -13
- package/lib/panel/publishDps.js +1 -1
- package/lib/redirectTo/index.js +0 -1
- package/lib/utils.d.ts +3 -1
- package/lib/utils.js +21 -17
- package/lib/utils.wechat.js +5 -5
- package/package.json +7 -6
- package/lib/nativeRouters/scene.d.ts +0 -34
- package/lib/nativeRouters/scene.js +0 -60
package/lib/cloud/alarm.js
CHANGED
@@ -8,7 +8,7 @@ import { THING } from '../constants';
|
|
8
8
|
*/
|
9
9
|
const getDevAlarmList = devId => {
|
10
10
|
return requestCloud({
|
11
|
-
api:
|
11
|
+
api: `${THING}.m.linkage.rule.product.query`,
|
12
12
|
version: '1.0',
|
13
13
|
data: {
|
14
14
|
devId
|
@@ -24,7 +24,7 @@ const getDevAlarmList = devId => {
|
|
24
24
|
*/
|
25
25
|
const setAlarmSwitch = params => {
|
26
26
|
return requestCloud({
|
27
|
-
api:
|
27
|
+
api: `${THING}.m.linkage.dev.warn.set`,
|
28
28
|
version: '1.0',
|
29
29
|
data: _objectSpread({}, params)
|
30
30
|
});
|
package/lib/cloud/core.js
CHANGED
package/lib/cloud/device.js
CHANGED
@@ -52,7 +52,7 @@ const getGroupDpsInfos = groupId => {
|
|
52
52
|
*/
|
53
53
|
const updateGroupDpName = params => {
|
54
54
|
return requestCloud({
|
55
|
-
api:
|
55
|
+
api: `${THING}.m.group.dpname.update`,
|
56
56
|
version: '1.0',
|
57
57
|
data: _objectSpread({}, params)
|
58
58
|
});
|
@@ -65,7 +65,7 @@ const updateGroupDpName = params => {
|
|
65
65
|
*/
|
66
66
|
const getWeatherQuality = params => {
|
67
67
|
return requestCloud({
|
68
|
-
api:
|
68
|
+
api: `${THING}.m.public.weather.get`,
|
69
69
|
version: '2.0',
|
70
70
|
data: _objectSpread({}, params)
|
71
71
|
});
|
@@ -78,7 +78,7 @@ const getWeatherQuality = params => {
|
|
78
78
|
*/
|
79
79
|
const getWeathers = params => {
|
80
80
|
return requestCloud({
|
81
|
-
api:
|
81
|
+
api: `${THING}.m.public.weathers.get`,
|
82
82
|
version: '2.0',
|
83
83
|
data: _objectSpread({}, params)
|
84
84
|
});
|
@@ -93,7 +93,7 @@ const getWeathers = params => {
|
|
93
93
|
*/
|
94
94
|
const saveCustomizePosition = params => {
|
95
95
|
return requestCloud({
|
96
|
-
api:
|
96
|
+
api: `${THING}.m.device.customize.position.save`,
|
97
97
|
version: '1.0',
|
98
98
|
data: _objectSpread({}, params)
|
99
99
|
});
|
@@ -105,7 +105,7 @@ const saveCustomizePosition = params => {
|
|
105
105
|
*/
|
106
106
|
const getCustomizePosition = params => {
|
107
107
|
return requestCloud({
|
108
|
-
api:
|
108
|
+
api: `${THING}.m.device.customize.position.get`,
|
109
109
|
version: '1.0',
|
110
110
|
data: _objectSpread({}, params)
|
111
111
|
});
|
package/lib/cloud/linkage.js
CHANGED
@@ -8,7 +8,7 @@ import { THING } from '../constants';
|
|
8
8
|
*/
|
9
9
|
const getLinkageDeviceList = params => {
|
10
10
|
return requestCloud({
|
11
|
-
api:
|
11
|
+
api: `${THING}.m.linkage.dev.list`,
|
12
12
|
version: '3.0',
|
13
13
|
data: _objectSpread({}, params)
|
14
14
|
});
|
@@ -23,7 +23,7 @@ const getSceneList = _ref => {
|
|
23
23
|
devId
|
24
24
|
} = _ref;
|
25
25
|
return requestCloud({
|
26
|
-
api:
|
26
|
+
api: `${THING}.m.linkage.rule.brief.query`,
|
27
27
|
version: '1.0',
|
28
28
|
data: {
|
29
29
|
devId
|
@@ -40,7 +40,7 @@ const getSceneList = _ref => {
|
|
40
40
|
|
41
41
|
const getBindRuleList = params => {
|
42
42
|
return requestCloud({
|
43
|
-
api:
|
43
|
+
api: `${THING}.m.linkage.associative.entity.id.category.query`,
|
44
44
|
version: '1.0',
|
45
45
|
data: _objectSpread({}, params)
|
46
46
|
});
|
@@ -65,7 +65,7 @@ const bindRule = _ref2 => {
|
|
65
65
|
bizDomain
|
66
66
|
} = _ref2;
|
67
67
|
return requestCloud({
|
68
|
-
api:
|
68
|
+
api: `${THING}.m.linkage.associative.entity.bind`,
|
69
69
|
version: '1.0',
|
70
70
|
data: {
|
71
71
|
relationExpr: {
|
@@ -102,7 +102,7 @@ const bindRule = _ref2 => {
|
|
102
102
|
*/
|
103
103
|
const removeRule = params => {
|
104
104
|
return requestCloud({
|
105
|
-
api:
|
105
|
+
api: `${THING}.m.linkage.associative.entity.remove`,
|
106
106
|
version: '1.0',
|
107
107
|
data: _objectSpread({}, params)
|
108
108
|
});
|
@@ -117,7 +117,7 @@ const triggerRule = _ref3 => {
|
|
117
117
|
ruleId
|
118
118
|
} = _ref3;
|
119
119
|
return requestCloud({
|
120
|
-
api:
|
120
|
+
api: `${THING}.m.linkage.rule.trigger`,
|
121
121
|
version: '1.0',
|
122
122
|
data: {
|
123
123
|
ruleId
|
@@ -134,7 +134,7 @@ const enableRule = _ref4 => {
|
|
134
134
|
ruleId
|
135
135
|
} = _ref4;
|
136
136
|
return requestCloud({
|
137
|
-
api:
|
137
|
+
api: `${THING}.m.linkage.rule.enable`,
|
138
138
|
version: '1.0',
|
139
139
|
data: {
|
140
140
|
ruleId
|
@@ -151,7 +151,7 @@ const disableRule = _ref5 => {
|
|
151
151
|
ruleId
|
152
152
|
} = _ref5;
|
153
153
|
return requestCloud({
|
154
|
-
api:
|
154
|
+
api: `${THING}.m.linkage.rule.disable`,
|
155
155
|
version: '1.0',
|
156
156
|
data: {
|
157
157
|
ruleId
|
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
|
});
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
@@ -0,0 +1,80 @@
|
|
1
|
+
type OpenSceneCreateParams = {
|
2
|
+
devId?: string;
|
3
|
+
success?: () => void;
|
4
|
+
fail?: (err?: {
|
5
|
+
errorMsg: string;
|
6
|
+
errorCode: string | number;
|
7
|
+
innerError: {
|
8
|
+
errorCode: string | number;
|
9
|
+
errorMsg: string;
|
10
|
+
};
|
11
|
+
}) => void;
|
12
|
+
complete?: () => void;
|
13
|
+
} & {
|
14
|
+
[key: string]: string | boolean | number;
|
15
|
+
};
|
16
|
+
export declare function openSceneCreate(params?: OpenSceneCreateParams): Promise<void>;
|
17
|
+
export declare const openCreateScene: typeof openSceneCreate;
|
18
|
+
export declare function openUniversalCreateScene(params?: OpenSceneCreateParams): Promise<void>;
|
19
|
+
type OpenSceneEdit = {
|
20
|
+
devId?: string;
|
21
|
+
sceneId?: string;
|
22
|
+
success?: () => void;
|
23
|
+
fail?: (err?: {
|
24
|
+
errorMsg: string;
|
25
|
+
errorCode: string | number;
|
26
|
+
innerError: {
|
27
|
+
errorCode: string | number;
|
28
|
+
errorMsg: string;
|
29
|
+
};
|
30
|
+
}) => void;
|
31
|
+
complete?: () => void;
|
32
|
+
} & {
|
33
|
+
[key: string]: string | boolean | number;
|
34
|
+
};
|
35
|
+
export declare function openSceneEdit(params?: OpenSceneEdit): Promise<void>;
|
36
|
+
export declare const openEditScene: typeof openSceneEdit;
|
37
|
+
type OpenGuideScene = {
|
38
|
+
action?: 'add' | 'edit';
|
39
|
+
success?: () => void;
|
40
|
+
fail?: (err?: {
|
41
|
+
errorMsg: string;
|
42
|
+
errorCode: string | number;
|
43
|
+
innerError: {
|
44
|
+
errorCode: string | number;
|
45
|
+
errorMsg: string;
|
46
|
+
};
|
47
|
+
}) => void;
|
48
|
+
complete?: () => void;
|
49
|
+
} & {
|
50
|
+
[key: string]: string | boolean | number;
|
51
|
+
};
|
52
|
+
/**
|
53
|
+
* 打开APP引导场景页
|
54
|
+
* @param params { action?: 'add' | 'edit', success?: () => void, fail?: (err?: { errorMsg: string, errorCode: string | number, innerError: { errorCode: string | number, errorMsg: string } }) => void, complete?: () => void, [key: string]: string | boolean | number }
|
55
|
+
* @returns
|
56
|
+
*/
|
57
|
+
export declare function openGuideScene(params?: OpenGuideScene): Promise<void>;
|
58
|
+
type OpenConfigDevice = {
|
59
|
+
devId?: string;
|
60
|
+
sceneId?: string;
|
61
|
+
success?: () => void;
|
62
|
+
fail?: (err?: {
|
63
|
+
errorMsg: string;
|
64
|
+
errorCode: string | number;
|
65
|
+
innerError: {
|
66
|
+
errorCode: string | number;
|
67
|
+
errorMsg: string;
|
68
|
+
};
|
69
|
+
}) => void;
|
70
|
+
complete?: () => void;
|
71
|
+
} & {
|
72
|
+
[key: string]: string | boolean | number;
|
73
|
+
};
|
74
|
+
/**
|
75
|
+
* 打开编辑场景页面
|
76
|
+
* @param params { devId?: string, sceneId?: string, success?: () => void, fail?: (err?: { errorMsg: string, errorCode: string | number, innerError: { errorCode: string | number, errorMsg: string } }) => void, complete?: () => void, [key: string]: string | boolean | number }
|
77
|
+
* @returns
|
78
|
+
*/
|
79
|
+
export declare function openConfigDevice(params?: OpenConfigDevice): Promise<void>;
|
80
|
+
export {};
|
@@ -0,0 +1,163 @@
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2
|
+
const _excluded = ["success", "fail", "complete"],
|
3
|
+
_excluded2 = ["success", "fail", "complete"],
|
4
|
+
_excluded3 = ["success", "fail", "complete"],
|
5
|
+
_excluded4 = ["success", "fail", "complete"],
|
6
|
+
_excluded5 = ["success", "fail", "complete"];
|
7
|
+
import { isAndroid } from '@ray-js/env';
|
8
|
+
import { stringifyUrl } from '../utils';
|
9
|
+
export function openSceneCreate(params) {
|
10
|
+
const _ref = params || {},
|
11
|
+
{
|
12
|
+
success,
|
13
|
+
fail,
|
14
|
+
complete
|
15
|
+
} = _ref,
|
16
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
17
|
+
return new Promise((resolve, reject) => {
|
18
|
+
ty.router({
|
19
|
+
url: stringifyUrl({
|
20
|
+
url: 'createScene',
|
21
|
+
query: rest
|
22
|
+
}),
|
23
|
+
success() {
|
24
|
+
success === null || success === void 0 ? void 0 : success();
|
25
|
+
resolve();
|
26
|
+
},
|
27
|
+
fail(err) {
|
28
|
+
fail === null || fail === void 0 ? void 0 : fail(err);
|
29
|
+
reject(err);
|
30
|
+
},
|
31
|
+
complete() {
|
32
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
33
|
+
}
|
34
|
+
});
|
35
|
+
});
|
36
|
+
}
|
37
|
+
export const openCreateScene = openSceneCreate;
|
38
|
+
|
39
|
+
// 兼容Android 端仅支持 Zigbee 本地场景, Android使用createSmartScene
|
40
|
+
export function openUniversalCreateScene(params) {
|
41
|
+
const _ref2 = params || {},
|
42
|
+
{
|
43
|
+
success,
|
44
|
+
fail,
|
45
|
+
complete
|
46
|
+
} = _ref2,
|
47
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
48
|
+
const url = isAndroid ? 'createSmartScene' : 'createScene';
|
49
|
+
return new Promise((resolve, reject) => {
|
50
|
+
ty.router({
|
51
|
+
url: stringifyUrl({
|
52
|
+
url,
|
53
|
+
query: rest
|
54
|
+
}),
|
55
|
+
success() {
|
56
|
+
success === null || success === void 0 ? void 0 : success();
|
57
|
+
resolve();
|
58
|
+
},
|
59
|
+
fail(err) {
|
60
|
+
fail === null || fail === void 0 ? void 0 : fail(err);
|
61
|
+
reject(err);
|
62
|
+
},
|
63
|
+
complete() {
|
64
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
65
|
+
}
|
66
|
+
});
|
67
|
+
});
|
68
|
+
}
|
69
|
+
export function openSceneEdit(params) {
|
70
|
+
const _ref3 = params || {},
|
71
|
+
{
|
72
|
+
success,
|
73
|
+
fail,
|
74
|
+
complete
|
75
|
+
} = _ref3,
|
76
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
77
|
+
return new Promise((resolve, reject) => {
|
78
|
+
ty.router({
|
79
|
+
url: stringifyUrl({
|
80
|
+
url: 'editScene',
|
81
|
+
query: rest
|
82
|
+
}),
|
83
|
+
success() {
|
84
|
+
success === null || success === void 0 ? void 0 : success();
|
85
|
+
resolve();
|
86
|
+
},
|
87
|
+
fail(err) {
|
88
|
+
fail === null || fail === void 0 ? void 0 : fail(err);
|
89
|
+
reject(err);
|
90
|
+
},
|
91
|
+
complete() {
|
92
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
93
|
+
}
|
94
|
+
});
|
95
|
+
});
|
96
|
+
}
|
97
|
+
export const openEditScene = openSceneEdit;
|
98
|
+
/**
|
99
|
+
* 打开APP引导场景页
|
100
|
+
* @param params { action?: 'add' | 'edit', success?: () => void, fail?: (err?: { errorMsg: string, errorCode: string | number, innerError: { errorCode: string | number, errorMsg: string } }) => void, complete?: () => void, [key: string]: string | boolean | number }
|
101
|
+
* @returns
|
102
|
+
*/
|
103
|
+
export function openGuideScene(params) {
|
104
|
+
const _ref4 = params || {},
|
105
|
+
{
|
106
|
+
success,
|
107
|
+
fail,
|
108
|
+
complete
|
109
|
+
} = _ref4,
|
110
|
+
rest = _objectWithoutProperties(_ref4, _excluded4);
|
111
|
+
return new Promise((resolve, reject) => {
|
112
|
+
ty.router({
|
113
|
+
url: stringifyUrl({
|
114
|
+
url: 'thing_add_scene',
|
115
|
+
query: rest
|
116
|
+
}),
|
117
|
+
success() {
|
118
|
+
success === null || success === void 0 ? void 0 : success();
|
119
|
+
resolve();
|
120
|
+
},
|
121
|
+
fail(err) {
|
122
|
+
fail === null || fail === void 0 ? void 0 : fail(err);
|
123
|
+
reject(err);
|
124
|
+
},
|
125
|
+
complete() {
|
126
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
127
|
+
}
|
128
|
+
});
|
129
|
+
});
|
130
|
+
}
|
131
|
+
/**
|
132
|
+
* 打开编辑场景页面
|
133
|
+
* @param params { devId?: string, sceneId?: string, success?: () => void, fail?: (err?: { errorMsg: string, errorCode: string | number, innerError: { errorCode: string | number, errorMsg: string } }) => void, complete?: () => void, [key: string]: string | boolean | number }
|
134
|
+
* @returns
|
135
|
+
*/
|
136
|
+
export function openConfigDevice(params) {
|
137
|
+
const _ref5 = params || {},
|
138
|
+
{
|
139
|
+
success,
|
140
|
+
fail,
|
141
|
+
complete
|
142
|
+
} = _ref5,
|
143
|
+
rest = _objectWithoutProperties(_ref5, _excluded5);
|
144
|
+
return new Promise((resolve, reject) => {
|
145
|
+
ty.router({
|
146
|
+
url: stringifyUrl({
|
147
|
+
url: 'config_device',
|
148
|
+
query: rest
|
149
|
+
}),
|
150
|
+
success() {
|
151
|
+
success === null || success === void 0 ? void 0 : success();
|
152
|
+
resolve();
|
153
|
+
},
|
154
|
+
fail(err) {
|
155
|
+
fail === null || fail === void 0 ? void 0 : fail(err);
|
156
|
+
reject(err);
|
157
|
+
},
|
158
|
+
complete() {
|
159
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
160
|
+
}
|
161
|
+
});
|
162
|
+
});
|
163
|
+
}
|
@@ -1,2 +1,3 @@
|
|
1
|
-
export * from './
|
2
|
-
export * from './outdoors';
|
1
|
+
export * from './device';
|
2
|
+
export * from './outdoors';
|
3
|
+
export * from './root';
|
@@ -18,7 +18,7 @@ type OpenOutdoorCyclingNavigationParams = {
|
|
18
18
|
* @param params {devId: string}
|
19
19
|
* @returns
|
20
20
|
*/
|
21
|
-
export declare function openOutdoorCyclingNavigation(params
|
21
|
+
export declare function openOutdoorCyclingNavigation(params?: OpenOutdoorCyclingNavigationParams): Promise<void>;
|
22
22
|
type OpenAdditionalUnlockMethodsParams = {
|
23
23
|
devId?: string;
|
24
24
|
success?: () => void;
|
@@ -60,7 +60,7 @@ type OpenOutdoorAmbientLightingParams = {
|
|
60
60
|
* @param params {devId: string}
|
61
61
|
* @returns
|
62
62
|
*/
|
63
|
-
export declare function openOutdoorAmbientLighting(params
|
63
|
+
export declare function openOutdoorAmbientLighting(params?: OpenOutdoorAmbientLightingParams): Promise<void>;
|
64
64
|
type OpenOutdoorShortcutSiriParams = {
|
65
65
|
devId?: string;
|
66
66
|
success?: () => void;
|
@@ -102,5 +102,5 @@ type OpenOutdoorConfigDeviceHomeParams = {
|
|
102
102
|
* @param params {devId: string}
|
103
103
|
* @returns
|
104
104
|
*/
|
105
|
-
export declare function openOutdoorConfigDeviceHome(params
|
105
|
+
export declare function openOutdoorConfigDeviceHome(params?: OpenOutdoorConfigDeviceHomeParams): Promise<void>;
|
106
106
|
export {};
|
@@ -4,26 +4,26 @@ const _excluded = ["success", "fail", "complete"],
|
|
4
4
|
_excluded3 = ["success", "fail", "complete"],
|
5
5
|
_excluded4 = ["success", "fail", "complete"],
|
6
6
|
_excluded5 = ["success", "fail", "complete"];
|
7
|
-
import {
|
7
|
+
import { stringifyUrl } from '../utils';
|
8
8
|
/**
|
9
9
|
* 打开骑行导航页面
|
10
10
|
* @param params {devId: string}
|
11
11
|
* @returns
|
12
12
|
*/
|
13
13
|
export function openOutdoorCyclingNavigation(params) {
|
14
|
-
const {
|
14
|
+
const _ref = params || {},
|
15
|
+
{
|
15
16
|
success,
|
16
17
|
fail,
|
17
18
|
complete
|
18
|
-
} =
|
19
|
-
rest = _objectWithoutProperties(
|
20
|
-
let paramsStr = '';
|
21
|
-
if (Object.keys(rest).length > 0) {
|
22
|
-
paramsStr = '?' + objectToUrlParams(rest);
|
23
|
-
}
|
19
|
+
} = _ref,
|
20
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
24
21
|
return new Promise((resolve, reject) => {
|
25
22
|
ty.router({
|
26
|
-
url:
|
23
|
+
url: stringifyUrl({
|
24
|
+
url: 'tsod_outdoor_cycling_navigation',
|
25
|
+
query: rest
|
26
|
+
}),
|
27
27
|
success() {
|
28
28
|
success === null || success === void 0 ? void 0 : success();
|
29
29
|
resolve();
|
@@ -50,13 +50,12 @@ export function openAdditionalUnlockMethods(params) {
|
|
50
50
|
complete
|
51
51
|
} = params,
|
52
52
|
rest = _objectWithoutProperties(params, _excluded2);
|
53
|
-
let paramsStr = '';
|
54
|
-
if (Object.keys(rest).length > 0) {
|
55
|
-
paramsStr = '?' + objectToUrlParams(rest);
|
56
|
-
}
|
57
53
|
return new Promise((resolve, reject) => {
|
58
54
|
ty.router({
|
59
|
-
url:
|
55
|
+
url: stringifyUrl({
|
56
|
+
url: 'tsod_additional_unlock_methods',
|
57
|
+
query: rest
|
58
|
+
}),
|
60
59
|
success() {
|
61
60
|
success === null || success === void 0 ? void 0 : success();
|
62
61
|
resolve();
|
@@ -77,19 +76,19 @@ export function openAdditionalUnlockMethods(params) {
|
|
77
76
|
* @returns
|
78
77
|
*/
|
79
78
|
export function openOutdoorAmbientLighting(params) {
|
80
|
-
const {
|
79
|
+
const _ref2 = params || {},
|
80
|
+
{
|
81
81
|
success,
|
82
82
|
fail,
|
83
83
|
complete
|
84
|
-
} =
|
85
|
-
rest = _objectWithoutProperties(
|
86
|
-
let paramsStr = '';
|
87
|
-
if (Object.keys(rest).length > 0) {
|
88
|
-
paramsStr = '?' + objectToUrlParams(rest);
|
89
|
-
}
|
84
|
+
} = _ref2,
|
85
|
+
rest = _objectWithoutProperties(_ref2, _excluded3);
|
90
86
|
return new Promise((resolve, reject) => {
|
91
87
|
ty.router({
|
92
|
-
url:
|
88
|
+
url: stringifyUrl({
|
89
|
+
url: 'tsod_outdoor_ambient_lighting',
|
90
|
+
query: rest
|
91
|
+
}),
|
93
92
|
success() {
|
94
93
|
success === null || success === void 0 ? void 0 : success();
|
95
94
|
resolve();
|
@@ -116,13 +115,12 @@ export function openOutdoorShortcutSiri(params) {
|
|
116
115
|
complete
|
117
116
|
} = params,
|
118
117
|
rest = _objectWithoutProperties(params, _excluded4);
|
119
|
-
let paramsStr = '';
|
120
|
-
if (Object.keys(rest).length > 0) {
|
121
|
-
paramsStr = '?' + objectToUrlParams(rest);
|
122
|
-
}
|
123
118
|
return new Promise((resolve, reject) => {
|
124
119
|
ty.router({
|
125
|
-
url:
|
120
|
+
url: stringifyUrl({
|
121
|
+
url: 'tsod_outdoor_shortcut_siri',
|
122
|
+
query: rest
|
123
|
+
}),
|
126
124
|
success() {
|
127
125
|
success === null || success === void 0 ? void 0 : success();
|
128
126
|
resolve();
|
@@ -143,19 +141,19 @@ export function openOutdoorShortcutSiri(params) {
|
|
143
141
|
* @returns
|
144
142
|
*/
|
145
143
|
export function openOutdoorConfigDeviceHome(params) {
|
146
|
-
const {
|
144
|
+
const _ref3 = params || {},
|
145
|
+
{
|
147
146
|
success,
|
148
147
|
fail,
|
149
148
|
complete
|
150
|
-
} =
|
151
|
-
rest = _objectWithoutProperties(
|
152
|
-
let paramsStr = '';
|
153
|
-
if (Object.keys(rest).length > 0) {
|
154
|
-
paramsStr = '?' + objectToUrlParams(rest);
|
155
|
-
}
|
149
|
+
} = _ref3,
|
150
|
+
rest = _objectWithoutProperties(_ref3, _excluded5);
|
156
151
|
return new Promise((resolve, reject) => {
|
157
152
|
ty.router({
|
158
|
-
url:
|
153
|
+
url: stringifyUrl({
|
154
|
+
url: 'tsod_outdoor_config_device_home',
|
155
|
+
query: rest
|
156
|
+
}),
|
159
157
|
success() {
|
160
158
|
success === null || success === void 0 ? void 0 : success();
|
161
159
|
resolve();
|
@@ -0,0 +1,23 @@
|
|
1
|
+
type OpenAppScanParams = {
|
2
|
+
gwId?: string;
|
3
|
+
source?: string;
|
4
|
+
success?: () => void;
|
5
|
+
fail?: (err?: {
|
6
|
+
errorMsg: string;
|
7
|
+
errorCode: string | number;
|
8
|
+
innerError: {
|
9
|
+
errorCode: string | number;
|
10
|
+
errorMsg: string;
|
11
|
+
};
|
12
|
+
}) => void;
|
13
|
+
complete?: () => void;
|
14
|
+
} & {
|
15
|
+
[key: string]: string | boolean | number;
|
16
|
+
};
|
17
|
+
/**
|
18
|
+
* 打开APP扫码
|
19
|
+
* @param params {gwId: string, source: string}
|
20
|
+
* @returns
|
21
|
+
*/
|
22
|
+
export declare function openAppScan(params?: OpenAppScanParams): Promise<void>;
|
23
|
+
export {};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2
|
+
const _excluded = ["success", "fail", "complete"];
|
3
|
+
import { stringifyUrl } from '../utils';
|
4
|
+
/**
|
5
|
+
* 打开APP扫码
|
6
|
+
* @param params {gwId: string, source: string}
|
7
|
+
* @returns
|
8
|
+
*/
|
9
|
+
export function openAppScan(params) {
|
10
|
+
const _ref = params || {},
|
11
|
+
{
|
12
|
+
success,
|
13
|
+
fail,
|
14
|
+
complete
|
15
|
+
} = _ref,
|
16
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
17
|
+
return new Promise((resolve, reject) => {
|
18
|
+
ty.router({
|
19
|
+
url: stringifyUrl({
|
20
|
+
url: 'scan',
|
21
|
+
query: rest
|
22
|
+
}),
|
23
|
+
success() {
|
24
|
+
success === null || success === void 0 ? void 0 : success();
|
25
|
+
resolve();
|
26
|
+
},
|
27
|
+
fail(err) {
|
28
|
+
fail === null || fail === void 0 ? void 0 : fail(err);
|
29
|
+
reject(err);
|
30
|
+
},
|
31
|
+
complete() {
|
32
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
33
|
+
}
|
34
|
+
});
|
35
|
+
});
|
36
|
+
}
|
package/lib/panel/i18n/index.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import "core-js/modules/es.string.replace.js";
|
2
1
|
import { requestCloud, getSystemInfoSync, THING } from '../..';
|
3
2
|
import { getBitValue } from '../utils';
|
4
3
|
export default class I18N {
|
@@ -11,7 +10,7 @@ export default class I18N {
|
|
11
10
|
}
|
12
11
|
forceUpdateNetworkLang(productId) {
|
13
12
|
requestCloud({
|
14
|
-
api:
|
13
|
+
api: `${THING}.m.i18n.get`,
|
15
14
|
version: '1.0',
|
16
15
|
data: {
|
17
16
|
productId,
|
@@ -102,14 +101,14 @@ export default class I18N {
|
|
102
101
|
formatString(str) {
|
103
102
|
let res = str;
|
104
103
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
105
|
-
res = this._replaceAll(
|
104
|
+
res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
106
105
|
}
|
107
106
|
return res;
|
108
107
|
}
|
109
108
|
formatValue(key) {
|
110
109
|
let res = typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
111
110
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
112
|
-
res = this._replaceAll(
|
111
|
+
res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
113
112
|
}
|
114
113
|
return res;
|
115
114
|
}
|
@@ -122,17 +121,17 @@ export default class I18N {
|
|
122
121
|
getDpLang(code, value) {
|
123
122
|
let key;
|
124
123
|
if (typeof value === 'undefined') {
|
125
|
-
key =
|
124
|
+
key = `dp_${code}`.toLowerCase();
|
126
125
|
} else if (typeof value === 'boolean') {
|
127
126
|
const valStr = value ? 'on' : 'off';
|
128
|
-
key =
|
127
|
+
key = `dp_${code}_${valStr}`.toLowerCase();
|
129
128
|
} else {
|
130
|
-
key =
|
129
|
+
key = `dp_${code}_${value}`.toLowerCase();
|
131
130
|
}
|
132
131
|
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
133
132
|
}
|
134
133
|
getDpName(code, defaultName) {
|
135
|
-
const key =
|
134
|
+
const key = `dp_${code}`.toLowerCase();
|
136
135
|
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
|
137
136
|
}
|
138
137
|
getDpsLang(key) {
|
@@ -164,7 +163,7 @@ export default class I18N {
|
|
164
163
|
if (typeof schema === 'undefined') return result;
|
165
164
|
const lists = schema.range;
|
166
165
|
lists.map(v => {
|
167
|
-
const key =
|
166
|
+
const key = `dp_${dpCode}_${v}`.toLowerCase();
|
168
167
|
result[v] = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
169
168
|
return null;
|
170
169
|
});
|
@@ -178,12 +177,12 @@ export default class I18N {
|
|
178
177
|
* @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
|
179
178
|
*/
|
180
179
|
parseCountdown(t, power) {
|
181
|
-
const h = parseFloat(
|
182
|
-
const m = parseFloat(
|
180
|
+
const h = parseFloat(`${t / 3600}`);
|
181
|
+
const m = parseFloat(`${t / 60 - h * 60}`);
|
183
182
|
const tHour = I18n.t('t_hour') !== 't_hour' ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
|
184
183
|
const tMinute = I18n.t('t_minute') !== 't_minute' ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
|
185
|
-
const time = h >= 1.0 ?
|
186
|
-
const key =
|
184
|
+
const time = h >= 1.0 ? `${Math.round(h)}${tHour}` : `${Math.round(m)}${tMinute}`;
|
185
|
+
const key = `countdown_${power ? 'on' : 'off'}`;
|
187
186
|
const str = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
188
187
|
return this.formatString(str, time);
|
189
188
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import "core-js/modules/es.string.replace.js";
|
2
1
|
import { requestCloud, getSystemInfoSync, THING } from '../..';
|
3
2
|
import { getBitValue } from '../utils';
|
4
3
|
|
@@ -16,7 +15,7 @@ export default class I18N {
|
|
16
15
|
}
|
17
16
|
forceUpdateNetworkLang(productId) {
|
18
17
|
requestCloud({
|
19
|
-
api:
|
18
|
+
api: `${THING}.m.i18n.get`,
|
20
19
|
version: '1.0',
|
21
20
|
data: {
|
22
21
|
productId,
|
@@ -107,14 +106,14 @@ export default class I18N {
|
|
107
106
|
formatString(str) {
|
108
107
|
let res = str;
|
109
108
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
110
|
-
res = this._replaceAll(
|
109
|
+
res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
111
110
|
}
|
112
111
|
return res;
|
113
112
|
}
|
114
113
|
formatValue(key) {
|
115
114
|
let res = typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
116
115
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
117
|
-
res = this._replaceAll(
|
116
|
+
res = this._replaceAll(`{${i}}`, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
118
117
|
}
|
119
118
|
return res;
|
120
119
|
}
|
@@ -127,17 +126,17 @@ export default class I18N {
|
|
127
126
|
getDpLang(code, value) {
|
128
127
|
let key;
|
129
128
|
if (typeof value === 'undefined') {
|
130
|
-
key =
|
129
|
+
key = `dp_${code}`.toLowerCase();
|
131
130
|
} else if (typeof value === 'boolean') {
|
132
131
|
const valStr = value ? 'on' : 'off';
|
133
|
-
key =
|
132
|
+
key = `dp_${code}_${valStr}`.toLowerCase();
|
134
133
|
} else {
|
135
|
-
key =
|
134
|
+
key = `dp_${code}_${value}`.toLowerCase();
|
136
135
|
}
|
137
136
|
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
138
137
|
}
|
139
138
|
getDpName(code, defaultName) {
|
140
|
-
const key =
|
139
|
+
const key = `dp_${code}`.toLowerCase();
|
141
140
|
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
|
142
141
|
}
|
143
142
|
getDpsLang(key) {
|
@@ -169,7 +168,7 @@ export default class I18N {
|
|
169
168
|
if (typeof schema === 'undefined') return result;
|
170
169
|
const lists = schema.range;
|
171
170
|
lists.map(v => {
|
172
|
-
const key =
|
171
|
+
const key = `dp_${dpCode}_${v}`.toLowerCase();
|
173
172
|
result[v] = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
174
173
|
return null;
|
175
174
|
});
|
@@ -183,12 +182,12 @@ export default class I18N {
|
|
183
182
|
* @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
|
184
183
|
*/
|
185
184
|
parseCountdown(t, power) {
|
186
|
-
const h = parseFloat(
|
187
|
-
const m = parseFloat(
|
185
|
+
const h = parseFloat(`${t / 3600}`);
|
186
|
+
const m = parseFloat(`${t / 60 - h * 60}`);
|
188
187
|
const tHour = I18n.t('t_hour') !== 't_hour' ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
|
189
188
|
const tMinute = I18n.t('t_minute') !== 't_minute' ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
|
190
|
-
const time = h >= 1.0 ?
|
191
|
-
const key =
|
189
|
+
const time = h >= 1.0 ? `${Math.round(h)}${tHour}` : `${Math.round(m)}${tMinute}`;
|
190
|
+
const key = `countdown_${power ? 'on' : 'off'}`;
|
192
191
|
const str = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
193
192
|
return this.formatString(str, time);
|
194
193
|
}
|
package/lib/panel/publishDps.js
CHANGED
@@ -25,7 +25,7 @@ export function sendDps(data) {
|
|
25
25
|
const codeIds = (devInfo === null || devInfo === void 0 ? void 0 : devInfo.codeIds) || {};
|
26
26
|
Object.keys(data).forEach(code => {
|
27
27
|
if (codeIds[code] !== undefined) {
|
28
|
-
dps[
|
28
|
+
dps[`${codeIds[code]}`] = data[code];
|
29
29
|
} else {
|
30
30
|
dps[code] = data[code];
|
31
31
|
}
|
package/lib/redirectTo/index.js
CHANGED
package/lib/utils.d.ts
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
import { UrlObject } from 'query-string';
|
1
2
|
type Opts = {
|
2
3
|
deprecated?: boolean;
|
3
4
|
namespace?: string;
|
4
5
|
};
|
5
6
|
export declare function factory(name: string, opts?: Opts): () => any;
|
6
7
|
export declare function factoryContants(name: string, opts?: Opts): any;
|
7
|
-
export declare
|
8
|
+
export declare const parseUrl: (url: string) => import("query-string").ParsedUrl;
|
9
|
+
export declare const stringifyUrl: (object: UrlObject) => string;
|
8
10
|
export {};
|
package/lib/utils.js
CHANGED
@@ -1,41 +1,45 @@
|
|
1
|
+
import { stringifyUrl as _stringifyUrl, parseUrl as _parseUrl } from 'query-string';
|
1
2
|
export function factory(name) {
|
2
3
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
3
4
|
return function () {
|
4
5
|
var _inst$opts$namespace;
|
5
6
|
if (opts.deprecated) {
|
6
|
-
console.warn(
|
7
|
+
console.warn(`该方法 ${name} 已弃用`);
|
7
8
|
}
|
8
9
|
const inst = typeof ty === 'undefined' ? {} : ty;
|
9
10
|
const method = opts.namespace ? ((_inst$opts$namespace = inst[opts.namespace]) !== null && _inst$opts$namespace !== void 0 ? _inst$opts$namespace : {})[name] : inst[name];
|
10
11
|
if (!method) {
|
11
|
-
console.warn(
|
12
|
+
console.warn(`// TODO 暂未实现方法 ${opts.namespace ? opts.namespace + '.' : ''}${name}`);
|
12
13
|
return;
|
13
14
|
}
|
15
|
+
// eslint-disable-next-line prefer-rest-params
|
14
16
|
return method.apply(this, arguments);
|
15
17
|
};
|
16
18
|
}
|
17
19
|
export function factoryContants(name) {
|
18
20
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
19
21
|
if (opts.deprecated) {
|
20
|
-
console.warn(
|
22
|
+
console.warn(`该变量 ${name} 已弃用`);
|
21
23
|
}
|
22
24
|
const inst = typeof ty === 'undefined' ? {} : ty;
|
23
25
|
if (!inst[name]) {
|
24
|
-
console.warn(
|
26
|
+
console.warn(`// TODO 暂未实现变量 ${name}`);
|
25
27
|
return;
|
26
28
|
}
|
27
29
|
return inst[name];
|
28
30
|
}
|
29
|
-
export
|
30
|
-
|
31
|
-
|
32
|
-
//
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
export const parseUrl = url => {
|
32
|
+
return _parseUrl(url, {
|
33
|
+
arrayFormat: 'bracket',
|
34
|
+
// WARN: 这里的参数与微信不一致, 但是无法进行修改了, 存量的项目已经在使用
|
35
|
+
// 例如 url=encodeURIComponent('https://www.baidu.com?name=1&age=2') 在微信中不会进行 decode
|
36
|
+
// 而在涂鸦小程序上会进行 decode, 这里是需要注意的地方
|
37
|
+
decode: true
|
38
|
+
});
|
39
|
+
};
|
40
|
+
export const stringifyUrl = object => {
|
41
|
+
return _stringifyUrl(object, {
|
42
|
+
arrayFormat: 'bracket',
|
43
|
+
encode: true
|
44
|
+
});
|
45
|
+
};
|
package/lib/utils.wechat.js
CHANGED
@@ -5,7 +5,7 @@ export function factory(name) {
|
|
5
5
|
if (/(set|get|remove|clear)+Storage(Sync)?$/.test(name)) {
|
6
6
|
return function (option) {
|
7
7
|
if (opts.deprecated) {
|
8
|
-
console.warn(
|
8
|
+
console.warn(`该方法 ${name} 已弃用`);
|
9
9
|
}
|
10
10
|
// eslint-disable-next-line prefer-rest-params
|
11
11
|
return wx[name].call(this, option.key, option.data);
|
@@ -13,10 +13,10 @@ export function factory(name) {
|
|
13
13
|
}
|
14
14
|
return function () {
|
15
15
|
if (opts.deprecated) {
|
16
|
-
console.warn(
|
16
|
+
console.warn(`该方法 ${name} 已弃用`);
|
17
17
|
}
|
18
18
|
if (!tyWx[name] && !wx[name]) {
|
19
|
-
console.warn(
|
19
|
+
console.warn(`// TODO 暂未实现方法 wx.${name}`);
|
20
20
|
return;
|
21
21
|
}
|
22
22
|
// 优先取得 TTT 能力的方法
|
@@ -30,11 +30,11 @@ export function factory(name) {
|
|
30
30
|
export function factoryContants(name) {
|
31
31
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
32
32
|
if (opts.deprecated) {
|
33
|
-
console.warn(
|
33
|
+
console.warn(`该变量 ${name} 已弃用`);
|
34
34
|
}
|
35
35
|
const inst = typeof wx === 'undefined' ? {} : wx;
|
36
36
|
if (!inst[name]) {
|
37
|
-
console.warn(
|
37
|
+
console.warn(`// TODO 暂未实现变量 ${name}`);
|
38
38
|
return;
|
39
39
|
}
|
40
40
|
return inst[name];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/api",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.32",
|
4
4
|
"description": "Ray universal api",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -29,13 +29,14 @@
|
|
29
29
|
"watch": "ray start --type=component"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@ray-js/framework": "
|
33
|
-
"@ray-js/router": "
|
32
|
+
"@ray-js/framework": "1.4.32",
|
33
|
+
"@ray-js/router": "1.4.32",
|
34
34
|
"@ray-js/wechat": "^0.0.33",
|
35
|
-
"base64-browser": "^1.0.1"
|
35
|
+
"base64-browser": "^1.0.1",
|
36
|
+
"query-string": "^7.1.3"
|
36
37
|
},
|
37
38
|
"devDependencies": {
|
38
|
-
"@ray-js/cli": "
|
39
|
+
"@ray-js/cli": "1.4.32",
|
39
40
|
"art-template": "^4.13.2",
|
40
41
|
"fs-extra": "^10.1.0",
|
41
42
|
"miniprogram-api-typings": "^3.12.2",
|
@@ -45,5 +46,5 @@
|
|
45
46
|
"access": "public",
|
46
47
|
"registry": "https://registry.npmjs.org"
|
47
48
|
},
|
48
|
-
"gitHead": "
|
49
|
+
"gitHead": "883f1ad59b1036a84b026e280e27c71ebdbc12cd"
|
49
50
|
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
type OpenSceneCreateParams = {
|
2
|
-
devId?: string;
|
3
|
-
success?: () => void;
|
4
|
-
fail?: (err?: {
|
5
|
-
errorMsg: string;
|
6
|
-
errorCode: string | number;
|
7
|
-
innerError: {
|
8
|
-
errorCode: string | number;
|
9
|
-
errorMsg: string;
|
10
|
-
};
|
11
|
-
}) => void;
|
12
|
-
complete?: () => void;
|
13
|
-
} & {
|
14
|
-
[key: string]: string | boolean | number;
|
15
|
-
};
|
16
|
-
export declare function openSceneCreate(params: OpenSceneCreateParams): Promise<void>;
|
17
|
-
type OpenSceneEdit = {
|
18
|
-
devId?: string;
|
19
|
-
sceneId?: string;
|
20
|
-
success?: () => void;
|
21
|
-
fail?: (err?: {
|
22
|
-
errorMsg: string;
|
23
|
-
errorCode: string | number;
|
24
|
-
innerError: {
|
25
|
-
errorCode: string | number;
|
26
|
-
errorMsg: string;
|
27
|
-
};
|
28
|
-
}) => void;
|
29
|
-
complete?: () => void;
|
30
|
-
} & {
|
31
|
-
[key: string]: string | boolean | number;
|
32
|
-
};
|
33
|
-
export declare function openSceneEdit(params: OpenSceneEdit): Promise<void>;
|
34
|
-
export {};
|
@@ -1,60 +0,0 @@
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2
|
-
const _excluded = ["success", "fail", "complete"],
|
3
|
-
_excluded2 = ["success", "fail", "complete"];
|
4
|
-
import { objectToUrlParams } from '../utils';
|
5
|
-
export function openSceneCreate(params) {
|
6
|
-
const {
|
7
|
-
success,
|
8
|
-
fail,
|
9
|
-
complete
|
10
|
-
} = params,
|
11
|
-
rest = _objectWithoutProperties(params, _excluded);
|
12
|
-
let paramsStr = '';
|
13
|
-
if (Object.keys(rest).length > 0) {
|
14
|
-
paramsStr = '?' + objectToUrlParams(rest);
|
15
|
-
}
|
16
|
-
return new Promise((resolve, reject) => {
|
17
|
-
ty.router({
|
18
|
-
url: 'tuyaSmart://createScene' + paramsStr,
|
19
|
-
success() {
|
20
|
-
success === null || success === void 0 ? void 0 : success();
|
21
|
-
resolve();
|
22
|
-
},
|
23
|
-
fail(err) {
|
24
|
-
fail === null || fail === void 0 ? void 0 : fail(err);
|
25
|
-
reject(err);
|
26
|
-
},
|
27
|
-
complete() {
|
28
|
-
complete === null || complete === void 0 ? void 0 : complete();
|
29
|
-
}
|
30
|
-
});
|
31
|
-
});
|
32
|
-
}
|
33
|
-
export function openSceneEdit(params) {
|
34
|
-
const {
|
35
|
-
success,
|
36
|
-
fail,
|
37
|
-
complete
|
38
|
-
} = params,
|
39
|
-
rest = _objectWithoutProperties(params, _excluded2);
|
40
|
-
let paramsStr = '';
|
41
|
-
if (Object.keys(rest).length > 0) {
|
42
|
-
paramsStr = '?' + objectToUrlParams(rest);
|
43
|
-
}
|
44
|
-
return new Promise((resolve, reject) => {
|
45
|
-
ty.router({
|
46
|
-
url: 'tuyaSmart://editScene' + paramsStr,
|
47
|
-
success() {
|
48
|
-
success === null || success === void 0 ? void 0 : success();
|
49
|
-
resolve();
|
50
|
-
},
|
51
|
-
fail(err) {
|
52
|
-
fail === null || fail === void 0 ? void 0 : fail(err);
|
53
|
-
reject(err);
|
54
|
-
},
|
55
|
-
complete() {
|
56
|
-
complete === null || complete === void 0 ? void 0 : complete();
|
57
|
-
}
|
58
|
-
});
|
59
|
-
});
|
60
|
-
}
|