@fe-free/ai 6.0.27 → 6.0.29
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/CHANGELOG.md +18 -0
- package/package.json +4 -4
- package/src/messages/messages.tsx +4 -0
- package/src/sender/files.tsx +16 -3
- package/src/sender/index.tsx +4 -2
- package/src/sender/sender.stories.tsx +10 -0
- package/src/sender/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @fe-free/ai
|
|
2
2
|
|
|
3
|
+
## 6.0.29
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: sender
|
|
8
|
+
- @fe-free/core@6.0.29
|
|
9
|
+
- @fe-free/icons@6.0.29
|
|
10
|
+
- @fe-free/tool@6.0.29
|
|
11
|
+
|
|
12
|
+
## 6.0.28
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- some
|
|
17
|
+
- @fe-free/core@6.0.28
|
|
18
|
+
- @fe-free/icons@6.0.28
|
|
19
|
+
- @fe-free/tool@6.0.28
|
|
20
|
+
|
|
3
21
|
## 6.0.27
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/ai",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.29",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"lodash-es": "^4.17.21",
|
|
18
18
|
"uuid": "^13.0.0",
|
|
19
19
|
"zustand": "^4.5.7",
|
|
20
|
-
"@fe-free/core": "6.0.
|
|
20
|
+
"@fe-free/core": "6.0.29"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"antd": "^6.2.1",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"i18next-icu": "^2.4.1",
|
|
28
28
|
"react": "^19.2.0",
|
|
29
29
|
"react-i18next": "^16.4.0",
|
|
30
|
-
"@fe-free/icons": "6.0.
|
|
31
|
-
"@fe-free/tool": "6.0.
|
|
30
|
+
"@fe-free/icons": "6.0.29",
|
|
31
|
+
"@fe-free/tool": "6.0.29"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -9,6 +9,8 @@ import { EnumMessageType, type Message } from '../store/types';
|
|
|
9
9
|
interface MessagesProps<UserData, AIData, SystemData> {
|
|
10
10
|
refList?: React.RefObject<HTMLDivElement | null>;
|
|
11
11
|
messages?: Message<UserData, AIData, SystemData>[];
|
|
12
|
+
/** 是否开启滚动条固定 */
|
|
13
|
+
scrollFixed?: boolean;
|
|
12
14
|
/** 含所有 */
|
|
13
15
|
renderMessage?: (props: { message: Message<UserData, AIData, SystemData> }) => React.ReactNode;
|
|
14
16
|
/** 系统消息 */
|
|
@@ -65,6 +67,7 @@ function Messages<UserData, AIData, SystemData>(
|
|
|
65
67
|
const {
|
|
66
68
|
refList,
|
|
67
69
|
messages,
|
|
70
|
+
scrollFixed = true,
|
|
68
71
|
renderMessage,
|
|
69
72
|
renderMessageOfSystem,
|
|
70
73
|
renderMessageOfUser,
|
|
@@ -133,6 +136,7 @@ function Messages<UserData, AIData, SystemData>(
|
|
|
133
136
|
style={{
|
|
134
137
|
transform: `translateZ(0)`,
|
|
135
138
|
}}
|
|
139
|
+
disabled={!scrollFixed}
|
|
136
140
|
>
|
|
137
141
|
{messages?.map((message) => {
|
|
138
142
|
return (
|
package/src/sender/files.tsx
CHANGED
|
@@ -18,7 +18,7 @@ function FileAction(
|
|
|
18
18
|
},
|
|
19
19
|
) {
|
|
20
20
|
const { value, refUpload, fileUrls, setFileUrls, allowUpload } = props;
|
|
21
|
-
const { filesMaxCount } = allowUpload || {};
|
|
21
|
+
const { filesMaxCount, multiple = true } = allowUpload || {};
|
|
22
22
|
|
|
23
23
|
const { message } = App.useApp();
|
|
24
24
|
const { t } = useTranslation();
|
|
@@ -65,6 +65,14 @@ function FileAction(
|
|
|
65
65
|
open
|
|
66
66
|
onCancel={() => setOpen(false)}
|
|
67
67
|
onOk={() => {
|
|
68
|
+
if (!multiple) {
|
|
69
|
+
if (url.trim()) {
|
|
70
|
+
setFileUrls([url]);
|
|
71
|
+
}
|
|
72
|
+
setOpen(false);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
68
76
|
if (filesMaxCount && value?.files && value.files.length >= filesMaxCount) {
|
|
69
77
|
message.warning(
|
|
70
78
|
t('@fe-free/ai.sender.exceedMaxUploadCount', '超过最大上传数量{count}', {
|
|
@@ -100,7 +108,7 @@ function FileUpload(
|
|
|
100
108
|
},
|
|
101
109
|
) {
|
|
102
110
|
const { allowUpload, refUpload, fileList, setFileList, uploadMaxCount } = props;
|
|
103
|
-
const { uploadAction, uploadHeaders, filesMaxCount, accept } = allowUpload || {};
|
|
111
|
+
const { uploadAction, uploadHeaders, filesMaxCount, accept, multiple = true } = allowUpload || {};
|
|
104
112
|
|
|
105
113
|
const { message } = App.useApp();
|
|
106
114
|
const { t } = useTranslation();
|
|
@@ -111,10 +119,15 @@ function FileUpload(
|
|
|
111
119
|
headers={uploadHeaders}
|
|
112
120
|
accept={accept}
|
|
113
121
|
fileList={fileList}
|
|
114
|
-
multiple
|
|
122
|
+
multiple={multiple}
|
|
115
123
|
pastable
|
|
116
124
|
maxCount={uploadMaxCount ? uploadMaxCount + 1 : undefined}
|
|
117
125
|
onChange={(info) => {
|
|
126
|
+
if (!multiple) {
|
|
127
|
+
setFileList(info.fileList.slice(-1));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
118
131
|
if (uploadMaxCount && info.fileList.length > uploadMaxCount) {
|
|
119
132
|
message.warning(
|
|
120
133
|
t('@fe-free/ai.sender.exceedMaxUploadCount', '超过最大上传数量{count}', {
|
package/src/sender/index.tsx
CHANGED
|
@@ -66,7 +66,7 @@ function Sender(originProps: SenderProps) {
|
|
|
66
66
|
const refText = useRef<TextAreaRef | null>(null);
|
|
67
67
|
|
|
68
68
|
const { value, onChange, allowUpload, onSubmit, loading, allowSpeech } = props;
|
|
69
|
-
const { filesMaxCount } = allowUpload || {};
|
|
69
|
+
const { filesMaxCount, multiple = true } = allowUpload || {};
|
|
70
70
|
|
|
71
71
|
const refContainer = useRef<HTMLDivElement>(null);
|
|
72
72
|
const refUpload = useRef<HTMLDivElement>(null);
|
|
@@ -196,7 +196,9 @@ function Sender(originProps: SenderProps) {
|
|
|
196
196
|
refUpload={refUpload}
|
|
197
197
|
fileList={fileList}
|
|
198
198
|
setFileList={setFileList}
|
|
199
|
-
uploadMaxCount={
|
|
199
|
+
uploadMaxCount={
|
|
200
|
+
!multiple ? 1 : filesMaxCount ? filesMaxCount - fileUrls.length : undefined
|
|
201
|
+
}
|
|
200
202
|
/>
|
|
201
203
|
)}
|
|
202
204
|
</div>
|
|
@@ -103,6 +103,16 @@ export const RenderUpload: Story = {
|
|
|
103
103
|
render: (props) => <Component {...props} />,
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
export const SingleUpload: Story = {
|
|
107
|
+
args: {
|
|
108
|
+
allowUpload: {
|
|
109
|
+
uploadAction: '/api/ai-service/v1/file_upload/upload',
|
|
110
|
+
multiple: false,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
render: (props) => <Component {...props} />,
|
|
114
|
+
};
|
|
115
|
+
|
|
106
116
|
export const AllowSpeech: Story = {
|
|
107
117
|
render: (props) => {
|
|
108
118
|
const [recording, setRecording] = useState(true);
|
package/src/sender/types.ts
CHANGED