|
@@ -21,13 +21,12 @@ import InfoModalSetting from './components/InfoModalSetting';
|
|
|
import router from '@/router';
|
|
import router from '@/router';
|
|
|
import { Record } from './types';
|
|
import { Record } from './types';
|
|
|
import dayjs from 'dayjs';
|
|
import dayjs from 'dayjs';
|
|
|
|
|
+import axios from 'axios';
|
|
|
import LocalStorage from '@/LocalStorage';
|
|
import LocalStorage from '@/LocalStorage';
|
|
|
import store from './store';
|
|
import store from './store';
|
|
|
import './style.less';
|
|
import './style.less';
|
|
|
-import { uploadAxiosInstance } from '@/apis/api';
|
|
|
|
|
|
|
|
|
|
const { Dragger } = Upload;
|
|
const { Dragger } = Upload;
|
|
|
-
|
|
|
|
|
interface Props{
|
|
interface Props{
|
|
|
drawerItem: any;
|
|
drawerItem: any;
|
|
|
}
|
|
}
|
|
@@ -81,38 +80,8 @@ const KnowledgeLibInfo : React.FC<Props> = ({drawerItem}:Props) => {
|
|
|
const props : UploadProps = {
|
|
const props : UploadProps = {
|
|
|
name: 'files',
|
|
name: 'files',
|
|
|
multiple: true,
|
|
multiple: true,
|
|
|
- customRequest: async (options) => {
|
|
|
|
|
- const { file, onSuccess, onError, onProgress } = options;
|
|
|
|
|
- const formData = new FormData();
|
|
|
|
|
- formData.append('files', file as File);
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- const response = await uploadAxiosInstance.post(
|
|
|
|
|
- `/deepseek/api/uploadDocument/${params.knowledgeId}`,
|
|
|
|
|
- formData,
|
|
|
|
|
- {
|
|
|
|
|
- headers: {
|
|
|
|
|
- 'Content-Type': 'multipart/form-data',
|
|
|
|
|
- },
|
|
|
|
|
- onUploadProgress: (progressEvent) => {
|
|
|
|
|
- if (progressEvent.total) {
|
|
|
|
|
- const percent = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
|
|
|
- onProgress?.({ percent });
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // 处理响应
|
|
|
|
|
- if (response.data && response.data.code === 200) {
|
|
|
|
|
- onSuccess?.(response.data, file as any);
|
|
|
|
|
- } else {
|
|
|
|
|
- onError?.(new Error(response.data?.msg || '上传失败'));
|
|
|
|
|
- }
|
|
|
|
|
- } catch (error: any) {
|
|
|
|
|
- onError?.(error);
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ action: '/api/deepseek/api/uploadDocument/' + params.knowledgeId,
|
|
|
|
|
+ headers: getHeaders(),
|
|
|
beforeUpload( file, fileList ) {
|
|
beforeUpload( file, fileList ) {
|
|
|
setUploadLoading( true );
|
|
setUploadLoading( true );
|
|
|
// const allowedExtensions = ['md', 'txt', 'pdf', 'jpg', 'png', 'jpeg', 'docx', 'xlsx', 'pptx', 'eml', 'csv', 'tar', 'gz', 'bz2', 'zip', 'rar', 'jar'];
|
|
// const allowedExtensions = ['md', 'txt', 'pdf', 'jpg', 'png', 'jpeg', 'docx', 'xlsx', 'pptx', 'eml', 'csv', 'tar', 'gz', 'bz2', 'zip', 'rar', 'jar'];
|
|
@@ -232,7 +201,7 @@ const KnowledgeLibInfo : React.FC<Props> = ({drawerItem}:Props) => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- const res = await uploadAxiosInstance.post( '/deepseek/api/uploadDocument/' + params.knowledgeId, formData, {
|
|
|
|
|
|
|
+ const res = await axios.post( '/api/deepseek/api/uploadDocument/' + params.knowledgeId, formData, {
|
|
|
headers: { 'Content-Type': 'multipart/form-data' }
|
|
headers: { 'Content-Type': 'multipart/form-data' }
|
|
|
} );
|
|
} );
|
|
|
|
|
|