简历上传,pdf简历下载
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import axios from 'axios'
|
||||
|
||||
/** 默认 Token */
|
||||
const DEFAULT_TOKEN = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOjIwMzUyNTM4OTg5MTk4NzA0NjUsInV1SWQiOiI2MmQ5MDE2NTcyNzY0ZmNjODNjZTIyYjRjODA5ZmU5MiJ9.eE-Q5rio5J5kxkS-XPYdmk-1Tgvg6kj6NGoKWMFNU14'
|
||||
|
||||
/**
|
||||
* AI 端专用 axios 实例
|
||||
* 基础地址指向 AI 服务,超时时间较长(大模型响应慢)
|
||||
*/
|
||||
const aiService = axios.create({
|
||||
baseURL: '/ai-api',
|
||||
timeout: 300000, // 5 分钟,大模型处理可能较慢
|
||||
})
|
||||
|
||||
/**
|
||||
* 请求拦截器 — 每次请求都带上 Token header
|
||||
* 浏览器安全策略不允许 JS 直接设置 Cookie header,改用 Token header 传递
|
||||
*/
|
||||
aiService.interceptors.request.use((config) => {
|
||||
config.headers['Token'] = DEFAULT_TOKEN
|
||||
return config
|
||||
})
|
||||
|
||||
/** AI 端通用响应结构 */
|
||||
export interface AiResult<T = any> {
|
||||
code: number
|
||||
msg: string
|
||||
data: T
|
||||
timestamp: string
|
||||
uuid: string
|
||||
}
|
||||
|
||||
/** 上传简历返回数据 */
|
||||
export interface UploadResumeData {
|
||||
resumeId: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传简历文件
|
||||
* POST /resume/upload
|
||||
* @param file 简历文件(pdf / word)
|
||||
*/
|
||||
export function uploadResume(file: File) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
return aiService.post<AiResult<UploadResumeData>>('/resume/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
}).then(res => res.data)
|
||||
}
|
||||
|
||||
export default aiService
|
||||
Reference in New Issue
Block a user