Merge pull request #371 from SuanmoSuanyangTechnology/fix/release_web_zy
Fix/release web zy
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 13:59:56
|
* @Date: 2026-02-03 13:59:56
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-02-03 13:59:56
|
* @Last Modified time: 2026-02-09 16:24:05
|
||||||
*/
|
*/
|
||||||
import { request, API_PREFIX } from '@/utils/request'
|
import { request, API_PREFIX } from '@/utils/request'
|
||||||
|
|
||||||
// Upload file,file storage has expiration period
|
// Upload file,file storage has expiration period
|
||||||
export const fileUploadUrl = `${API_PREFIX}/storage/files`
|
export const fileUploadUrlWithoutApiPrefix = '/storage/files'
|
||||||
|
export const fileUploadUrl = `${API_PREFIX}${fileUploadUrlWithoutApiPrefix}`
|
||||||
export const fileUpload = (formData?: unknown) => {
|
export const fileUpload = (formData?: unknown) => {
|
||||||
return request.uploadFile('/storage/files', formData)
|
return request.uploadFile(fileUploadUrlWithoutApiPrefix, formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file access URL (no token required)
|
// Get file access URL (no token required)
|
||||||
@@ -30,4 +31,5 @@ export const deleteFile = (fileId: string) => {
|
|||||||
return request.delete(deleteFileUrl(fileId))
|
return request.delete(deleteFileUrl(fileId))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const shareFileUploadUrl = `${API_PREFIX}/storage/share/files`
|
export const shareFileUploadUrlWithoutApiPrefix = `/storage/share/files`
|
||||||
|
export const shareFileUploadUrl = `${API_PREFIX}${shareFileUploadUrlWithoutApiPrefix}`
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 16:29:21
|
* @Date: 2026-02-03 16:29:21
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-02-09 10:33:21
|
* @Last Modified time: 2026-02-09 16:56:27
|
||||||
*/
|
*/
|
||||||
import { type FC, type ReactNode, useEffect, useRef, useState, forwardRef, useImperativeHandle } from 'react';
|
import { type FC, type ReactNode, useEffect, useRef, useState, forwardRef, useImperativeHandle } from 'react';
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
@@ -210,7 +210,7 @@ const Agent = forwardRef<AgentRef>((_props, ref) => {
|
|||||||
})
|
})
|
||||||
if (default_model_config_id === values?.default_model_config_id) {
|
if (default_model_config_id === values?.default_model_config_id) {
|
||||||
setChatList([{
|
setChatList([{
|
||||||
label: vo.label || '',
|
label: defaultModel?.id === default_model_config_id && defaultModel?.name ? defaultModel.name : vo.label || '',
|
||||||
model_config_id: default_model_config_id || '',
|
model_config_id: default_model_config_id || '',
|
||||||
model_parameters: {...rest},
|
model_parameters: {...rest},
|
||||||
list: []
|
list: []
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-06 21:09:42
|
* @Date: 2026-02-06 21:09:42
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-02-06 21:09:42
|
* @Last Modified time: 2026-02-09 16:41:31
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* File Upload Component
|
* File Upload Component
|
||||||
@@ -25,8 +25,8 @@ import { Upload, Progress, App } from 'antd';
|
|||||||
import type { UploadProps, UploadFile } from 'antd';
|
import type { UploadProps, UploadFile } from 'antd';
|
||||||
import type { UploadProps as RcUploadProps } from 'antd/es/upload/interface';
|
import type { UploadProps as RcUploadProps } from 'antd/es/upload/interface';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { cookieUtils } from '@/utils/request'
|
import { request } from '@/utils/request'
|
||||||
import { fileUploadUrl } from '@/api/fileStorage'
|
import { fileUploadUrlWithoutApiPrefix } from '@/api/fileStorage'
|
||||||
|
|
||||||
interface UploadFilesProps extends Omit<UploadProps, 'onChange'> {
|
interface UploadFilesProps extends Omit<UploadProps, 'onChange'> {
|
||||||
/** Upload API endpoint */
|
/** Upload API endpoint */
|
||||||
@@ -99,7 +99,7 @@ export interface UploadFilesRef {
|
|||||||
* Supports single/multiple file uploads, drag-and-drop, file validation, and preview
|
* Supports single/multiple file uploads, drag-and-drop, file validation, and preview
|
||||||
*/
|
*/
|
||||||
const UploadFiles = forwardRef<UploadFilesRef, UploadFilesProps>(({
|
const UploadFiles = forwardRef<UploadFilesRef, UploadFilesProps>(({
|
||||||
action = fileUploadUrl,
|
action = fileUploadUrlWithoutApiPrefix,
|
||||||
multiple = false,
|
multiple = false,
|
||||||
fileList: propFileList = [],
|
fileList: propFileList = [],
|
||||||
onChange,
|
onChange,
|
||||||
@@ -110,6 +110,7 @@ const UploadFiles = forwardRef<UploadFilesRef, UploadFilesProps>(({
|
|||||||
maxCount = 1,
|
maxCount = 1,
|
||||||
onRemove: customOnRemove,
|
onRemove: customOnRemove,
|
||||||
update,
|
update,
|
||||||
|
requestConfig,
|
||||||
...props
|
...props
|
||||||
}, ref) => {
|
}, ref) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -163,6 +164,24 @@ const UploadFiles = forwardRef<UploadFilesRef, UploadFilesProps>(({
|
|||||||
return isAutoUpload;
|
return isAutoUpload;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom upload request handler
|
||||||
|
*/
|
||||||
|
const handleCustomRequest: RcUploadProps['customRequest'] = async (options) => {
|
||||||
|
const { file, onSuccess, onError } = options;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', file);
|
||||||
|
|
||||||
|
const response = await request.uploadFile(action, formData, requestConfig);
|
||||||
|
|
||||||
|
onSuccess?.({data: response});
|
||||||
|
} catch (error) {
|
||||||
|
onError?.(error as Error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles upload state changes
|
* Handles upload state changes
|
||||||
*/
|
*/
|
||||||
@@ -207,13 +226,10 @@ const UploadFiles = forwardRef<UploadFilesRef, UploadFilesProps>(({
|
|||||||
|
|
||||||
// Generate upload component configuration
|
// Generate upload component configuration
|
||||||
const uploadProps: UploadProps = {
|
const uploadProps: UploadProps = {
|
||||||
action,
|
customRequest: handleCustomRequest,
|
||||||
multiple: multiple && maxCount > 1,
|
multiple: multiple && maxCount > 1,
|
||||||
fileList,
|
fileList,
|
||||||
beforeUpload,
|
beforeUpload,
|
||||||
headers: {
|
|
||||||
authorization: `Bearer ${cookieUtils.get('authToken')}`,
|
|
||||||
},
|
|
||||||
onChange: handleChange,
|
onChange: handleChange,
|
||||||
accept,
|
accept,
|
||||||
disabled,
|
disabled,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-03 16:58:03
|
* @Date: 2026-02-03 16:58:03
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-02-06 21:11:23
|
* @Last Modified time: 2026-02-09 16:37:49
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Conversation Page
|
* Conversation Page
|
||||||
@@ -35,7 +35,7 @@ import MemoryFunctionCheckedIcon from '@/assets/images/conversation/memoryFuncti
|
|||||||
import { type SSEMessage } from '@/utils/stream'
|
import { type SSEMessage } from '@/utils/stream'
|
||||||
import UploadFiles from './components/FileUpload'
|
import UploadFiles from './components/FileUpload'
|
||||||
// import AudioRecorder from '@/components/AudioRecorder'
|
// import AudioRecorder from '@/components/AudioRecorder'
|
||||||
import { shareFileUploadUrl } from '@/api/fileStorage'
|
import { shareFileUploadUrlWithoutApiPrefix } from '@/api/fileStorage'
|
||||||
import UploadFileListModal from './components/UploadFileListModal'
|
import UploadFileListModal from './components/UploadFileListModal'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -350,11 +350,16 @@ const Conversation: FC = () => {
|
|||||||
{
|
{
|
||||||
key: 'upload', label: (
|
key: 'upload', label: (
|
||||||
<UploadFiles
|
<UploadFiles
|
||||||
action={shareFileUploadUrl}
|
action={shareFileUploadUrlWithoutApiPrefix}
|
||||||
fileType={['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg']}
|
fileType={['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg']}
|
||||||
onChange={fileChange}
|
onChange={fileChange}
|
||||||
fileList={[]}
|
fileList={[]}
|
||||||
update={update}
|
update={update}
|
||||||
|
requestConfig={{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
authorization: `Bearer ${shareToken || ''}`,
|
||||||
|
} }}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user