问题:前端API包含/api/v1导致路径重复
- 前端: /fund/sys/api/v1/auth/login
- 网关StripPrefix=2后: /api/v1/auth/login
- PrefixPath=/api/v1后: /api/v1/api/v1/auth/login ❌
修复:移除前端API中的/api/v1前缀
fund-admin修改:
- auth.ts: /sys/auth/login
- user.ts: /sys/sys/user/page
- tenant.ts: /sys/sys/tenant/page
- customer.ts: /cust/cust/customer/page
- project.ts: /proj/proj/project/page
- expense.ts: /exp/exp/expense/page
- receivable.ts: /receipt/receipt/receivable/page
- report.ts: /report/report/dashboard/stats
- file.ts: /file/file/upload
- menu.ts: /sys/sys/menu/tree
- role.ts: /sys/sys/role/page
- dept.ts: /sys/sys/dept/list
- config.ts: /sys/sys/config/page
- FileUpload组件: /fund/file/file/upload
fund-mobile修改:
- index.ts: 统一移除/api/v1,添加模块名重复
路由流程示例:
- 前端请求: /fund/sys/auth/login
- StripPrefix=2: /auth/login
- PrefixPath=/api/v1: /api/v1/auth/login ✓
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { request } from './request'
|
|
|
|
// 文件上传
|
|
export function uploadFile(file: File, businessType?: string, businessId?: number, description?: string) {
|
|
const formData = new FormData()
|
|
formData.append('file', file)
|
|
if (businessType) formData.append('businessType', businessType)
|
|
if (businessId) formData.append('businessId', String(businessId))
|
|
if (description) formData.append('description', description)
|
|
|
|
return request.post('/file/file/upload', formData, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data'
|
|
}
|
|
})
|
|
}
|
|
|
|
// 获取文件列表
|
|
export function getFileList(params: { pageNum: number; pageSize: number; businessType?: string; businessId?: number; fileType?: string }) {
|
|
return request.get('/file/file/page', { params })
|
|
}
|
|
|
|
// 根据业务查询文件
|
|
export function getFilesByBusiness(businessType: string, businessId: number) {
|
|
return request.get('/file/file/list', { params: { businessType, businessId } })
|
|
}
|
|
|
|
// 获取文件详情
|
|
export function getFileById(id: number) {
|
|
return request.get(`/file/file/${id}`)
|
|
}
|
|
|
|
// 删除文件
|
|
export function deleteFile(id: number) {
|
|
return request.delete(`/file/file/${id}`)
|
|
}
|
|
|
|
// 获取文件下载URL
|
|
export function getFileDownloadUrl(filePath: string) {
|
|
return `/file/file/download/${filePath}`
|
|
}
|