platform-vue/docs/文件上传超时配置.md

63 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 文件上传超时配置说明
## 修改内容
移除了文件上传的超时限制,允许大文件上传完成而不会因超时中断。
## 修改位置
`platform/src/api/file.js` 中的 `uploadFile` 函数
## 修改详情
### 修改前
```javascript
const config = {
url: "/platform/uploadfile",
method: "post",
data: formData,
timeout: 2 * 60 * 60 * 1000, // 2小时超时
};
```
### 修改后
```javascript
const config = {
url: "/platform/uploadfile",
method: "post",
data: formData,
timeout: 0, // 不设置超时时间,等待文件上传完毕
};
```
## 影响范围
此修改影响所有使用 `uploadFile` 函数的文件上传功能,包括但不限于:
- 软件升级安装包上传 (`platform/src/views/platform/softwareupgrade/components/edit.vue`)
- 文件管理器上传 (`platform/src/views/system/fileManager/index.vue`)
- 其他调用 `uploadFile` API 的组件
## 技术说明
- `timeout: 0` 在 axios 中表示不设置超时限制
- 上传进度仍然会正常显示(通过 `onUploadProgress` 回调)
- 用户可以随时取消上传操作
- 适用于大文件(如软件安装包)的上传场景
## 注意事项
1. 虽然客户端不设置超时,但服务器端可能仍有超时限制
2. 建议在服务器端Go 后端)也检查并调整相应的超时配置
3. 对于超大文件,建议考虑使用分片上传或断点续传机制
## 相关文件
- `platform/src/api/file.js` - 文件上传 API
- `platform/src/utils/request.js` - axios 请求配置(普通接口默认 5 分钟超时)
- `platform/src/views/platform/softwareupgrade/components/edit.vue` - 软件升级上传组件
## 修改日期
2026-04-09