@ray-js/t-agent-ui-ray 0.1.0-beta-3 → 0.1.0-beta-5
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/dist/ChatContainer/index.js +1 -2
- package/dist/MessageInput/index.js +2 -4
- package/dist/contexts.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/useLongPress.js +40 -23
- package/dist/hooks/useTranslate.d.ts +2 -0
- package/dist/hooks/useTranslate.js +62 -0
- package/dist/i18n/strings.d.ts +499 -0
- package/dist/i18n/strings.js +498 -0
- package/dist/tiles/BubbleTile/index.js +2 -5
- package/dist/tiles/DividerTile/index.d.ts +8 -0
- package/dist/tiles/DividerTile/index.js +16 -0
- package/dist/tiles/DividerTile/index.less +26 -0
- package/dist/tiles/ExecuteCardTile/bookmark.png +0 -0
- package/dist/tiles/ExecuteCardTile/index.d.ts +10 -0
- package/dist/tiles/ExecuteCardTile/index.js +231 -0
- package/dist/tiles/ExecuteCardTile/index.less +154 -0
- package/dist/tiles/OperateCardTile/Expand.d.ts +17 -0
- package/dist/tiles/OperateCardTile/Expand.js +167 -0
- package/dist/tiles/OperateCardTile/Expand.less +135 -0
- package/dist/tiles/OperateCardTile/Tabs.d.ts +16 -0
- package/dist/tiles/OperateCardTile/Tabs.js +39 -0
- package/dist/tiles/OperateCardTile/Tabs.less +72 -0
- package/dist/tiles/OperateCardTile/index.d.ts +21 -0
- package/dist/tiles/OperateCardTile/index.js +226 -0
- package/dist/tiles/OperateCardTile/index.less +18 -0
- package/dist/tiles/OperateCardTile/lock.png +0 -0
- package/dist/tiles/map.js +7 -1
- package/dist/utils/formatMessage.d.ts +11 -0
- package/dist/utils/formatMessage.js +28 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +13 -0
- package/package.json +2 -2
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
4
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
5
|
+
import { Image, Switch, Text, View } from '@ray-js/components';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
import { SceneType } from '@ray-js/t-agent-plugin-assistant';
|
|
8
|
+
import './index.less';
|
|
9
|
+
import { triggerRule } from '@ray-js/ray';
|
|
10
|
+
import { routeScene } from '../../utils';
|
|
11
|
+
import lockPng from '../OperateCardTile/lock.png';
|
|
12
|
+
import bookmark from './bookmark.png';
|
|
13
|
+
import { useTranslate } from '../../hooks';
|
|
14
|
+
export default function ExecuteCardTile(props) {
|
|
15
|
+
const {
|
|
16
|
+
tile
|
|
17
|
+
} = props;
|
|
18
|
+
const {
|
|
19
|
+
deviceInfo,
|
|
20
|
+
sceneInfo,
|
|
21
|
+
deviceShareInfo
|
|
22
|
+
} = tile.data || {};
|
|
23
|
+
const t = useTranslate();
|
|
24
|
+
const {
|
|
25
|
+
cards
|
|
26
|
+
} = useMemo(() => {
|
|
27
|
+
const cards = [];
|
|
28
|
+
if (deviceInfo !== null && deviceInfo !== void 0 && deviceInfo.length) {
|
|
29
|
+
deviceInfo.forEach(i => {
|
|
30
|
+
const {
|
|
31
|
+
intent
|
|
32
|
+
} = i;
|
|
33
|
+
switch (intent) {
|
|
34
|
+
case 'controlDevice':
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
cards.push(_objectSpread(_objectSpread({}, i), {}, {
|
|
38
|
+
displayType: 'device'
|
|
39
|
+
}));
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (sceneInfo !== null && sceneInfo !== void 0 && sceneInfo.length) {
|
|
45
|
+
sceneInfo.forEach(i => {
|
|
46
|
+
if (i.valid == null) {
|
|
47
|
+
i.valid = true;
|
|
48
|
+
}
|
|
49
|
+
const {
|
|
50
|
+
intent,
|
|
51
|
+
type
|
|
52
|
+
} = i;
|
|
53
|
+
const displayType = type === SceneType.EXECUTE ? 'execute' : 'scene';
|
|
54
|
+
switch (intent) {
|
|
55
|
+
case 'queryScene':
|
|
56
|
+
case 'updateScene':
|
|
57
|
+
cards.push(_objectSpread(_objectSpread({}, i), {}, {
|
|
58
|
+
displayType
|
|
59
|
+
}));
|
|
60
|
+
break;
|
|
61
|
+
case 'deleteScene':
|
|
62
|
+
if (!i.success) {
|
|
63
|
+
cards.push(_objectSpread(_objectSpread({}, i), {}, {
|
|
64
|
+
displayType
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (deviceShareInfo !== null && deviceShareInfo !== void 0 && deviceShareInfo.length) {
|
|
74
|
+
deviceShareInfo.forEach(i => {
|
|
75
|
+
cards.push(_objectSpread(_objectSpread({}, i), {}, {
|
|
76
|
+
displayType: 'device'
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
cards
|
|
82
|
+
};
|
|
83
|
+
}, [deviceInfo, sceneInfo]);
|
|
84
|
+
if (!cards.length) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const handleTap = card => {
|
|
88
|
+
const {
|
|
89
|
+
deviceId,
|
|
90
|
+
intent
|
|
91
|
+
} = card;
|
|
92
|
+
if (intent === 'shareDevice') {
|
|
93
|
+
ty.router({
|
|
94
|
+
url: "tuyaSmart://thing_single_device_share?devId=".concat(deviceId),
|
|
95
|
+
fail(err) {
|
|
96
|
+
console.error('router thing_single_device_share fail', err);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
ty.openPanel({
|
|
102
|
+
deviceId,
|
|
103
|
+
fail() {
|
|
104
|
+
ty.showToast({
|
|
105
|
+
title: t('t-agent.execute-card-tile.execution.failed'),
|
|
106
|
+
icon: 'error'
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const changeScene = (e, card) => {
|
|
112
|
+
const {
|
|
113
|
+
sceneId
|
|
114
|
+
} = card;
|
|
115
|
+
};
|
|
116
|
+
const deleteScene = (e, card) => {
|
|
117
|
+
var _e$origin;
|
|
118
|
+
e === null || e === void 0 || (_e$origin = e.origin) === null || _e$origin === void 0 || _e$origin.stopPropagation();
|
|
119
|
+
const {
|
|
120
|
+
sceneId
|
|
121
|
+
} = card;
|
|
122
|
+
ty.router({
|
|
123
|
+
url: "tuyaSmart://editScene?sceneId=".concat(sceneId, "&biz_type=ai_smart&action=delete"),
|
|
124
|
+
fail: console.error
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
const enterScene = card => {
|
|
128
|
+
const {
|
|
129
|
+
sceneId,
|
|
130
|
+
valid
|
|
131
|
+
} = card;
|
|
132
|
+
if (!valid) {
|
|
133
|
+
ty.showToast({
|
|
134
|
+
title: t('t-agent.execute-card-tile.scene.invalid'),
|
|
135
|
+
image: '/assets/images/notice.png'
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
routeScene(sceneId);
|
|
140
|
+
};
|
|
141
|
+
const execute = (e, card) => {
|
|
142
|
+
var _e$origin2;
|
|
143
|
+
e === null || e === void 0 || (_e$origin2 = e.origin) === null || _e$origin2 === void 0 || _e$origin2.stopPropagation();
|
|
144
|
+
const {
|
|
145
|
+
sceneId
|
|
146
|
+
} = card;
|
|
147
|
+
triggerRule({
|
|
148
|
+
ruleId: sceneId
|
|
149
|
+
}).then(() => {
|
|
150
|
+
ty.showToast({
|
|
151
|
+
title: t('t-agent.execute-card-tile.execution.success'),
|
|
152
|
+
icon: 'success'
|
|
153
|
+
});
|
|
154
|
+
}).catch(() => {
|
|
155
|
+
ty.showToast({
|
|
156
|
+
title: t('t-agent.execute-card-tile.execution.failed'),
|
|
157
|
+
icon: 'error'
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
162
|
+
className: "t-agent-execute-card-tile"
|
|
163
|
+
}, cards.map(card => {
|
|
164
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
165
|
+
className: "t-agent-execute-card-tile-card"
|
|
166
|
+
}, card.displayType === 'device' && /*#__PURE__*/React.createElement(View, {
|
|
167
|
+
className: "t-agent-execute-card-tile-device",
|
|
168
|
+
onClick: () => handleTap(card)
|
|
169
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
170
|
+
src: card.icon,
|
|
171
|
+
mode: "widthFix",
|
|
172
|
+
className: "t-agent-execute-card-tile-device-icon"
|
|
173
|
+
}), /*#__PURE__*/React.createElement(View, null, card.name)), card.displayType === 'energy' && /*#__PURE__*/React.createElement(View, {
|
|
174
|
+
className: "t-agent-execute-card-tile-energy",
|
|
175
|
+
onClick: () => handleTap(card)
|
|
176
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
177
|
+
src: card.icon,
|
|
178
|
+
mode: "widthFix",
|
|
179
|
+
className: "t-agent-execute-card-tile-energy-icon"
|
|
180
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
181
|
+
className: "t-agent-execute-card-tile-energy-content"
|
|
182
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
183
|
+
className: "t-agent-execute-card-tile-energy-content-title"
|
|
184
|
+
}, card.name), /*#__PURE__*/React.createElement(View, {
|
|
185
|
+
className: "t-agent-execute-card-tile-energy-content-desc"
|
|
186
|
+
}, card.desc))), card.displayType === 'scene' && /*#__PURE__*/React.createElement(View, {
|
|
187
|
+
className: "t-agent-execute-card-tile-scene",
|
|
188
|
+
onClick: () => enterScene(card)
|
|
189
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
190
|
+
className: "t-agent-execute-card-tile-scene-icon-wrapper",
|
|
191
|
+
style: {
|
|
192
|
+
backgroundColor: "#".concat(card.displayColor)
|
|
193
|
+
}
|
|
194
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
195
|
+
src: card.icon || bookmark,
|
|
196
|
+
mode: "widthFix",
|
|
197
|
+
className: "t-agent-execute-card-tile-scene-icon"
|
|
198
|
+
})), /*#__PURE__*/React.createElement(View, {
|
|
199
|
+
className: "t-agent-execute-card-tile-scene-name"
|
|
200
|
+
}, card.name, card.room && /*#__PURE__*/React.createElement(Text, null, "-", card.room)), card.valid && card.intent !== 'deleteScene' ? /*#__PURE__*/React.createElement(View, {
|
|
201
|
+
onClick: e => {
|
|
202
|
+
var _e$origin3;
|
|
203
|
+
return e === null || e === void 0 || (_e$origin3 = e.origin) === null || _e$origin3 === void 0 ? void 0 : _e$origin3.stopPropagation();
|
|
204
|
+
}
|
|
205
|
+
}, /*#__PURE__*/React.createElement(Switch, {
|
|
206
|
+
checked: card.enabled,
|
|
207
|
+
onChange: e => changeScene(e, card)
|
|
208
|
+
})) : /*#__PURE__*/React.createElement(View, {
|
|
209
|
+
className: "t-agent-execute-card-tile-scene-delete",
|
|
210
|
+
onClick: e => deleteScene(e, card)
|
|
211
|
+
}, t('t-agent.execute-card-tile.delete'))), card.displayType === 'execute' && /*#__PURE__*/React.createElement(View, {
|
|
212
|
+
className: "t-agent-execute-card-tile-execute ".concat(!card.valid ? 't-agent-execute-card-tile-execute-disabled' : ''),
|
|
213
|
+
style: {
|
|
214
|
+
backgroundColor: "#".concat(card.displayColor)
|
|
215
|
+
},
|
|
216
|
+
onClick: () => enterScene(card)
|
|
217
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
218
|
+
src: card.icon || lockPng,
|
|
219
|
+
mode: "widthFix",
|
|
220
|
+
className: "t-agent-execute-card-tile-execute-icon"
|
|
221
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
222
|
+
className: "t-agent-execute-card-tile-execute-name"
|
|
223
|
+
}, card.name, card.room && /*#__PURE__*/React.createElement(Text, null, "-", card.room)), /*#__PURE__*/React.createElement(View, {
|
|
224
|
+
className: "t-agent-execute-card-tile-execute-button",
|
|
225
|
+
onClick: e => execute(e, card),
|
|
226
|
+
style: {
|
|
227
|
+
color: "#".concat(card.displayColor)
|
|
228
|
+
}
|
|
229
|
+
}, t('t-agent.execute-card-tile.execute'))));
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
.t-agent-execute-card-tile {
|
|
2
|
+
.t-agent-execute-card-tile-card {
|
|
3
|
+
.t-agent-execute-card-tile-device {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
min-height: 44px;
|
|
7
|
+
background-color: var(--app-B1);
|
|
8
|
+
padding: 12px;
|
|
9
|
+
border-radius: var(--app-C1_1);
|
|
10
|
+
margin-top: 8px;
|
|
11
|
+
|
|
12
|
+
.t-agent-execute-card-tile-device-icon {
|
|
13
|
+
width: 40px;
|
|
14
|
+
height: 40px;
|
|
15
|
+
margin-right: 10px;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.t-agent-execute-card-tile-energy {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
min-height: 44px;
|
|
23
|
+
background-color: var(--app-B1);
|
|
24
|
+
padding: 12px;
|
|
25
|
+
border-radius: var(--app-C1_1);
|
|
26
|
+
margin-top: 8px;
|
|
27
|
+
|
|
28
|
+
.t-agent-execute-card-tile-energy-icon {
|
|
29
|
+
width: 32px;
|
|
30
|
+
height: 32px;
|
|
31
|
+
border-radius: 4px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.t-agent-execute-card-tile-energy-content {
|
|
35
|
+
margin-left: 8px;
|
|
36
|
+
flex: 1;
|
|
37
|
+
.t-agent-execute-card-tile-energy-content-title {
|
|
38
|
+
font-size: 16px;
|
|
39
|
+
color: var(--app-C1);
|
|
40
|
+
line-height: 22px;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
text-overflow: ellipsis;
|
|
43
|
+
display: -webkit-box;
|
|
44
|
+
-webkit-line-clamp: 2;
|
|
45
|
+
-webkit-box-orient: vertical;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.t-agent-execute-card-tile-energy-content-desc {
|
|
49
|
+
font-size: 13px;
|
|
50
|
+
color: var(--app-B1-N3);
|
|
51
|
+
line-height: 18px;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
text-overflow: ellipsis;
|
|
54
|
+
display: -webkit-box;
|
|
55
|
+
-webkit-line-clamp: 2;
|
|
56
|
+
-webkit-box-orient: vertical;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.t-agent-execute-card-tile-scene {
|
|
62
|
+
min-height: 44px;
|
|
63
|
+
background-color: var(--app-B1);
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
padding: 12px;
|
|
67
|
+
border-radius: var(--app-C1_1);
|
|
68
|
+
margin-top: 8px;
|
|
69
|
+
|
|
70
|
+
.t-agent-execute-card-tile-scene-icon-wrapper {
|
|
71
|
+
display: flex;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
align-items: center;
|
|
74
|
+
width: 32px;
|
|
75
|
+
height: 32px;
|
|
76
|
+
border-radius: 10px;
|
|
77
|
+
margin-right: 8px;
|
|
78
|
+
.t-agent-execute-card-tile-scene-icon {
|
|
79
|
+
width: 20px;
|
|
80
|
+
height: 20px;
|
|
81
|
+
filter: brightness(100);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.t-agent-execute-card-tile-scene-name {
|
|
86
|
+
flex: 1;
|
|
87
|
+
font-size: 16px;
|
|
88
|
+
line-height: 22px;
|
|
89
|
+
color: var(--app-C1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.t-agent-execute-card-tile-scene-switch {
|
|
93
|
+
margin-left: auto;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.t-agent-execute-card-tile-scene-delete {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
height: 24px;
|
|
100
|
+
padding-right: 12px;
|
|
101
|
+
padding-left: 12px;
|
|
102
|
+
color: var(--app-M2);
|
|
103
|
+
background: #fff;
|
|
104
|
+
border-radius: var(--app-C1_1);
|
|
105
|
+
font-size: 12px;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.t-agent-execute-card-tile-execute {
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
min-height: 44px;
|
|
113
|
+
background-color: #e36468;
|
|
114
|
+
padding: 12px;
|
|
115
|
+
border-radius: var(--app-C1_1);
|
|
116
|
+
margin-top: 8px;
|
|
117
|
+
|
|
118
|
+
&.t-agent-execute-card-tile-execute-disabled {
|
|
119
|
+
opacity: 0.3;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.t-agent-execute-card-tile-execute-icon {
|
|
123
|
+
width: 40px;
|
|
124
|
+
height: 40px;
|
|
125
|
+
margin-right: 10px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.t-agent-execute-card-tile-execute-name {
|
|
129
|
+
font-size: 16px;
|
|
130
|
+
line-height: 22px;
|
|
131
|
+
color: #ffffff;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
text-overflow: ellipsis;
|
|
134
|
+
display: -webkit-box;
|
|
135
|
+
-webkit-line-clamp: 2;
|
|
136
|
+
-webkit-box-orient: vertical;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.t-agent-execute-card-tile-execute-button {
|
|
140
|
+
margin-left: auto;
|
|
141
|
+
line-height: 18px;
|
|
142
|
+
padding: 3px 12px;
|
|
143
|
+
font-size: 12px;
|
|
144
|
+
font-weight: 600;
|
|
145
|
+
color: #e36468;
|
|
146
|
+
background-color: #ffffff;
|
|
147
|
+
display: flex;
|
|
148
|
+
justify-content: center;
|
|
149
|
+
align-items: center;
|
|
150
|
+
border-radius: 18px;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DeviceInfoItem, SceneInfoItem, ChangeInfoItem } from '@ray-js/t-agent-plugin-assistant';
|
|
3
|
+
import './Expand.less';
|
|
4
|
+
export interface IOperations {
|
|
5
|
+
device: DeviceInfoItem[];
|
|
6
|
+
scene: SceneInfoItem[];
|
|
7
|
+
moreDevice: ChangeInfoItem[];
|
|
8
|
+
moreScene: ChangeInfoItem[];
|
|
9
|
+
more: ChangeInfoItem[];
|
|
10
|
+
}
|
|
11
|
+
interface ExpandProps {
|
|
12
|
+
operations?: IOperations;
|
|
13
|
+
tapDevice?: (e: any) => void;
|
|
14
|
+
tapScene?: (e: any) => void;
|
|
15
|
+
}
|
|
16
|
+
export default function Expand({ operations, tapDevice, tapScene, }: ExpandProps): React.JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
3
|
+
import { View, Text, Image } from '@ray-js/components';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { SceneType } from '@ray-js/t-agent-plugin-assistant';
|
|
6
|
+
import Tabs from './Tabs';
|
|
7
|
+
import './Expand.less';
|
|
8
|
+
import bookmark from '../ExecuteCardTile/bookmark.png';
|
|
9
|
+
import lockPng from './lock.png';
|
|
10
|
+
import { useTranslate } from '../../hooks';
|
|
11
|
+
import { formatMessage } from '../../utils';
|
|
12
|
+
export default function Expand(_ref) {
|
|
13
|
+
var _operations$device, _operations$moreDevic, _operations$scene, _operations$moreScene, _operations$more;
|
|
14
|
+
let {
|
|
15
|
+
operations = {
|
|
16
|
+
device: [],
|
|
17
|
+
scene: [],
|
|
18
|
+
moreDevice: [],
|
|
19
|
+
moreScene: [],
|
|
20
|
+
more: []
|
|
21
|
+
},
|
|
22
|
+
tapDevice,
|
|
23
|
+
tapScene
|
|
24
|
+
} = _ref;
|
|
25
|
+
const t = useTranslate();
|
|
26
|
+
const deviceCount = (((_operations$device = operations.device) === null || _operations$device === void 0 ? void 0 : _operations$device.length) || 0) + (((_operations$moreDevic = operations.moreDevice) === null || _operations$moreDevic === void 0 ? void 0 : _operations$moreDevic.length) || 0);
|
|
27
|
+
const sceneCount = (((_operations$scene = operations.scene) === null || _operations$scene === void 0 ? void 0 : _operations$scene.length) || 0) + (((_operations$moreScene = operations.moreScene) === null || _operations$moreScene === void 0 ? void 0 : _operations$moreScene.length) || 0);
|
|
28
|
+
const moreCount = ((_operations$more = operations.more) === null || _operations$more === void 0 ? void 0 : _operations$more.length) || 0;
|
|
29
|
+
const tabs = [];
|
|
30
|
+
if (deviceCount > 0) {
|
|
31
|
+
var _operations$device2, _operations$moreDevic2;
|
|
32
|
+
tabs.push({
|
|
33
|
+
key: 'device',
|
|
34
|
+
title: t('t-agent.expand.tab.device'),
|
|
35
|
+
badge: deviceCount,
|
|
36
|
+
content: /*#__PURE__*/React.createElement(View, {
|
|
37
|
+
className: "t-agent-expand-device-list"
|
|
38
|
+
}, (_operations$device2 = operations.device) === null || _operations$device2 === void 0 ? void 0 : _operations$device2.map(device => {
|
|
39
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
40
|
+
key: device.deviceId,
|
|
41
|
+
className: "t-agent-expand-device-item",
|
|
42
|
+
onClick: () => tapDevice === null || tapDevice === void 0 ? void 0 : tapDevice({
|
|
43
|
+
currentTarget: {
|
|
44
|
+
dataset: {
|
|
45
|
+
id: device.deviceId
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
50
|
+
src: device.icon,
|
|
51
|
+
className: "t-agent-expand-device-icon"
|
|
52
|
+
}), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
|
|
53
|
+
className: "t-agent-expand-device-info"
|
|
54
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
55
|
+
className: "t-agent-expand-device-name"
|
|
56
|
+
}, device.name), device.room && /*#__PURE__*/React.createElement(Text, {
|
|
57
|
+
className: "t-agent-expand-device-room"
|
|
58
|
+
}, "-", device.room)), /*#__PURE__*/React.createElement(Text, {
|
|
59
|
+
className: "t-agent-expand-device-status"
|
|
60
|
+
}, device.success ? t('t-agent.expand.execution.success') : t('t-agent.expand.execution.failed'))));
|
|
61
|
+
}), (_operations$moreDevic2 = operations.moreDevice) === null || _operations$moreDevic2 === void 0 ? void 0 : _operations$moreDevic2.map(device => /*#__PURE__*/React.createElement(View, {
|
|
62
|
+
key: device.id,
|
|
63
|
+
className: "t-agent-expand-device-item",
|
|
64
|
+
onClick: () => tapDevice === null || tapDevice === void 0 ? void 0 : tapDevice({
|
|
65
|
+
currentTarget: {
|
|
66
|
+
dataset: {
|
|
67
|
+
id: device.id
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
72
|
+
src: bookmark,
|
|
73
|
+
className: "t-agent-expand-device-icon"
|
|
74
|
+
}), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
|
|
75
|
+
className: "t-agent-expand-device-info"
|
|
76
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
77
|
+
className: "t-agent-expand-device-name"
|
|
78
|
+
}, formatMessage(t, 't-agent.expand.device.rename', {
|
|
79
|
+
oldName: device.fromData,
|
|
80
|
+
newName: device.toData
|
|
81
|
+
}))), /*#__PURE__*/React.createElement(Text, {
|
|
82
|
+
className: "t-agent-expand-device-status"
|
|
83
|
+
}, device.success ? t('t-agent.expand.execution.success') : t('t-agent.expand.execution.failed'))))))
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (sceneCount > 0) {
|
|
87
|
+
var _operations$scene2, _operations$moreScene2;
|
|
88
|
+
tabs.push({
|
|
89
|
+
key: 'scene',
|
|
90
|
+
title: t('t-agent.expand.tab.scene'),
|
|
91
|
+
badge: sceneCount,
|
|
92
|
+
content: /*#__PURE__*/React.createElement(View, {
|
|
93
|
+
className: "t-agent-expand-scene-list"
|
|
94
|
+
}, (_operations$scene2 = operations.scene) === null || _operations$scene2 === void 0 ? void 0 : _operations$scene2.map(scene => {
|
|
95
|
+
const isExecuteScene = scene.type === SceneType.EXECUTE;
|
|
96
|
+
const icon = isExecuteScene ? lockPng : bookmark;
|
|
97
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
98
|
+
key: scene.sceneId,
|
|
99
|
+
className: "t-agent-expand-scene-item",
|
|
100
|
+
onClick: () => tapScene === null || tapScene === void 0 ? void 0 : tapScene({
|
|
101
|
+
currentTarget: {
|
|
102
|
+
dataset: {
|
|
103
|
+
id: scene.sceneId
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
108
|
+
src: scene.icon || icon,
|
|
109
|
+
className: "t-agent-expand-scene-icon"
|
|
110
|
+
}), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
|
|
111
|
+
className: "t-agent-expand-scene-name"
|
|
112
|
+
}, isExecuteScene ? t('t-agent.expand.scene.one-click') : t('t-agent.expand.scene.auto'), ' ', scene.name), /*#__PURE__*/React.createElement(Text, {
|
|
113
|
+
className: "t-agent-expand-scene-status"
|
|
114
|
+
}, scene.success ? t('t-agent.expand.execution.success') : t('t-agent.expand.execution.failed'))));
|
|
115
|
+
}), (_operations$moreScene2 = operations.moreScene) === null || _operations$moreScene2 === void 0 ? void 0 : _operations$moreScene2.map(scene => /*#__PURE__*/React.createElement(View, {
|
|
116
|
+
key: scene.id,
|
|
117
|
+
className: "t-agent-expand-scene-item",
|
|
118
|
+
onClick: () => tapScene === null || tapScene === void 0 ? void 0 : tapScene({
|
|
119
|
+
currentTarget: {
|
|
120
|
+
dataset: {
|
|
121
|
+
id: scene.id
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
126
|
+
src: bookmark,
|
|
127
|
+
className: "t-agent-expand-scene-icon"
|
|
128
|
+
}), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
|
|
129
|
+
className: "t-agent-expand-scene-name"
|
|
130
|
+
}, formatMessage(t, 't-agent.expand.scene.rename', {
|
|
131
|
+
oldName: scene.fromData,
|
|
132
|
+
newName: scene.toData
|
|
133
|
+
})), /*#__PURE__*/React.createElement(Text, {
|
|
134
|
+
className: "t-agent-expand-scene-status"
|
|
135
|
+
}, scene.success ? t('t-agent.expand.execution.success') : t('t-agent.expand.execution.failed'))))))
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (moreCount > 0) {
|
|
139
|
+
var _operations$more2;
|
|
140
|
+
tabs.push({
|
|
141
|
+
key: 'more',
|
|
142
|
+
title: t('t-agent.expand.tab.more'),
|
|
143
|
+
badge: moreCount,
|
|
144
|
+
content: /*#__PURE__*/React.createElement(View, {
|
|
145
|
+
className: "t-agent-expand-more-list"
|
|
146
|
+
}, (_operations$more2 = operations.more) === null || _operations$more2 === void 0 ? void 0 : _operations$more2.map(item => /*#__PURE__*/React.createElement(View, {
|
|
147
|
+
key: item.id,
|
|
148
|
+
className: "t-agent-expand-more-item"
|
|
149
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
150
|
+
src: bookmark,
|
|
151
|
+
className: "t-agent-expand-more-icon"
|
|
152
|
+
}), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
|
|
153
|
+
className: "t-agent-expand-more-name"
|
|
154
|
+
}, item.desc), /*#__PURE__*/React.createElement(Text, {
|
|
155
|
+
className: "t-agent-expand-more-status"
|
|
156
|
+
}, item.success ? t('t-agent.expand.execution.success') : t('t-agent.expand.execution.failed'))))))
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
160
|
+
className: "t-agent-expand-container"
|
|
161
|
+
}, tabs.length > 0 ? /*#__PURE__*/React.createElement(Tabs, {
|
|
162
|
+
tabs: tabs,
|
|
163
|
+
defaultActiveKey: tabs[0].key
|
|
164
|
+
}) : /*#__PURE__*/React.createElement(View, {
|
|
165
|
+
className: "t-agent-expand-empty"
|
|
166
|
+
}, /*#__PURE__*/React.createElement(Text, null, t('t-agent.expand.no.details'))));
|
|
167
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
.t-agent-expand {
|
|
2
|
+
&-container {
|
|
3
|
+
padding: 16px;
|
|
4
|
+
background-color: #fff;
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
7
|
+
margin-top: 12px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&-empty {
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
min-height: 100px;
|
|
15
|
+
color: #999;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-device {
|
|
19
|
+
&-list {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
gap: 12px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-item {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
padding: 12px;
|
|
29
|
+
background-color: #f5f5f5;
|
|
30
|
+
border-radius: 6px;
|
|
31
|
+
|
|
32
|
+
&:active {
|
|
33
|
+
opacity: 0.8;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&-icon {
|
|
38
|
+
width: 40px;
|
|
39
|
+
height: 40px;
|
|
40
|
+
border-radius: 12px;
|
|
41
|
+
margin-right: 5px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&-info {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&-name {
|
|
50
|
+
font-size: 14px;
|
|
51
|
+
font-weight: 500;
|
|
52
|
+
color: #333;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&-room {
|
|
56
|
+
font-size: 12px;
|
|
57
|
+
color: #666;
|
|
58
|
+
margin-left: 4px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&-status {
|
|
62
|
+
font-size: 12px;
|
|
63
|
+
color: #0089ff;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&-scene {
|
|
68
|
+
&-list {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
gap: 12px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&-item {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
padding: 12px;
|
|
78
|
+
background-color: #f5f5f5;
|
|
79
|
+
border-radius: 6px;
|
|
80
|
+
|
|
81
|
+
&:active {
|
|
82
|
+
opacity: 0.8;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&-icon {
|
|
87
|
+
width: 40px;
|
|
88
|
+
height: 40px;
|
|
89
|
+
border-radius: 12px;
|
|
90
|
+
margin-right: 5px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&-name {
|
|
94
|
+
font-size: 14px;
|
|
95
|
+
font-weight: 500;
|
|
96
|
+
color: #333;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&-status {
|
|
100
|
+
font-size: 12px;
|
|
101
|
+
color: #0089ff;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&-more {
|
|
106
|
+
&-list {
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: column;
|
|
109
|
+
gap: 12px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&-item {
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
padding: 12px;
|
|
116
|
+
background-color: #f5f5f5;
|
|
117
|
+
border-radius: 6px;
|
|
118
|
+
|
|
119
|
+
&:active {
|
|
120
|
+
opacity: 0.8;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&-name {
|
|
125
|
+
font-size: 14px;
|
|
126
|
+
font-weight: 500;
|
|
127
|
+
color: #333;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&-status {
|
|
131
|
+
font-size: 12px;
|
|
132
|
+
color: #0089ff;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|