From fa29f2aa201e69592f82aed156792ae1e9cbd3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E9=94=90=E6=B3=A2?= <10549902+zhuangruibo@user.noreply.gitee.com> Date: Fri, 26 Jun 2026 10:58:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=92bug=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ng/3/nginx.conf | 1 + .../src/http/http.js | 5 ++++- .../src/util/fileUpload.js | 22 ++++--------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/ng/3/nginx.conf b/ng/3/nginx.conf index 90698a02..5b42620a 100644 --- a/ng/3/nginx.conf +++ b/ng/3/nginx.conf @@ -19,6 +19,7 @@ http { default_type application/octet-stream; add_header X-Frame-Options SAMEORIGIN; server_tokens off; + client_max_body_size 50M; # 定义后端集群 upstream java_cluster { diff --git a/zdxt-web-client/zdxt-efcode-enterprise-app/src/http/http.js b/zdxt-web-client/zdxt-efcode-enterprise-app/src/http/http.js index 2216d605..f18a5bde 100644 --- a/zdxt-web-client/zdxt-efcode-enterprise-app/src/http/http.js +++ b/zdxt-web-client/zdxt-efcode-enterprise-app/src/http/http.js @@ -17,7 +17,10 @@ const router = $globalRouter; //请求拦截器添加head http.interceptors.request.use( config => { - if(!config.headers['Content-Type']){ + // FormData 必须由浏览器/axios 自动设置 multipart boundary + if (config.data instanceof FormData) { + delete config.headers['Content-Type']; + } else if(!config.headers['Content-Type']){ config.headers['Content-Type'] = 'application/json' } const token = $globalStore.useCommon.token; diff --git a/zdxt-web-client/zdxt-efcode-enterprise-app/src/util/fileUpload.js b/zdxt-web-client/zdxt-efcode-enterprise-app/src/util/fileUpload.js index 34fa55ce..522a0f2e 100644 --- a/zdxt-web-client/zdxt-efcode-enterprise-app/src/util/fileUpload.js +++ b/zdxt-web-client/zdxt-efcode-enterprise-app/src/util/fileUpload.js @@ -1,25 +1,12 @@ -import {_form, _post} from '../http/index' -import { baseUrl } from "../config/env"; -import axios from 'axios'; -const http = axios.create({ - traditional: true, - contentType : "application/json", - timeout: 1000 * 500000, // 1 秒 -}); -const uploadFile = (files,callback) => { +import http from '../http/http'; + +const uploadFile = (files, callback) => { files.status = "uploading"; files.message = "上传中..."; // 需要使用 FormData 进行文件上传 let form = new FormData(); form.append("file", files.file); - axios({ - method: "post", - url: baseUrl+ "/app-enf/common/file/upload", - data: form, - headers: { - 'Content-Type': 'multipart/form-data' - } - }) + http.post("/app-enf/common/file/upload", form) .then((res) => { files.status = "done"; files.message = "上传成功"; @@ -30,7 +17,6 @@ const uploadFile = (files,callback) => { files.message = "上传失败"; console.log(err); }); - } const nameCorrect=(name)=>{