feat(upload): 增加文件上传功能并优化 API 基础 URL 获取

- 在 nginx 配置中添加 client_max_body_size 指令,支持大文件上传
- 优化 getAPIBaseUrl 函数,确保在没有设置 baseURL 时返回空字符串
- 在苹果账户信息页面的文件上传组件中使用动态 API 基础 URL
- 在上传请求中添加 tokenFrom 头,用于区分 token 来源
This commit is contained in:
danial
2025-02-04 21:17:10 +08:00
parent 559135a4a0
commit 5c1df260b5
3 changed files with 9 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
server {
listen 12400;
server_name localhost;
client_max_body_size 100M; # 全局设置,影响所有的 server 块
location / {
root /app;

View File

@@ -14,8 +14,7 @@ export function handleDownLoadFile(response: Blob, fileName: string) {
}
export function getAPIBaseUrl() {
console.log(axios.defaults.baseURL);
return axios.defaults.baseURL;
return axios.defaults.baseURL ? axios.defaults.baseURL : '';
}
export default null;

View File

@@ -62,10 +62,13 @@
</a-button>
<a-upload
size="small"
action="/api/cardInfo/AppleCard/account/batchAdd"
:action="`${getAPIBaseUrl()}/api/cardInfo/AppleCard/account/batchAdd`"
:limit="1"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
:headers="{ Authorization: `Bearer ${getToken()}` }"
:headers="{
Authorization: `Bearer ${getToken()}`,
tokenFrom: getTokenFrom()
}"
@success="uploadSucceed"
/>
</a-space>
@@ -174,7 +177,8 @@ import {
downloadAppleAccountTemplteAPI
} from '@/api/apple-card-info';
import { FileItem, Notification, TableColumnData } from '@arco-design/web-vue';
import { getToken, checkTokenFromIframe } from '@/utils/auth';
import { getToken, checkTokenFromIframe, getTokenFrom } from '@/utils/auth';
import { getAPIBaseUrl } from '@/api/utils';
import AddModal from './components/add-modal.vue';
import AccountDetail from './components/detail.vue';
import { apiClient } from '@/api';