|
|
@@ -65,6 +65,7 @@ const KnowledgeLibInfo : React.FC = () => {
|
|
|
|
|
|
const [ fileList, setFileList ] = React.useState<any[]>( [] );
|
|
|
const [ uploading, setUploading ] = React.useState( false );
|
|
|
+ const uploadMessageRef = React.useRef<(() => void) | null>( null );
|
|
|
|
|
|
const [ sListFlag, setSListFlag ] = React.useState<boolean>();
|
|
|
const [ cUpdateFlag, setCUpdateFlag ] = React.useState<boolean>();
|
|
|
@@ -81,7 +82,6 @@ const KnowledgeLibInfo : React.FC = () => {
|
|
|
multiple: true,
|
|
|
action: '/api/deepseek/api/uploadDocument/' + params.knowledgeId,
|
|
|
headers: getHeaders(),
|
|
|
- showUploadList: false, // 隐藏上传列表,避免显示HTML错误信息的tooltip
|
|
|
beforeUpload( file, fileList ) {
|
|
|
setUploadLoading( true );
|
|
|
// const allowedExtensions = ['md', 'txt', 'pdf', 'jpg', 'png', 'jpeg', 'docx', 'xlsx', 'pptx', 'eml', 'csv', 'tar', 'gz', 'bz2', 'zip', 'rar', 'jar'];
|
|
|
@@ -127,14 +127,26 @@ const KnowledgeLibInfo : React.FC = () => {
|
|
|
|
|
|
},
|
|
|
onChange( info ) {
|
|
|
- const { status } = info.file;
|
|
|
+ const { status, name } = info.file;
|
|
|
|
|
|
- if ( status !== 'uploading' ) {
|
|
|
- console.log( status, 'status--uploading' );
|
|
|
- }
|
|
|
- if ( status === 'done' ) {
|
|
|
+ if ( status === 'uploading' ) {
|
|
|
+ // 文件开始上传,显示持续提示
|
|
|
+ if ( !uploadMessageRef.current ) {
|
|
|
+ const closeMessage = message.loading(
|
|
|
+ `为了确保文件 "${name}" 的解析质量,系统需要一些时间进行准备(通常为2-20分钟)。辛苦您耐心等待,您可以继续使用其他功能,只要不关闭当前页面即可。`,
|
|
|
+ 0 // 0表示不自动关闭
|
|
|
+ );
|
|
|
+ uploadMessageRef.current = closeMessage;
|
|
|
+ }
|
|
|
+ setUploadLoading( true );
|
|
|
+ } else if ( status === 'done' ) {
|
|
|
console.log( status, 'status--done' );
|
|
|
console.info( info.file.response, 'info.file.response.data' );
|
|
|
+ // 关闭上传提示
|
|
|
+ if ( uploadMessageRef.current ) {
|
|
|
+ uploadMessageRef.current();
|
|
|
+ uploadMessageRef.current = null;
|
|
|
+ }
|
|
|
if ( info.file.response.code === 200 && info.file.response.data === 1 ) {
|
|
|
message.success( `${ info.file.name } file uploaded successfully.` );
|
|
|
init( params.knowledgeId );
|
|
|
@@ -142,6 +154,11 @@ const KnowledgeLibInfo : React.FC = () => {
|
|
|
setUploadLoading( false );
|
|
|
} else if ( status === 'error' ) {
|
|
|
console.log( status, 'status--error' );
|
|
|
+ // 关闭上传提示
|
|
|
+ if ( uploadMessageRef.current ) {
|
|
|
+ uploadMessageRef.current();
|
|
|
+ uploadMessageRef.current = null;
|
|
|
+ }
|
|
|
// 检查是否是504超时错误
|
|
|
const response = info.file.response;
|
|
|
const error = info.file.error;
|
|
|
@@ -155,6 +172,8 @@ const KnowledgeLibInfo : React.FC = () => {
|
|
|
responseStr.includes('<h1>504 Gateway Time-out</h1>') ||
|
|
|
errorStr.includes('timeout') ||
|
|
|
errorStr.includes('504')) {
|
|
|
+ info.file.response = '上传文件超时,请修改文件后再上传';
|
|
|
+ info.file.error = '上传文件超时,请修改文件后再上传';
|
|
|
message.error( '上传文件超时,请修改文件后再上传' );
|
|
|
} else {
|
|
|
message.error( `${ info.file.name } 文件上传失败` );
|
|
|
@@ -192,7 +211,7 @@ const KnowledgeLibInfo : React.FC = () => {
|
|
|
if (err?.response?.status === 504 || err?.code === 'ECONNABORTED' || String(err).includes('timeout')) {
|
|
|
message.error( '上传文件超时,请修改文件后再上传' );
|
|
|
} else {
|
|
|
- message.error( '上传失败' );
|
|
|
+ message.error( '上传失败' );
|
|
|
}
|
|
|
} finally {
|
|
|
setUploading( false );
|
|
|
@@ -412,6 +431,7 @@ const KnowledgeLibInfo : React.FC = () => {
|
|
|
title={<span style={{ fontWeight: 600 }}>上传知识文档</span>}
|
|
|
>
|
|
|
<div style={{ color: '#666', fontSize: 12 }}>支持多种格式(Word、PDF、图片等),单个/总大小有上限,上传后自动处理(约5-10分钟,如遇到超时,可等待几分钟后刷新页面,将自动成功)。</div>
|
|
|
+ {/* <div style={{ color: '#666', fontSize: 12 }}>支持pdf,doc,docx文件格式上传,建议单个文件不要超过10M,页数控制在100页以内。尽量单文件上传。</div> */}
|
|
|
<div style={{ textAlign: 'right', color: '#1677ff', fontWeight: 600 }}>step 1</div>
|
|
|
</Card>
|
|
|
</Col>
|
|
|
@@ -477,9 +497,10 @@ const KnowledgeLibInfo : React.FC = () => {
|
|
|
点击上传,或拖放文件到此处
|
|
|
</p>
|
|
|
<p className="ant-upload-hint">
|
|
|
- 支持文件格式md,txt,pdf,jpg,png,jpeg,docx,xlsx,
|
|
|
+ {/* 支持文件格式md,txt,pdf,jpg,png,jpeg,docx,xlsx,
|
|
|
pptx,eml,csv,单个文档 ≤ 30M,单张图片 ≤ 2.5M,文件总
|
|
|
- 大小不得超过125M.
|
|
|
+ 大小不得超过125M. */}
|
|
|
+ 支持pdf,doc,docx,jpg,png,jpeg文件格式上传,建议单个文件不要超过10M,页数控制在100页以内。尽量单文件上传。
|
|
|
</p>
|
|
|
</Dragger>
|
|
|
</div>
|