@ray-js/t-agent-ui-ray 0.1.1 → 0.2.0-beta-1
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 +0 -10
- package/dist/MessageInput/MessageInputAIStream/AsrInput.d.ts +15 -0
- package/dist/MessageInput/MessageInputAIStream/AsrInput.js +109 -0
- package/dist/MessageInput/MessageInputAIStream/index.d.ts +10 -0
- package/dist/MessageInput/MessageInputAIStream/index.js +359 -0
- package/dist/MessageInput/{AsrInput.d.ts → MessageInputAssistant/AsrInput.d.ts} +1 -1
- package/dist/MessageInput/{AsrInput.js → MessageInputAssistant/AsrInput.js} +2 -2
- package/dist/MessageInput/MessageInputAssistant/index.d.ts +11 -0
- package/dist/MessageInput/MessageInputAssistant/index.js +322 -0
- package/dist/MessageInput/icons/keyboard.svg +1 -0
- package/dist/MessageInput/index.d.ts +0 -1
- package/dist/MessageInput/index.js +3 -320
- package/dist/MessageInput/index.less +78 -3
- package/dist/MessageList/index.d.ts +5 -0
- package/dist/MessageList/index.js +4 -2
- package/dist/MessageRender/index.d.ts +6 -1
- package/dist/MessageRender/index.js +19 -2
- package/dist/MessageRender/index.less +48 -1
- package/dist/PrivateImage/index.js +1 -1
- package/dist/cards/map.js +3 -2
- package/dist/contexts.d.ts +1 -2
- package/dist/contexts.js +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/useAttachmentInput.d.ts +3 -1
- package/dist/hooks/useAttachmentInput.js +75 -34
- package/dist/hooks/useLongPress.d.ts +1 -1
- package/dist/hooks/useLongPress.js +38 -36
- package/dist/hooks/useMultSelect.d.ts +7 -0
- package/dist/hooks/useMultSelect.js +12 -0
- package/dist/i18n/strings.d.ts +8 -0
- package/dist/i18n/strings.js +11 -0
- package/dist/renderOption.js +5 -0
- package/dist/tiles/BubbleTile/index.js +9 -10
- package/dist/tiles/CardTile/index.js +6 -7
- package/dist/tiles/ExecuteCardTile/index.d.ts +8 -1
- package/dist/tiles/ExecuteCardTile/index.js +11 -1
- package/dist/tiles/FileTile/index.d.ts +8 -0
- package/dist/tiles/FileTile/index.js +57 -0
- package/dist/tiles/FileTile/index.less +44 -0
- package/dist/tiles/ImageTile/index.js +1 -0
- package/dist/tiles/OperateCardTile/Expand.d.ts +7 -1
- package/dist/tiles/OperateCardTile/Expand.js +11 -1
- package/dist/tiles/OperateCardTile/index.d.ts +4 -1
- package/dist/tiles/OperateCardTile/index.js +2 -0
- package/dist/tiles/WorkflowTile/RollBack/index.js +11 -12
- package/dist/tiles/WorkflowTile/index.d.ts +4 -1
- package/dist/tiles/map.js +3 -1
- package/dist/types.d.ts +2 -0
- package/dist/utils/file.d.ts +24 -0
- package/dist/utils/file.js +190 -0
- package/package.json +2 -2
|
@@ -4,10 +4,15 @@ import "core-js/modules/esnext.iterator.map.js";
|
|
|
4
4
|
import "core-js/modules/esnext.iterator.some.js";
|
|
5
5
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
6
6
|
import { useCallback, useMemo, useState } from 'react';
|
|
7
|
-
import { chooseImage, chooseVideo, uploadImage, uploadVideo } from '
|
|
7
|
+
import { chooseImage, chooseVideo, uploadImage, uploadVideo } from '../utils/file';
|
|
8
8
|
import { generateId } from '@ray-js/t-agent';
|
|
9
9
|
import { useRenderOptions } from './context';
|
|
10
10
|
export function useAttachmentInput() {
|
|
11
|
+
let {
|
|
12
|
+
local
|
|
13
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
14
|
+
local: false
|
|
15
|
+
};
|
|
11
16
|
const [uploaded, setUploaded] = useState([]);
|
|
12
17
|
const uploading = useMemo(() => uploaded.some(file => file.type === 'loading'), [uploaded]);
|
|
13
18
|
const blocks = useMemo(() => {
|
|
@@ -15,26 +20,45 @@ export function useAttachmentInput() {
|
|
|
15
20
|
if (uploaded.length) {
|
|
16
21
|
for (const uploadFile of uploaded) {
|
|
17
22
|
if (uploadFile.type === 'image') {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
if (local) {
|
|
24
|
+
b.push({
|
|
25
|
+
type: 'image_path',
|
|
26
|
+
image_path: {
|
|
27
|
+
path: uploadFile.url
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
b.push({
|
|
32
|
+
type: 'image_url',
|
|
33
|
+
image_url: {
|
|
34
|
+
url: uploadFile.url
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
24
38
|
}
|
|
25
39
|
if (uploadFile.type === 'video') {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
if (local) {
|
|
41
|
+
b.push({
|
|
42
|
+
type: 'video_path',
|
|
43
|
+
video_path: {
|
|
44
|
+
path: uploadFile.url,
|
|
45
|
+
thumb_path: uploadFile.thumbUrl
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
b.push({
|
|
50
|
+
type: 'video_url',
|
|
51
|
+
video_url: {
|
|
52
|
+
url: uploadFile.url,
|
|
53
|
+
thumb_url: uploadFile.thumbUrl
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
33
57
|
}
|
|
34
58
|
}
|
|
35
59
|
}
|
|
36
60
|
return b;
|
|
37
|
-
}, [uploaded]);
|
|
61
|
+
}, [uploaded, local]);
|
|
38
62
|
const loadBlocks = useCallback((blocks, append) => {
|
|
39
63
|
const uploaded = [];
|
|
40
64
|
for (const block of blocks) {
|
|
@@ -75,18 +99,26 @@ export function useAttachmentInput() {
|
|
|
75
99
|
await Promise.all(paths.map(async path => {
|
|
76
100
|
const id = generateId();
|
|
77
101
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
if (local) {
|
|
103
|
+
setUploaded(prev => [...prev, {
|
|
104
|
+
id,
|
|
105
|
+
type: 'image',
|
|
106
|
+
url: path
|
|
107
|
+
}]);
|
|
108
|
+
} else {
|
|
109
|
+
setUploaded(prev => [...prev, {
|
|
110
|
+
id,
|
|
111
|
+
type: 'loading'
|
|
112
|
+
}]);
|
|
113
|
+
const {
|
|
114
|
+
publicUrl
|
|
115
|
+
} = await uploadImage(path, getStaticResourceBizType(path, 'image:upload'));
|
|
116
|
+
setUploaded(prev => prev.map(item => item.id === id ? {
|
|
117
|
+
id,
|
|
118
|
+
type: 'image',
|
|
119
|
+
url: publicUrl
|
|
120
|
+
} : item));
|
|
121
|
+
}
|
|
90
122
|
} catch (error) {
|
|
91
123
|
setUploaded(prev => prev.filter(item => item.id !== id));
|
|
92
124
|
throw error;
|
|
@@ -108,13 +140,22 @@ export function useAttachmentInput() {
|
|
|
108
140
|
type: 'loading'
|
|
109
141
|
}]);
|
|
110
142
|
try {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
143
|
+
if (local) {
|
|
144
|
+
setUploaded(prev => [...prev, {
|
|
145
|
+
id,
|
|
146
|
+
type: 'video',
|
|
147
|
+
url: file.tempFilePath,
|
|
148
|
+
thumbUrl: file.thumbTempFilePath
|
|
149
|
+
}]);
|
|
150
|
+
} else {
|
|
151
|
+
const [thumb, video] = await Promise.all([uploadImage(file.thumbTempFilePath, getStaticResourceBizType(file.thumbTempFilePath, 'videoThumb:upload')), uploadVideo(file.tempFilePath, getStaticResourceBizType(file.tempFilePath, 'video:upload'))]);
|
|
152
|
+
setUploaded(prev => prev.map(item => item.id === id ? {
|
|
153
|
+
id,
|
|
154
|
+
type: 'video',
|
|
155
|
+
url: video.publicUrl,
|
|
156
|
+
thumbUrl: thumb.publicUrl
|
|
157
|
+
} : item));
|
|
158
|
+
}
|
|
118
159
|
} catch (error) {
|
|
119
160
|
setUploaded(prev => prev.filter(item => item.id !== id));
|
|
120
161
|
throw error;
|
|
@@ -2,7 +2,7 @@ import { ChatMessageObject } from '@ray-js/t-agent';
|
|
|
2
2
|
/**
|
|
3
3
|
* 预定义动作类型
|
|
4
4
|
*/
|
|
5
|
-
export type ActionType = 'copy' | 'delete' | 'like' | 'unlike' | 'deleteByChannel';
|
|
5
|
+
export type ActionType = 'copy' | 'delete' | 'like' | 'unlike' | 'deleteByChannel' | 'multSelect';
|
|
6
6
|
export interface ActionMenuItem {
|
|
7
7
|
key: string;
|
|
8
8
|
label: string;
|
|
@@ -5,7 +5,7 @@ import "core-js/modules/esnext.iterator.map.js";
|
|
|
5
5
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
6
6
|
import { useState, useEffect, useCallback } from 'react';
|
|
7
7
|
import logger from '../logger';
|
|
8
|
-
import { useChatAgent } from './context';
|
|
8
|
+
import { useChatAgent, useEmitEvent } from './context';
|
|
9
9
|
import { useTranslate } from './useTranslate';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -20,7 +20,7 @@ export function useLongPress() {
|
|
|
20
20
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
21
21
|
const {
|
|
22
22
|
message,
|
|
23
|
-
actions = ['copy', 'delete'],
|
|
23
|
+
actions = ['copy', 'multSelect', 'delete'],
|
|
24
24
|
getMessageContent = () => '',
|
|
25
25
|
customActions = [],
|
|
26
26
|
disabled = false
|
|
@@ -34,6 +34,7 @@ export function useLongPress() {
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
const agent = useChatAgent();
|
|
37
|
+
const emitEvent = useEmitEvent();
|
|
37
38
|
const t = useTranslate();
|
|
38
39
|
const [screenSize, setScreenSize] = useState({
|
|
39
40
|
width: 0,
|
|
@@ -78,6 +79,15 @@ export function useLongPress() {
|
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
break;
|
|
82
|
+
case 'multSelect':
|
|
83
|
+
menuItems.push({
|
|
84
|
+
key: 'multSelect',
|
|
85
|
+
label: t('t-agent.message.action.multSelect'),
|
|
86
|
+
action: () => {
|
|
87
|
+
emitEvent('multSelect', {});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
break;
|
|
81
91
|
case 'delete':
|
|
82
92
|
if (agent && message.id) {
|
|
83
93
|
menuItems.push({
|
|
@@ -110,13 +120,11 @@ export function useLongPress() {
|
|
|
110
120
|
key: 'deleteByChannel',
|
|
111
121
|
label: t('t-agent.message.action.deleteByChannel'),
|
|
112
122
|
action: () => {
|
|
113
|
-
const channel = agent.session.get('AIAssistant.channel');
|
|
114
|
-
const {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
removeMessageByChannel(channel);
|
|
119
|
-
}
|
|
123
|
+
// const channel = agent.session.get('AIAssistant.channel');
|
|
124
|
+
// const { removeMessageByChannel } = agent.plugins.assistant;
|
|
125
|
+
// if (typeof removeMessageByChannel === 'function') {
|
|
126
|
+
// removeMessageByChannel(channel);
|
|
127
|
+
// }
|
|
120
128
|
}
|
|
121
129
|
});
|
|
122
130
|
break;
|
|
@@ -125,19 +133,14 @@ export function useLongPress() {
|
|
|
125
133
|
key: 'like',
|
|
126
134
|
label: t('t-agent.message.action.like'),
|
|
127
135
|
action: async () => {
|
|
128
|
-
const {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
ty.showToast({
|
|
137
|
-
title: t('t-agent.message.like.success'),
|
|
138
|
-
icon: 'none'
|
|
139
|
-
});
|
|
140
|
-
}
|
|
136
|
+
// const { feedback } = agent.plugins.assistant;
|
|
137
|
+
// if (typeof feedback === 'function') {
|
|
138
|
+
// await feedback({ requestId: message.id, type: 'like' });
|
|
139
|
+
// ty.showToast({
|
|
140
|
+
// title: t('t-agent.message.like.success'),
|
|
141
|
+
// icon: 'none',
|
|
142
|
+
// });
|
|
143
|
+
// }
|
|
141
144
|
}
|
|
142
145
|
});
|
|
143
146
|
break;
|
|
@@ -146,19 +149,14 @@ export function useLongPress() {
|
|
|
146
149
|
key: 'unlike',
|
|
147
150
|
label: t('t-agent.message.action.unlike'),
|
|
148
151
|
action: async () => {
|
|
149
|
-
const {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
ty.showToast({
|
|
158
|
-
title: t('t-agent.message.unlike.success'),
|
|
159
|
-
icon: 'none'
|
|
160
|
-
});
|
|
161
|
-
}
|
|
152
|
+
// const { feedback } = agent.plugins.assistant;
|
|
153
|
+
// if (typeof feedback === 'function') {
|
|
154
|
+
// await feedback({ requestId: message.id, type: 'unlike' });
|
|
155
|
+
// ty.showToast({
|
|
156
|
+
// title: t('t-agent.message.unlike.success'),
|
|
157
|
+
// icon: 'none',
|
|
158
|
+
// });
|
|
159
|
+
// }
|
|
162
160
|
}
|
|
163
161
|
});
|
|
164
162
|
break;
|
|
@@ -202,6 +200,10 @@ export function useLongPress() {
|
|
|
202
200
|
}, [screenSize, menuItems.length]);
|
|
203
201
|
const handleLongPress = useCallback(e => {
|
|
204
202
|
var _e$detail$x, _e$detail, _e$detail$y, _e$detail2;
|
|
203
|
+
// 透出长按
|
|
204
|
+
emitEvent('longPress', {
|
|
205
|
+
message
|
|
206
|
+
});
|
|
205
207
|
if (disabled || !menuItems.length || state.showActionMenu) return;
|
|
206
208
|
|
|
207
209
|
// 检查e.detail是否存在,如果不存在,使用屏幕中心点作为默认坐标
|
|
@@ -221,7 +223,7 @@ export function useLongPress() {
|
|
|
221
223
|
if (e.origin && e.origin.stopPropagation) {
|
|
222
224
|
e.origin.stopPropagation();
|
|
223
225
|
}
|
|
224
|
-
}, [disabled, menuItems.length, state.showActionMenu, screenSize, calculateMenuPosition]);
|
|
226
|
+
}, [message, emitEvent, disabled, menuItems.length, state.showActionMenu, screenSize, calculateMenuPosition]);
|
|
225
227
|
const handleCloseMenu = useCallback(() => {
|
|
226
228
|
setState(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
227
229
|
isClosing: true
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const useMultSelectMessage: () => {
|
|
3
|
+
show: boolean;
|
|
4
|
+
select: string[];
|
|
5
|
+
onSelect: import("react").Dispatch<import("react").SetStateAction<string[]>>;
|
|
6
|
+
setShow: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
export const useMultSelectMessage = () => {
|
|
4
|
+
const [select, setSelect] = useState([]);
|
|
5
|
+
const [show, setShow] = useState(false);
|
|
6
|
+
return {
|
|
7
|
+
show,
|
|
8
|
+
select,
|
|
9
|
+
onSelect: setSelect,
|
|
10
|
+
setShow
|
|
11
|
+
};
|
|
12
|
+
};
|
package/dist/i18n/strings.d.ts
CHANGED
|
@@ -17,11 +17,15 @@ declare const _default: {
|
|
|
17
17
|
't-agent.build-in.button.set_home_location': string;
|
|
18
18
|
't-agent.input.voice.require-permission': string;
|
|
19
19
|
't-agent.input.upload.failed': string;
|
|
20
|
+
't-agent.input.asr.oninput.text.top': string;
|
|
21
|
+
't-agent.input.asr.oninput.text.center': string;
|
|
22
|
+
't-agent.input.asr.ptt': string;
|
|
20
23
|
't-agent.message.feedback.success': string;
|
|
21
24
|
't-agent.message.bubble.aborted': string;
|
|
22
25
|
't-agent.message.action.copy': string;
|
|
23
26
|
't-agent.message.action.delete': string;
|
|
24
27
|
't-agent.message.action.deleteByChannel': string;
|
|
28
|
+
't-agent.message.action.multSelect': string;
|
|
25
29
|
't-agent.message.like.success': string;
|
|
26
30
|
't-agent.message.unlike.success': string;
|
|
27
31
|
't-agent.message.action.like': string;
|
|
@@ -145,11 +149,15 @@ declare const _default: {
|
|
|
145
149
|
't-agent.build-in.button.set_home_location': string;
|
|
146
150
|
't-agent.input.voice.require-permission': string;
|
|
147
151
|
't-agent.input.upload.failed': string;
|
|
152
|
+
't-agent.input.asr.oninput.text.top': string;
|
|
153
|
+
't-agent.input.asr.oninput.text.center': string;
|
|
154
|
+
't-agent.input.asr.ptt': string;
|
|
148
155
|
't-agent.message.feedback.success': string;
|
|
149
156
|
't-agent.message.bubble.aborted': string;
|
|
150
157
|
't-agent.message.action.copy': string;
|
|
151
158
|
't-agent.message.action.delete': string;
|
|
152
159
|
't-agent.message.action.deleteByChannel': string;
|
|
160
|
+
't-agent.message.action.multSelect': string;
|
|
153
161
|
't-agent.message.like.success': string;
|
|
154
162
|
't-agent.message.unlike.success': string;
|
|
155
163
|
't-agent.message.action.like': string;
|
package/dist/i18n/strings.js
CHANGED
|
@@ -17,11 +17,15 @@ export default {
|
|
|
17
17
|
't-agent.build-in.button.set_home_location': '设置家庭位置',
|
|
18
18
|
't-agent.input.voice.require-permission': '需要授权录音权限',
|
|
19
19
|
't-agent.input.upload.failed': '文件上传失败',
|
|
20
|
+
't-agent.input.asr.oninput.text.top': '我在听,请说话',
|
|
21
|
+
't-agent.input.asr.oninput.text.center': '松开发送,上划取消',
|
|
22
|
+
't-agent.input.asr.ptt': '按住说话',
|
|
20
23
|
't-agent.message.feedback.success': '反馈成功',
|
|
21
24
|
't-agent.message.bubble.aborted': '用户中断',
|
|
22
25
|
't-agent.message.action.copy': '复制消息',
|
|
23
26
|
't-agent.message.action.delete': '删除消息',
|
|
24
27
|
't-agent.message.action.deleteByChannel': '删除所有渠道消息',
|
|
28
|
+
't-agent.message.action.multSelect': '多选',
|
|
25
29
|
't-agent.message.like.success': '点赞成功',
|
|
26
30
|
't-agent.message.unlike.success': '取消点赞成功',
|
|
27
31
|
't-agent.message.action.like': '喜欢消息',
|
|
@@ -145,11 +149,18 @@ export default {
|
|
|
145
149
|
't-agent.build-in.button.set_home_location': 'Set Home Location',
|
|
146
150
|
't-agent.input.voice.require-permission': 'Recording Permission Required',
|
|
147
151
|
't-agent.input.upload.failed': 'File Upload Failed',
|
|
152
|
+
't-agent.input.asr.oninput.text.top': 'Listening, speak now',
|
|
153
|
+
// 语音激活态顶部提示
|
|
154
|
+
't-agent.input.asr.oninput.text.center': 'Release to send · Swipe up to cancel',
|
|
155
|
+
// 交互操作指引
|
|
156
|
+
't-agent.input.asr.ptt': 'Press & hold to talk',
|
|
157
|
+
// Push-to-Talk 按钮提示
|
|
148
158
|
't-agent.message.feedback.success': 'Feedback Successful',
|
|
149
159
|
't-agent.message.bubble.aborted': 'User Aborted',
|
|
150
160
|
't-agent.message.action.copy': 'Copy Message',
|
|
151
161
|
't-agent.message.action.delete': 'Delete Message',
|
|
152
162
|
't-agent.message.action.deleteByChannel': 'Delete All Channel Messages',
|
|
163
|
+
't-agent.message.action.multSelect': 'Multiple Selection',
|
|
153
164
|
't-agent.message.like.success': 'Like Successful',
|
|
154
165
|
't-agent.message.unlike.success': 'Unlike Successful',
|
|
155
166
|
't-agent.message.action.like': 'Like Message',
|
package/dist/renderOption.js
CHANGED
|
@@ -11,6 +11,7 @@ import logger from './logger';
|
|
|
11
11
|
import LowCodeCardRender from './LowCodeCardRender';
|
|
12
12
|
import { cardMap } from './cards/map';
|
|
13
13
|
import CustomCardRender from './CustomCardRender';
|
|
14
|
+
import LongPressActionMenu from './LongPressActionMenu';
|
|
14
15
|
const defaultChatTileAs = props => {
|
|
15
16
|
const {
|
|
16
17
|
tile
|
|
@@ -66,11 +67,15 @@ const defaultRenderCardAs = card => {
|
|
|
66
67
|
}
|
|
67
68
|
return null;
|
|
68
69
|
};
|
|
70
|
+
const defaultRenderLongPressAs = res => {
|
|
71
|
+
return /*#__PURE__*/React.createElement(LongPressActionMenu, res.menuProps);
|
|
72
|
+
};
|
|
69
73
|
export const defaultRenderOptions = {
|
|
70
74
|
renderTileAs: defaultChatTileAs,
|
|
71
75
|
renderCustomBlockAs: defaultRenderCustomBlockAs,
|
|
72
76
|
customBlockTypes: defaultCustomBlockTypes,
|
|
73
77
|
renderCardAs: defaultRenderCardAs,
|
|
78
|
+
renderLongPressAs: defaultRenderLongPressAs,
|
|
74
79
|
customCardMap: {},
|
|
75
80
|
getStaticResourceBizType: () => '',
|
|
76
81
|
i18nTranslate: key => I18n.t(key)
|
|
@@ -10,16 +10,17 @@ import { View } from '@ray-js/components';
|
|
|
10
10
|
import React, { useEffect, useState, useCallback, memo } from 'react';
|
|
11
11
|
import { Image } from '@ray-js/ray';
|
|
12
12
|
import { BubbleTileStatus, ChatMessageStatus, safeParseJSON } from '@ray-js/t-agent';
|
|
13
|
-
import { getCurrentHomeInfo, submitEvaluation } from '@ray-js/t-agent-plugin-assistant';
|
|
14
13
|
import TileRender from '../../TileRender';
|
|
15
14
|
import noticeSvg from './notice.svg';
|
|
16
15
|
import noticeWarnSvg from './notice-warn.svg';
|
|
17
|
-
import { useChatAgent, useTranslate, useLongPress } from '../../hooks';
|
|
18
|
-
import LongPressActionMenu from '../../LongPressActionMenu';
|
|
16
|
+
import { useChatAgent, useTranslate, useLongPress, useRenderOptions } from '../../hooks';
|
|
19
17
|
import RollBack from '../WorkflowTile/RollBack';
|
|
20
18
|
const BubbleTile = props => {
|
|
21
19
|
var _message$meta$request, _workflowTile$data;
|
|
22
20
|
const agent = useChatAgent();
|
|
21
|
+
const {
|
|
22
|
+
renderLongPressAs
|
|
23
|
+
} = useRenderOptions();
|
|
23
24
|
const {
|
|
24
25
|
message,
|
|
25
26
|
tile,
|
|
@@ -87,20 +88,18 @@ const BubbleTile = props => {
|
|
|
87
88
|
}
|
|
88
89
|
return messageContent;
|
|
89
90
|
}, [tile]);
|
|
90
|
-
const {
|
|
91
|
-
longPressProps,
|
|
92
|
-
menuProps
|
|
93
|
-
} = useLongPress({
|
|
91
|
+
const longPressRes = useLongPress({
|
|
94
92
|
message,
|
|
95
93
|
// actions: [
|
|
96
94
|
// 'copy',
|
|
97
95
|
// 'delete',
|
|
98
96
|
// ...(isAssistantMessage ? ['like', 'unlike', 'deleteByChannel'] : []),
|
|
99
97
|
// ] as ActionType[],
|
|
100
|
-
actions: ['copy', 'delete'],
|
|
98
|
+
actions: ['copy', 'multSelect', 'delete'],
|
|
101
99
|
getMessageContent,
|
|
102
100
|
disabled: loading
|
|
103
101
|
});
|
|
102
|
+
const longPressBlock = renderLongPressAs(longPressRes);
|
|
104
103
|
const showAbortedMessage = bubbleStatus === BubbleTileStatus.ABORTED;
|
|
105
104
|
const showRollBack = side === 'start' && children.some(child => child.type === 'workflow');
|
|
106
105
|
const workflowTile = children.find(child => child.type === 'workflow');
|
|
@@ -108,7 +107,7 @@ const BubbleTile = props => {
|
|
|
108
107
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, _extends({
|
|
109
108
|
className: "t-agent-bubble-tile t-agent-bubble-tile-".concat(side),
|
|
110
109
|
"data-testid": "t-agent-bubble-tile"
|
|
111
|
-
}, longPressProps), side === 'end' && /*#__PURE__*/React.createElement(ErrorNotice, {
|
|
110
|
+
}, longPressRes.longPressProps), side === 'end' && /*#__PURE__*/React.createElement(ErrorNotice, {
|
|
112
111
|
bubbleStatus: bubbleStatus,
|
|
113
112
|
showInfo: showInfo
|
|
114
113
|
}), /*#__PURE__*/React.createElement(View, {
|
|
@@ -128,7 +127,7 @@ const BubbleTile = props => {
|
|
|
128
127
|
}, t('t-agent.message.bubble.aborted'))), side === 'start' && /*#__PURE__*/React.createElement(ErrorNotice, {
|
|
129
128
|
bubbleStatus: bubbleStatus,
|
|
130
129
|
showInfo: showInfo
|
|
131
|
-
})),
|
|
130
|
+
})), longPressBlock, showRollBack && !isLatestMessage && workflowNode && /*#__PURE__*/React.createElement(RollBack, {
|
|
132
131
|
nodeId: workflowNode
|
|
133
132
|
}));
|
|
134
133
|
};
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { View } from '@ray-js/components';
|
|
4
4
|
import './index.less';
|
|
5
5
|
import { useRenderOptions } from '../../hooks';
|
|
6
|
-
import LongPressActionMenu from '../../LongPressActionMenu';
|
|
6
|
+
// import LongPressActionMenu from '../../LongPressActionMenu';
|
|
7
7
|
import { useLongPress } from '../../hooks/useLongPress';
|
|
8
8
|
const CardTile = props => {
|
|
9
9
|
const {
|
|
@@ -13,22 +13,21 @@ const CardTile = props => {
|
|
|
13
13
|
message
|
|
14
14
|
} = props;
|
|
15
15
|
const {
|
|
16
|
-
renderCardAs
|
|
16
|
+
renderCardAs,
|
|
17
|
+
renderLongPressAs
|
|
17
18
|
} = useRenderOptions();
|
|
18
|
-
const {
|
|
19
|
-
longPressProps,
|
|
20
|
-
menuProps
|
|
21
|
-
} = useLongPress({
|
|
19
|
+
const longPressRes = useLongPress({
|
|
22
20
|
message,
|
|
23
21
|
actions: ['delete']
|
|
24
22
|
});
|
|
25
23
|
const node = renderCardAs(card);
|
|
24
|
+
const longPressBlock = renderLongPressAs(longPressRes);
|
|
26
25
|
if (!node) {
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
28
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, _extends({
|
|
30
29
|
className: "t-agent-card-tile",
|
|
31
30
|
"data-testid": "t-agent-bubble-tile"
|
|
32
|
-
}, longPressProps), node),
|
|
31
|
+
}, longPressRes.longPressProps), node), longPressBlock);
|
|
33
32
|
};
|
|
34
33
|
export default /*#__PURE__*/React.memo(CardTile);
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ChangeInfoItem, DeviceInfoItem, SceneInfoItem } from '@ray-js/t-agent-plugin-assistant';
|
|
3
2
|
import './index.less';
|
|
4
3
|
import { TileProps } from '../../types';
|
|
4
|
+
export declare enum SceneType {
|
|
5
|
+
EXECUTE = 1,
|
|
6
|
+
AUTO = 2
|
|
7
|
+
}
|
|
8
|
+
type DeviceInfoItem = any;
|
|
9
|
+
type SceneInfoItem = any;
|
|
10
|
+
type ChangeInfoItem = any;
|
|
5
11
|
export interface ExecuteCardTileData {
|
|
6
12
|
deviceInfo: DeviceInfoItem[];
|
|
7
13
|
sceneInfo: SceneInfoItem[];
|
|
8
14
|
deviceShareInfo: ChangeInfoItem[];
|
|
9
15
|
}
|
|
10
16
|
export default function ExecuteCardTile(props: TileProps<ExecuteCardTileData>): React.JSX.Element | null;
|
|
17
|
+
export {};
|
|
@@ -4,13 +4,23 @@ import "core-js/modules/esnext.iterator.for-each.js";
|
|
|
4
4
|
import "core-js/modules/esnext.iterator.map.js";
|
|
5
5
|
import { Image, Switch, Text, View } from '@ray-js/components';
|
|
6
6
|
import React, { useMemo } from 'react';
|
|
7
|
-
import {
|
|
7
|
+
// import {
|
|
8
|
+
// ChangeInfoItem,
|
|
9
|
+
// DeviceInfoItem,
|
|
10
|
+
// SceneInfoItem,
|
|
11
|
+
// SceneType,
|
|
12
|
+
// } from '@ray-js/t-agent-plugin-assistant';
|
|
8
13
|
import './index.less';
|
|
9
14
|
import { triggerRule } from '@ray-js/ray';
|
|
10
15
|
import { routeScene } from '../../utils';
|
|
11
16
|
import lockPng from '../OperateCardTile/lock.png';
|
|
12
17
|
import bookmark from './bookmark.png';
|
|
13
18
|
import { useTranslate } from '../../hooks';
|
|
19
|
+
export let SceneType = /*#__PURE__*/function (SceneType) {
|
|
20
|
+
SceneType[SceneType["EXECUTE"] = 1] = "EXECUTE";
|
|
21
|
+
SceneType[SceneType["AUTO"] = 2] = "AUTO";
|
|
22
|
+
return SceneType;
|
|
23
|
+
}({});
|
|
14
24
|
export default function ExecuteCardTile(props) {
|
|
15
25
|
const {
|
|
16
26
|
tile
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './index.less';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FileTileData } from '@ray-js/t-agent';
|
|
4
|
+
import { TileProps } from '../../types';
|
|
5
|
+
export default function FileTile(props: TileProps<FileTileData, {
|
|
6
|
+
type: '@buildIn/FileTileClick';
|
|
7
|
+
data: FileTileData;
|
|
8
|
+
}>): React.JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import './index.less';
|
|
2
|
+
import { View } from '@ray-js/components';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
const baseImg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAIHSURBVGiB7ZrbasJAEIa/HExEEFoQLJUKQguFXvf9H6CP0ItCX6B3vbA16cVkSUyN0d2JWUM+EAVz2D//zOwhG9DMBAiBHAiOHHdpciADfk89YQJMETG+EgIpELcdmABR583RI0bafJAEv11pIqQiyrgRI7G566NFjuTFdwxkxpGIM5LMQ3ZUUiXmOkOtTghMwuJH1nNjNMiAMMSvPsaVfAihViUYmqBBFIM9RkG+MzhBraPVBhbAiiMDQ0e+gY/i+yxsHVrTnRiAGfBkc6KtQ2bc9GZ5fhuvWD6wMYeOcIuEYoTE/5fitU9G06EN5Yx3rXjds9AUVJ0c9jaN1xT0iYjaIiHXC5o59EVPeVPlklUuBe66vommQ233eUaKxhwJyU7WMLpwaMN/Jx4pO8ob4AVxTB1tQRtknPdAWbrXiCtVEkTUQvn+qiFnxBiWSGfbNISJinNmSIVUQcuhFYef9injsSWSXyohqCFoBdw7XmOOiJq5NsZVkIYYQ4KIcirtroK0xBgipKBYM7jpwyioYKvaisNYvdqxFfSOxQLGGWxx6Js6GYL0RDrmkO+MgnxnkILy1qOuiMG9Y40ow+7andpLn2lfrVAkhXKFMyg+1+qS2dqzt99iEJuX6iRcbq1Og4iamPqi+o5izwxioa8haDYAAvxU/zhWss2mJp/KutkumlETYvgDMKQ0sd0CIwwAAAAASUVORK5CYII=';
|
|
5
|
+
export default function FileTile(props) {
|
|
6
|
+
const {
|
|
7
|
+
mimeType,
|
|
8
|
+
name,
|
|
9
|
+
path,
|
|
10
|
+
src
|
|
11
|
+
} = props.tile.data;
|
|
12
|
+
const showName = useMemo(() => {
|
|
13
|
+
if (name) {
|
|
14
|
+
return name;
|
|
15
|
+
}
|
|
16
|
+
if (path) {
|
|
17
|
+
const pathArr = path.split('/');
|
|
18
|
+
return pathArr[pathArr.length - 1];
|
|
19
|
+
}
|
|
20
|
+
return 'unknow';
|
|
21
|
+
}, [name, path]);
|
|
22
|
+
const showSrc = useMemo(() => src || path || baseImg, [src, path]);
|
|
23
|
+
if (mimeType === 'image') {
|
|
24
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
25
|
+
className: "t-agent-file-tile",
|
|
26
|
+
onClick: async () => {
|
|
27
|
+
props.emitTileEvent({
|
|
28
|
+
type: '@buildIn/FileTileClick',
|
|
29
|
+
data: props.tile.data
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
33
|
+
className: "t-agent-file-tile-image-preview",
|
|
34
|
+
style: {
|
|
35
|
+
backgroundImage: "url(".concat(showSrc, ")")
|
|
36
|
+
}
|
|
37
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
38
|
+
className: "t-agent-file-tile-image-text"
|
|
39
|
+
}, " ", showName));
|
|
40
|
+
}
|
|
41
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
42
|
+
className: "t-agent-file-tile",
|
|
43
|
+
onClick: async () => {
|
|
44
|
+
props.emitTileEvent({
|
|
45
|
+
type: '@buildIn/FileTileClick',
|
|
46
|
+
data: props.tile.data
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
50
|
+
className: "t-agent-file-tile-image-preview",
|
|
51
|
+
style: {
|
|
52
|
+
backgroundImage: "url(".concat(baseImg, ")")
|
|
53
|
+
}
|
|
54
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
55
|
+
className: "t-agent-file-tile-image-text"
|
|
56
|
+
}, " ", showName));
|
|
57
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.t-agent-file-tile {
|
|
2
|
+
width: 400rpx;
|
|
3
|
+
height: 136rpx;
|
|
4
|
+
border-radius: 32rpx;
|
|
5
|
+
opacity: 1;
|
|
6
|
+
|
|
7
|
+
background: var(--app-B3);
|
|
8
|
+
padding: 16rpx;
|
|
9
|
+
display: flex;
|
|
10
|
+
margin-top: 16rpx;
|
|
11
|
+
margin-bottom: 16rpx;
|
|
12
|
+
&:first-child {
|
|
13
|
+
margin-top: 0rpx;
|
|
14
|
+
}
|
|
15
|
+
&:last-child {
|
|
16
|
+
margin-bottom: 0rpx;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.t-agent-file-tile-image-preview {
|
|
21
|
+
width: 104rpx;
|
|
22
|
+
height: 104rpx;
|
|
23
|
+
background-repeat: no-repeat;
|
|
24
|
+
background-position: center;
|
|
25
|
+
background-size: cover;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.t-agent-file-tile-image-text {
|
|
29
|
+
margin-left: 16rpx;
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
color: var(--app-B3-N1);
|
|
32
|
+
width: 248rpx;
|
|
33
|
+
height: 104rpx;
|
|
34
|
+
word-break: break-all; /* 允许单词内断行 */
|
|
35
|
+
|
|
36
|
+
/* 限制两行 */
|
|
37
|
+
display: -webkit-box;
|
|
38
|
+
-webkit-line-clamp: 3; /* 控制显示行数 */
|
|
39
|
+
-webkit-box-orient: vertical;
|
|
40
|
+
|
|
41
|
+
/* 溢出省略号 */
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
text-overflow: ellipsis;
|
|
44
|
+
}
|