@fe-free/ai 6.0.24 → 6.0.26

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @fe-free/ai
2
2
 
3
+ ## 6.0.26
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @fe-free/tool@6.0.26
9
+ - @fe-free/core@6.0.26
10
+ - @fe-free/icons@6.0.26
11
+
12
+ ## 6.0.25
13
+
14
+ ### Patch Changes
15
+
16
+ - sender
17
+ - @fe-free/core@6.0.25
18
+ - @fe-free/icons@6.0.25
19
+ - @fe-free/tool@6.0.25
20
+
3
21
  ## 6.0.24
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.24",
3
+ "version": "6.0.26",
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.24"
20
+ "@fe-free/core": "6.0.26"
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.24",
31
- "@fe-free/tool": "6.0.24"
30
+ "@fe-free/icons": "6.0.26",
31
+ "@fe-free/tool": "6.0.26"
32
32
  },
33
33
  "scripts": {
34
34
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -100,7 +100,7 @@ function FileUpload(
100
100
  },
101
101
  ) {
102
102
  const { allowUpload, refUpload, fileList, setFileList, uploadMaxCount } = props;
103
- const { uploadAction, filesMaxCount, accept } = allowUpload || {};
103
+ const { uploadAction, uploadHeaders, filesMaxCount, accept } = allowUpload || {};
104
104
 
105
105
  const { message } = App.useApp();
106
106
  const { t } = useTranslation();
@@ -108,6 +108,7 @@ function FileUpload(
108
108
  return (
109
109
  <Upload.Dragger
110
110
  action={uploadAction}
111
+ headers={uploadHeaders}
111
112
  accept={accept}
112
113
  fileList={fileList}
113
114
  multiple
@@ -72,6 +72,20 @@ export const AllowUploadWithAccept: Story = {
72
72
  render: (props) => <Component {...props} />,
73
73
  };
74
74
 
75
+ export const AllowUploadWithHeaders: Story = {
76
+ args: {
77
+ allowUpload: {
78
+ uploadAction: '/api/ai-service/v1/file_upload/upload',
79
+ filesMaxCount: 3,
80
+ uploadHeaders: {
81
+ Authorization: 'Bearer mock-token',
82
+ 'X-Trace-Id': 'storybook-demo',
83
+ },
84
+ },
85
+ },
86
+ render: (props) => <Component {...props} />,
87
+ };
88
+
75
89
  export const RenderUpload: Story = {
76
90
  args: {
77
91
  allowUpload: {
@@ -1,5 +1,5 @@
1
- import type { ReactNode } from 'react';
2
- import { RefObject } from 'react';
1
+ import type { UploadProps } from 'antd';
2
+ import type { ReactNode, RefObject } from 'react';
3
3
 
4
4
  interface SenderRef {
5
5
  focus: () => void;
@@ -22,6 +22,8 @@ interface SenderProps {
22
22
  allowUpload?: {
23
23
  /** 上传文件的接口地址,约定返回的 {data: {url: string}} */
24
24
  uploadAction?: string;
25
+ /** 上传文件时附带的请求头 */
26
+ uploadHeaders?: UploadProps['headers'];
25
27
  /** 限制可上传文件类型,语法同 input.accept,如 image/*,.pdf */
26
28
  accept?: string;
27
29
  /** files 最大数量 */
@@ -19,19 +19,19 @@ async function fetchStream(
19
19
  };
20
20
  },
21
21
  ) {
22
- await XRequest<any, StreamMessage>(url, {
22
+ XRequest<any, StreamMessage>(url, {
23
23
  ...rest,
24
24
  params: params,
25
25
  headers: headers,
26
26
  callbacks: {
27
- onUpdate: (message, headers) => {
27
+ onUpdate: (message, hs) => {
28
28
  // 会存在 message 为 undefined 的情况
29
29
  if (message) {
30
- callbacks?.onUpdate?.(message, headers);
30
+ callbacks?.onUpdate?.(message, hs);
31
31
  }
32
32
  },
33
- onSuccess: (chunks, headers) => {
34
- callbacks?.onSuccess?.(chunks, headers);
33
+ onSuccess: (chunks, hs) => {
34
+ callbacks?.onSuccess?.(chunks, hs);
35
35
  },
36
36
  onError: (error, errorInfo) => {
37
37
  console.log('XRequest onError', error);