Browse Source

Merge branch 'dev/newpersission' of https://git.zyuas.com/LLM/chat-admin-web into dev/permission

* 'dev/newpersission' of https://git.zyuas.com/LLM/chat-admin-web:
  增强错误处理,添加403禁止访问提示信息,并优化应用创建和编辑逻辑
  增强文件上传错误处理,添加504超时提示信息,并优化相关样式
Ryuiso 4 ngày trước cách đây
mục cha
commit
7f5f4c0f83

+ 7 - 1
src/apis/api.ts

@@ -44,9 +44,15 @@ axiosInstance.interceptors.response.use(
     },
     (error) => {// 错误信息
         // HTTP状态码
-        const statusCode = error.response.status;
+        const statusCode = error.response?.status;
         if (String(error).includes('timeout')) {
             message.error('请求超时');
+        } else if (statusCode === 504) {
+            // 504网关超时,通常是上传文件超时
+            message.error('请求超时,请稍后重试');
+        } else if (statusCode === 403) {
+            // 403禁止访问,通常是防火墙拦截或内容违规
+            message.error('您提交的信息内容非法,访问已被防火墙拒绝');
         } else {
             if (statusCode < 500) {
                 message.error('请求失败');

+ 18 - 3
src/pages/deepseek/knowledgeLib/detail/drawerIndex.tsx

@@ -141,7 +141,17 @@ const KnowledgeLibInfo : React.FC<Props> = ({drawerItem}:Props) => {
         setUploadLoading( false );
       } else if ( status === 'error' ) {
         console.log( status, 'status--error' );
-        message.error( `${ info.file.name } file upload failed.` );
+        // 检查是否是504超时错误
+        const response = info.file.response;
+        const error = info.file.error;
+        
+        if (response && (String(response).includes('504') || String(response).includes('Gateway Time-out'))) {
+          message.error( '上传文件超时,请修改文件后再上传' );
+        } else if (error && (String(error).includes('timeout') || String(error).includes('504'))) {
+          message.error( '上传文件超时,请修改文件后再上传' );
+        } else {
+          message.error( `${ info.file.name } 文件上传失败` );
+        }
         setUploadLoading( false );
       }
     },
@@ -170,8 +180,13 @@ const KnowledgeLibInfo : React.FC<Props> = ({drawerItem}:Props) => {
 
       message.success( `${ fileList.length }个文件上传成功` );
       setFileList( [] );
-    } catch ( err ) {
-      message.error( '上传失败' );
+    } catch ( err: any ) {
+      // 检查是否是504超时错误
+      if (err?.response?.status === 504 || err?.code === 'ECONNABORTED' || String(err).includes('timeout')) {
+        message.error( '上传文件超时,请修改文件后再上传' );
+      } else {
+        message.error( '上传失败' );
+      }
     } finally {
       setUploading( false );
     }

+ 18 - 3
src/pages/deepseek/knowledgeLib/detail/index.tsx

@@ -141,7 +141,17 @@ const KnowledgeLibInfo : React.FC = () => {
         setUploadLoading( false );
       } else if ( status === 'error' ) {
         console.log( status, 'status--error' );
-        message.error( `${ info.file.name } file upload failed.` );
+        // 检查是否是504超时错误
+        const response = info.file.response;
+        const error = info.file.error;
+        
+        if (response && (String(response).includes('504') || String(response).includes('Gateway Time-out'))) {
+          message.error( '上传文件超时,请修改文件后再上传' );
+        } else if (error && (String(error).includes('timeout') || String(error).includes('504'))) {
+          message.error( '上传文件超时,请修改文件后再上传' );
+        } else {
+          message.error( `${ info.file.name } 文件上传失败` );
+        }
         setUploadLoading( false );
       }
     },
@@ -170,8 +180,13 @@ const KnowledgeLibInfo : React.FC = () => {
 
       message.success( `${ fileList.length }个文件上传成功` );
       setFileList( [] );
-    } catch ( err ) {
-      message.error( '上传失败' );
+    } catch ( err: any ) {
+      // 检查是否是504超时错误
+      if (err?.response?.status === 504 || err?.code === 'ECONNABORTED' || String(err).includes('timeout')) {
+        message.error( '上传文件超时,请修改文件后再上传' );
+      } else {
+        message.error( '上传失败' );
+      }
     } finally {
       setUploading( false );
     }

+ 7 - 1
src/pages/deepseek/knowledgeLib/slice/detail/imgPre.tsx

@@ -360,7 +360,13 @@ const SliceDetail: React.FC = () => {
                                         message.error(msg);
                                     }
                                 } else if (file.status === 'error') {// 上传失败
-                                    message.error('上传失败');
+                                    // 检查是否是504超时错误
+                                    const response = file.response;
+                                    if (response?.status === 504 || file.error?.includes('timeout')) {
+                                        message.error('上传图片超时,请修改图片后再上传');
+                                    } else {
+                                        message.error('上传失败');
+                                    }
                                 }
                             }}
                         >

+ 7 - 1
src/pages/deepseek/knowledgeLib/slice/detail/index.tsx

@@ -207,7 +207,13 @@ const SliceDetail: React.FC = () => {
                                         message.error(msg);
                                     }
                                 } else if (file.status === 'error') {// 上传失败
-                                    message.error('上传失败');
+                                    // 检查是否是504超时错误
+                                    const response = file.response;
+                                    if (response?.status === 504 || file.error?.includes('timeout')) {
+                                        message.error('上传图片超时,请修改图片后再上传');
+                                    } else {
+                                        message.error('上传失败');
+                                    }
                                 }
                             }}
                         >

+ 27 - 17
src/pages/deepseek/questionAnswer/info/index.tsx

@@ -601,23 +601,33 @@ const QuestionAnswerInfo: React.FC = () => {
             // console.log(info, 'info data----');
             const id = location?.state?.id;
             let res = null;
-            if (id) {
-                // 编辑应用
-                res = await apis.modifyTakaiApplicationApi(id, info);
-            } else {
-                // 创建应用
-                res = await await apis.createTakaiApplicationApi(info);
-            }
-            console.log(res, 'create or modify');
-            if (res.data === 9) {
-                message.error('没有配置审核人,请联系管理员');
-            } else if (res.data === 1) {
-                message.success('操作成功')
-            } else {
-                message.error('操作失败');
-            }
-            if (type === 'SUBMIT') {
-                router.navigate({ pathname: '/deepseek/questionAnswer' });
+            try {
+                if (id) {
+                    // 编辑应用
+                    res = await apis.modifyTakaiApplicationApi(id, info);
+                } else {
+                    // 创建应用
+                    res = await apis.createTakaiApplicationApi(info);
+                }
+                console.log(res, 'create or modify');
+                if (res.data === 9) {
+                    message.error('没有配置审核人,请联系管理员');
+                } else if (res.data === 1) {
+                    message.success('操作成功')
+                    if (type === 'SUBMIT') {
+                        router.navigate({ pathname: '/deepseek/questionAnswer' });
+                    }
+                } else {
+                    message.error('操作失败');
+                }
+            } catch (error: any) {
+                // 检查是否是403错误
+                if (error?.response?.status === 403) {
+                    message.error('您提交的信息内容非法,访问已被防火墙拒绝');
+                } else {
+                    console.error('提交失败:', error);
+                    // 其他错误会由axios拦截器处理,这里不再重复显示错误信息
+                }
             }
         }).catch((error) => {
             console.error(error);

+ 116 - 0
src/pages/deepseek/questionAnswer/list/style.less

@@ -211,3 +211,119 @@
     font-size: 14px;
   }
 }
+
+// 搜索展开组件样式
+.search-expand-wrapper {
+  position: relative;
+  display: flex;
+  align-items: center;
+  height: 32px;
+  transition: all 0.3s ease;
+}
+
+.search-input-container {
+  position: relative;
+  overflow: hidden;
+  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
+  opacity: 0;
+  width: 0;
+  margin-right: 0;
+  transform: translateX(-10px);
+  white-space: nowrap;
+  
+  &.expanded {
+    opacity: 1;
+    width: 200px;
+    margin-right: 8px;
+    transform: translateX(0);
+  }
+
+  .search-input {
+    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
+    border-radius: 16px;
+    height: 32px;
+    width: 100%;
+    display: flex;
+    align-items: center;
+    
+    .ant-input {
+      border-radius: 16px;
+      transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
+      height: 32px;
+      line-height: 32px;
+      padding: 4px 11px;
+      display: flex;
+      align-items: center;
+    }
+    
+    .ant-input-affix-wrapper {
+      border-radius: 16px;
+      transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
+      height: 32px;
+      display: flex;
+      align-items: center;
+      padding: 4px 11px;
+      
+      .ant-input {
+        height: auto;
+        line-height: 1.5715;
+        padding: 0;
+        border: none;
+        box-shadow: none;
+      }
+      
+      &:hover {
+        border-color: #40a9ff;
+      }
+      
+      &:focus,
+      &.ant-input-affix-wrapper-focused {
+        border-color: #1890ff;
+        box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
+      }
+    }
+    
+    .ant-input-prefix {
+      transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
+      color: #999;
+      display: flex;
+      align-items: center;
+      margin-right: 8px;
+    }
+  }
+}
+
+.search-button {
+  flex-shrink: 0;
+  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
+  z-index: 1;
+  
+  &:hover {
+    transform: scale(1.05);
+    box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
+  }
+}
+
+// 展开动画优化 - 使用hover触发
+.search-expand-wrapper:hover {
+  .search-input-container {
+    opacity: 1;
+    width: 200px;
+    margin-right: 8px;
+    transform: translateX(0);
+  }
+  
+  .search-button {
+    transform: scale(1.05);
+    box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
+  }
+}
+
+// 当输入框获得焦点时保持展开状态
+.search-input-container.expanded,
+.search-expand-wrapper:focus-within .search-input-container {
+  opacity: 1 !important;
+  width: 200px !important;
+  margin-right: 8px !important;
+  transform: translateX(0) !important;
+}