Преглед на файлове

多知识库选择修改

huiqi преди 3 месеца
родител
ревизия
e4da0f2def

+ 28 - 27
src/pages/deepseek/knowledgeLib/detail/index.tsx

@@ -1,6 +1,7 @@
 import * as React from 'react';
 import { generatePath, useParams } from 'react-router-dom';
 import { observer } from 'mobx-react';
+import config, { getHeaders } from '@/apis/config';
 
 import {
   Button,
@@ -27,7 +28,7 @@ import './style.less';
 const { Dragger } = Upload;
 
 const KnowledgeLibInfo : React.FC = () => {
-  
+
   const {
     state,
     init,
@@ -53,31 +54,31 @@ const KnowledgeLibInfo : React.FC = () => {
     infoModalSettingId,
     knowledgeDetail,
   } = state;
-  
+
   const [ uploadLoading, setUploadLoading ] = React.useState( false );
-  
+
   const params = useParams();
-  
+
   const [ fileList, setFileList ] = React.useState<any[]>( [] );
   const [ uploading, setUploading ] = React.useState( false );
-  
+
   const [ sListFlag, setSListFlag ] = React.useState<boolean>();
   const [ cUpdateFlag, setCUpdateFlag ] = React.useState<boolean>();
   const [ detailFlag, setDetailFlag ] = React.useState<boolean>();
   const [ deleteFlag, setDeleteFlag ] = React.useState<boolean>();
   const [ createFlag, setCreateFlag ] = React.useState<boolean>();
-  
+
   const props : UploadProps = {
     name: 'files',
     multiple: true,
     action: '/api/deepseek/api/uploadDocument/' + params.knowledgeId,
-    
+    headers: getHeaders(),
     beforeUpload( file, fileList ) {
       setUploadLoading( true );
       // const allowedExtensions = ['md', 'txt', 'pdf', 'jpg', 'png', 'jpeg', 'docx', 'xlsx', 'pptx', 'eml', 'csv', 'tar', 'gz', 'bz2', 'zip', 'rar', 'jar'];
-      
+
       const allowedExtensions = [ 'txt', 'pdf', 'jpg', 'png', 'jpeg', 'doc', 'docx', 'ppt', 'pptx' ];
-      
+
       // 检查文件类型
       for ( const file of fileList ) {
         const fileExt = file.name.split( '.' ).pop()?.toLowerCase();
@@ -87,38 +88,38 @@ const KnowledgeLibInfo : React.FC = () => {
           return Upload.LIST_IGNORE;
         }
       }
-      
+
       // 检查文件大小
       let totalSize = 0;
       for ( const file of fileList ) {
         const fileExt = file.name.split( '.' ).pop()?.toLowerCase();
         const fileSizeMB = file.size / 1024 / 1024;
-        
+
         if ( fileSizeMB > 30 ) {
           message.error( '单个文件不能大于30M' );
           setUploadLoading( false );
           return Upload.LIST_IGNORE;
         }
-        
+
         if ( [ 'jpg', 'png', 'jpeg' ].includes( fileExt! ) && fileSizeMB > 5 ) {
           message.error( '单张图片不能大于5M' );
           setUploadLoading( false );
           return Upload.LIST_IGNORE;
         }
-        
+
         totalSize += fileSizeMB;
       }
-      
+
       if ( totalSize > 125 ) {
         message.error( '文件总大小超过125M' );
         setUploadLoading( false );
         return Upload.LIST_IGNORE;
       }
-      
+
     },
     onChange( info ) {
       const { status } = info.file;
-      
+
       if ( status !== 'uploading' ) {
         console.log( status, 'status--uploading' );
       }
@@ -140,25 +141,25 @@ const KnowledgeLibInfo : React.FC = () => {
       console.log( 'Dropped files', e.dataTransfer.files );
     },
   };
-  
+
   const handleUpload = async () => {
     if ( fileList.length === 0 ) return;
-    
+
     setUploading( true );
     const formData = new FormData();
-    
+
     // 添加所有文件
     fileList.forEach( file => {
       if ( file.originFileObj ) {
         formData.append( 'files', file.originFileObj );
       }
     } );
-    
+
     try {
       const res = await axios.post( '/api/deepseek/api/uploadDocument/' + params.knowledgeId, formData, {
         headers: { 'Content-Type': 'multipart/form-data' }
       } );
-      
+
       message.success( `${ fileList.length }个文件上传成功` );
       setFileList( [] );
     } catch ( err ) {
@@ -167,7 +168,7 @@ const KnowledgeLibInfo : React.FC = () => {
       setUploading( false );
     }
   };
-  
+
   React.useEffect( () => {
     init( params.knowledgeId );
     const cList = LocalStorage.getStatusFlag( 'deepseek:slice:list' );
@@ -182,7 +183,7 @@ const KnowledgeLibInfo : React.FC = () => {
     setCreateFlag( createF );
     return () => reset();
   }, [] );
-  
+
   const columns : TableColumnsType<Record> = [
     {
       title: '序号',
@@ -331,7 +332,7 @@ const KnowledgeLibInfo : React.FC = () => {
       }
     }
   ];
-  
+
   const paginationConfig : TablePaginationConfig = {
     // 显示数据总量
     showTotal: ( total : number ) => {
@@ -350,7 +351,7 @@ const KnowledgeLibInfo : React.FC = () => {
       await onChangePagination( page, pageSize );
     },
   };
-  
+
   return (
       <div className='knowledgeLibInfo'>
         <Spin spinning={ uploadLoading || listLoading }>
@@ -424,7 +425,7 @@ const KnowledgeLibInfo : React.FC = () => {
                         onClickCancel={ infoModalOnClickCancel }
                     />
                 }
-                
+
                 {
                     infoModalSettingOpen &&
                     <InfoModalSetting
@@ -441,4 +442,4 @@ const KnowledgeLibInfo : React.FC = () => {
   );
 };
 
-export default observer( KnowledgeLibInfo );
+export default observer( KnowledgeLibInfo );

+ 19 - 10
src/pages/deepseek/questionAnswer/info/index.tsx

@@ -16,7 +16,7 @@ import LocalStorage from '@/LocalStorage';
 const { TextArea } = Input;
 const FormItem = Form.Item;
 const { Option } = Select;
-const MAX_COUNT = 10;
+const MAX_COUNT = 5;
 const Index = 1;
 
 const QuestionAnswerInfo: React.FC = () => {
@@ -170,9 +170,13 @@ const QuestionAnswerInfo: React.FC = () => {
         setInputs([...inputs, { id: newId, value: '' }]);
     };
 
-    const delInput = () => {
-        const newId = inputs.length - 1; // 生成新的唯一ID
-        setInputs(inputs.slice(0, inputs.length - 1));
+    // 删除输入框(按id删除+最少数量限制)
+    const delInput = (id: number) => {
+        if (inputs.length <= 1) {
+            message.warning("至少保留1个预设问题");
+            return;
+        }
+        setInputs(inputs.filter(input => input.id !== id));
     };
 
     // 处理输入变更的函数
@@ -278,6 +282,8 @@ const QuestionAnswerInfo: React.FC = () => {
                 } else {
                     setIsDeepThinkVisible(false);
                 }
+
+                console.log(info.knowledgeIds,'info.knowledgeIds')
                 form.setFieldsValue({
                     id: info.id,
                     name: info.name,  //应用名称
@@ -328,6 +334,9 @@ const QuestionAnswerInfo: React.FC = () => {
                         value: item.knowledgeId,
                     }
                 });
+                console.log(list,'list')
+
+
                 setKnowledgeList(list);
             } catch (error: any) {
                 console.error(error);
@@ -419,7 +428,6 @@ const QuestionAnswerInfo: React.FC = () => {
                         >
                             <Input placeholder="请输入问答应用名称" className='form-input-large' />
                         </FormItem>
-
                         <FormItem
                             label='应用类型'
                             name='typeId'
@@ -485,7 +493,7 @@ const QuestionAnswerInfo: React.FC = () => {
                                             />
                                             <div className='question-actions'>
                                                 <PlusCircleOutlined className='question-icon' onClick={addInput} />
-                                                <MinusCircleOutlined className='question-icon' onClick={delInput} />
+                                                <MinusCircleOutlined className='question-icon' onClick={() => delInput(input.id)} />
                                             </div>
                                         </div>
                                     ))}
@@ -560,6 +568,7 @@ const QuestionAnswerInfo: React.FC = () => {
                                                 }
                                                 const indexTypeList: Item[] = [];
                                                 if (values.knowledge_ids && values.knowledge_ids.length > 0) {
+                                                    console.log("knowledge_ids",values.knowledge_ids);
                                                     const index_type: Item = {
                                                         index_type_id: 0,
                                                         knowledge_id: values.knowledge_ids
@@ -707,17 +716,17 @@ const QuestionAnswerInfo: React.FC = () => {
                                         <div className='flex-center-top'>
                                             欢迎使用 {name}
                                         </div>
-
                                         <div className='flex-center padding-top-20'>
                                             <FormItem
                                                 label='引用知识库'
                                                 name='knowledge_ids'
                                                 rules={[{ required: true, message: '知识库不能为空' }]}>
                                                 <Select
-                                                    // mode='multiple'
-                                                    // maxCount={MAX_COUNT}
+                                                    mode='multiple'
+                                                    maxCount={MAX_COUNT}
+                                                    showSearch={true}
                                                     // suffixIcon={suffix}
-                                                    className='questionAnswerInfo-content-title'
+                                                    // className='questionAnswerInfo-content-title'
                                                     placeholder='请选择知识库'
                                                 >
                                                     {

+ 48 - 50
src/pages/deepseek/questionAnswer/info/style.less

@@ -4,14 +4,14 @@
   height: 100%;
   background: #FFFFFF;
   border-radius: @border-radius-base;
-  
+
   // 内容区域
   &-content {
     width: 100%;
     height: 100%;
     background: #FFFFFF;
     padding: 16px 20px;
-    
+
     // 标题样式
     &-title {
       width: 100%;
@@ -25,18 +25,15 @@
 .flex {
   &-center {
     &-container {
-      display: flex;
-      justify-content: center;
-      align-items: center;
-      background: #f5f5f5;
       width: 100%;
       height: 100%;
+      background: #f5f5f5;
     }
-    
+
     display: flex;
     justify-content: center;
     align-items: center;
-    
+
     &-top {
       display: flex;
       justify-content: center;
@@ -45,13 +42,13 @@
       font-size: 16px;
     }
   }
-  
+
   &-between {
     display: flex;
     justify-content: space-between;
     align-items: center;
   }
-  
+
   &-end {
     display: flex;
     justify-content: flex-end;
@@ -66,33 +63,33 @@
     color: #000000;
     transition: all 0.3s ease;
     box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
-    
+
     &:hover {
       background: #e8e8e8;
       color: #000000;
       box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
       transform: translateY(-1px);
     }
-    
+
     &:active {
       background: #dcdcdc;
       color: #000000;
       box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
       transform: translateY(0);
     }
-    
+
     &:focus {
       box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
     }
   }
-  
+
   &-back {
     background: #ffffff;
     border: 1px solid #f0f0f0;
     color: #595959;
     transition: all 0.3s ease;
     box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
-    
+
     &:hover {
       background: #fafafa;
       border-color: #40a9ff;
@@ -100,7 +97,7 @@
       box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
       transform: translateY(-1px);
     }
-    
+
     &:active {
       background: #f0f0f0;
       border-color: #1890ff;
@@ -108,7 +105,7 @@
       box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
       transform: translateY(0);
     }
-    
+
     &:focus {
       border-color: #40a9ff;
       box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
@@ -123,25 +120,25 @@
       width: 100%;
       max-width: 646px;
     }
-    
+
     &-height {
       height: 48px;
     }
   }
-  
+
   &-input {
     &-large {
       width: 100%;
       max-width: 646px;
       padding: 8px;
     }
-    
+
     &-number-small {
       margin: 0 16px;
       width: 100px;
     }
   }
-  
+
   &-textarea {
     &-large {
       height: 120px;
@@ -157,7 +154,7 @@
   &-full-width {
     width: 100%;
   }
-  
+
   &-fixed-height {
     height: 300px;
   }
@@ -166,44 +163,44 @@
 // 预设问题区域样式
 .preset-questions {
   margin: 24px 0;
-  
+
   h4 {
     margin-bottom: 16px;
     color: #262626;
   }
-  
+
   .question-item {
     display: flex;
     align-items: center;
     margin-bottom: 12px;
     flex-wrap: wrap;
     gap: 12px;
-    
+
     label {
       min-width: 60px;
       color: #595959;
       flex-shrink: 0;
     }
-    
+
     .question-input {
       flex: 1;
       min-width: 200px;
       max-width: 400px;
       margin: 0;
     }
-    
+
     .question-actions {
       display: flex;
       gap: 8px;
       flex-shrink: 0;
-      
+
       .question-icon {
         margin: 0;
         font-size: 18px;
         color: @primary-color;
         cursor: pointer;
         transition: all 0.3s ease;
-        
+
         &:hover {
           color: @primary-color;
           transform: scale(1.1);
@@ -225,7 +222,7 @@
   color: @primary-color;
   cursor: pointer;
   text-decoration: none;
-  
+
   &:hover {
     text-decoration: underline;
   }
@@ -254,10 +251,10 @@
     display: flex;
     justify-content: space-between;
     align-items: flex-start;
-    
+
     &-text {
       // 说明文本
-        
+
       .variable-highlight {
         color: #1890ff;
         font-weight: 500;
@@ -274,20 +271,20 @@
     flex: 1;
     display: flex;
     flex-direction: column;
-    
+
     .ant-form-item {
       margin-bottom: 0;
       height: 100%;
-      
+
       .ant-form-item-control {
         height: 100%;
-        
+
         .ant-form-item-control-input {
           height: 100%;
-          
+
           .ant-form-item-control-input-content {
             height: 100%;
-            
+
             .ant-input {
               height: 100%;
               border: 1px solid #f0f0f0;
@@ -296,12 +293,12 @@
               font-size: 14px;
               line-height: 1.6;
               resize: none;
-              
+
               &:focus {
                 border-color: #1890ff;
                 box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
               }
-              
+
               &::placeholder {
                 color: #bfbfbf;
                 font-style: italic;
@@ -315,6 +312,7 @@
 }
 
 .half-width {
+  margin: 0 auto;
   width: 50%;
   height: 100%;
 }
@@ -325,12 +323,12 @@
     &-10 {
       padding-top: 10px;
     }
-    
+
     &-20 {
       padding-top: 20px;
     }
   }
-  
+
   &-bottom {
     &-10 {
       padding-bottom: 10px;
@@ -355,7 +353,7 @@
       }
     }
   }
-  
+
   .form {
     &-control-width,
     &-input-large,
@@ -363,32 +361,32 @@
       max-width: 100%;
     }
   }
-  
+
   .question-input {
     max-width: 100%;
     margin-left: 0;
   }
-  
+
   .half-width {
     width: 100%;
   }
-  
+
   .preset-questions {
     .question-item {
       flex-direction: column;
       align-items: flex-start;
       gap: 8px;
-      
+
       label {
         min-width: auto;
       }
-      
+
       .question-input {
         width: 100%;
         max-width: 100%;
         min-width: auto;
       }
-      
+
       .question-actions {
         align-self: flex-end;
       }
@@ -402,14 +400,14 @@
       padding: 16px;
     }
   }
-  
+
   .form {
     &-input-large,
     &-textarea-large {
       padding: 6px;
     }
   }
-  
+
   .preset-questions {
     .question-item {
       .question-actions {

+ 24 - 26
src/pages/deepseek/questionAnswer/list/style.less

@@ -17,21 +17,21 @@
   border-radius: @border-radius-large;
   min-height: 200px;
   overflow: auto;
-  
+
   // 默认状态下操作按钮颜色
   .action-button {
     color: #999 !important;
     transition: color 0.3s ease;
-    
+
     &:hover {
       color: @primary-color !important;
     }
   }
-  
+
   .delete-button {
     color: #999 !important;
     transition: color 0.3s ease;
-    
+
     &:hover {
       color: @error-color !important;
     }
@@ -40,12 +40,12 @@
 .card:hover{
   box-shadow: 0 0 8px rgba(0,0,0,.1);
   border: 1px solid @primary-color ;
-  
+
   // 悬停状态下操作按钮颜色
   .action-button {
     color: @primary-color !important;
   }
-  
+
   .delete-button {
     color: @error-color !important;
   }
@@ -59,12 +59,10 @@
   transition: all 0.3s;
 }
 
-
-
 .ant-select-selector {
   border-radius: 4px !important;
   background: #fff !important;
-  height: 32px !important;
+  //height: 32px !important;
 }
 
 .ant-select-dropdown {
@@ -72,7 +70,7 @@
     background-color: @primary-color !important;
     color: #fff !important;
   }
-  
+
   .ant-select-item-option-active {
     background-color: rgba(0, 123, 255, 0.1);
   }
@@ -85,7 +83,7 @@
   display: flex;
   gap: 8px;
   flex-wrap: wrap;
-  
+
   .ant-btn {
     border-radius: 16px;
     height: 32px;
@@ -98,41 +96,41 @@
     transition: all 0.3s ease;
     display: flex;
     align-items: center;
-    
+
     &:hover {
       transform: translateY(-1px);
       box-shadow: 0 2px 8px rgba(24, 144, 255, 0.2);
       border-color: #40a9ff;
       color: #40a9ff;
     }
-    
+
     // 所有选中状态的按钮都使用统一的蓝色主题
     &.ant-btn-primary {
       background-color: #1890ff !important;
       border-color: #1890ff !important;
       color: #fff !important;
       font-weight: 500 !important;
-      
+
       &:hover {
         background-color: #40a9ff !important;
         border-color: #40a9ff !important;
         color: #fff !important;
       }
     }
-    
+
     // 全部按钮特殊样式 - 未选中时
     &:first-child:not(.ant-btn-primary) {
       background-color: #f5f5f5;
       border-color: #d9d9d9;
       color: #666;
-      
+
       &:hover {
         background-color: #e6f7ff;
         border-color: #40a9ff;
         color: #40a9ff;
       }
     }
-    
+
     // 图标样式优化
     .anticon {
       font-size: 14px;
@@ -140,27 +138,27 @@
       transition: color 0.3s ease;
       color: #666; // 默认颜色
     }
-    
+
     // 悬停时图标颜色变化
     &:hover .anticon {
       color: #40a9ff !important;
     }
-    
+
     // 选中状态时图标颜色
     &.ant-btn-primary .anticon {
       color: #fff !important;
     }
-    
+
     // 选中状态悬停时图标颜色
     &.ant-btn-primary:hover .anticon {
       color: #fff !important;
     }
-    
+
     // 全部按钮未选中时图标颜色
     &:first-child:not(.ant-btn-primary) .anticon {
       color: #666;
     }
-    
+
     // 全部按钮悬停时图标颜色
     &:first-child:not(.ant-btn-primary):hover .anticon {
       color: #40a9ff;
@@ -172,7 +170,7 @@
 @media (max-width: 768px) {
   .filter-button-group {
     gap: 6px;
-    
+
     .ant-btn {
       font-size: 12px;
       padding: 0 12px;
@@ -184,7 +182,7 @@
 @media (max-width: 480px) {
   .filter-button-group {
     gap: 4px;
-    
+
     .ant-btn {
       font-size: 11px;
       padding: 0 8px;
@@ -203,12 +201,12 @@
   align-items: center;
   justify-content: center;
   transition: all 0.3s ease;
-  
+
   &:hover {
     transform: translateY(-1px);
     box-shadow: 0 2px 8px rgba(24, 144, 255, 0.2);
   }
-  
+
   .anticon {
     font-size: 14px;
   }

+ 2 - 2
src/utils/index.ts

@@ -1,6 +1,6 @@
 // 正则表达式
 export const regex = {
-    password: /^[a-zA-Z0-9]{6,16}$/,// 密码
+    password: /^[a-zA-Z0-9@#$%^&*_\-+=]{6,16}$////^[a-zA-Z0-9]{6,16}$/,// 密码
 };
 
 // 下载文件
@@ -13,4 +13,4 @@ export const downloadFile = (blob: Blob, fileName: string) => {
     document.body.appendChild(elementA);
     elementA.click();
     document.body.removeChild(elementA);
-};
+};