import axios from 'axios' // API基础配置 const API_BASE_URL = 'http://192.168.1.52:8001' // 创建axios实例 const apiClient = axios.create({ baseURL: API_BASE_URL, timeout: 30000, headers: { 'Content-Type': 'application/json', }, }) // API 端点表。约定:路径里有 id 时用函数(参数名 = 模板中同名的字段),纯 // 字串的保持字串。spec 0004 之后,task / story / image 这些之前缺失的端点 // 也补齐了。注意:这不是真理之源——服务层 (`taskService.js` 等) 直接硬编 // 码路径调用;从这里改不会影响现有调用。先把这条目修对,主要是给后续重构 // 提供可参考的对应表。 export const apiEndpoints = { // 认证相关 AUTH: { LOGIN: '/api/token/', REFRESH: '/api/token/refresh/', }, // 学生相关 STUDENTS: { LIST: '/api/students/', CREATE: '/api/students/', UPDATE: (studentId) => `/api/students/${studentId}/`, DELETE: (studentId) => `/api/students/${studentId}/`, }, // 学科相关 SUBJECTS: { LIST: '/api/subjects/', CREATE: '/api/subjects/', UPDATE: (subjectId) => `/api/subjects/${subjectId}/`, DELETE: (subjectId) => `/api/subjects/${subjectId}/`, }, // 学期相关 TERMS: { LIST: '/api/terms/', CREATE: '/api/terms/', UPDATE: (termId) => `/api/terms/${termId}/`, DELETE: (termId) => `/api/terms/${termId}/`, }, // 系列任务(Story) STORIES: { LIST: '/api/stories/', CREATE: '/api/stories/', UPDATE: (storyId) => `/api/stories/${storyId}/`, DELETE: (storyId) => `/api/stories/${storyId}/`, }, // 作业任务(spec 0004:图片迁出到子资源) TASKS: { LIST: '/api/tasks/', CREATE: '/api/tasks/', UPDATE: (taskId) => `/api/tasks/${taskId}/`, DELETE: (taskId) => `/api/tasks/${taskId}/`, IMAGES: { LIST: (taskId) => `/api/tasks/${taskId}/images/`, CREATE: (taskId) => `/api/tasks/${taskId}/images/`, DELETE: (taskId, imageId) => `/api/tasks/${taskId}/images/${imageId}/`, CONTENT: (taskId, imageId) => `/api/tasks/${taskId}/images/${imageId}/content/`, }, }, } export default apiClient