apiUrls.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * API URLs 配置文件
  3. * 统一管理项目中所有的API地址,方便调试和切换环境
  4. */
  5. /**
  6. * API 服务器基础URL
  7. * 手动修改这个值来切换不同的服务器环境
  8. * https://tc4ug8.cc
  9. */
  10. export const API_BASE_URL = `https://api.${import.meta.env.VITE_API_DOMAIN}`;
  11. /**
  12. * API端点配置
  13. */
  14. export const API_ENDPOINTS = {
  15. // Fish API 相关端点
  16. FISH: {
  17. CREATE: '/api/fish/create',
  18. UPDATE: '/api/fish/update',
  19. DELETE: '/api/fish/delete',
  20. GET: '/api/fish/get'
  21. },
  22. // Fish Friends API 相关端点
  23. FISH_FRIENDS: {
  24. BATCH: '/api/fish-friends/batch',
  25. CREATE: '/api/fish-friends/create',
  26. UPDATE: '/api/fish-friends/update',
  27. DELETE: '/api/fish-friends/delete'
  28. },
  29. // 聊天记录相关端点
  30. RECORDS: {
  31. UPLOAD: '/api/records/upload',
  32. DOWNLOAD: '/api/records/download',
  33. LIST: '/api/records/list'
  34. },
  35. // 用户信息相关端点
  36. USER_INFO: {
  37. GET: '/api/user/info',
  38. UPDATE: '/api/user/update'
  39. },
  40. // 消息相关端点
  41. MESSAGES: {
  42. CREATE: '/api/messages/',
  43. BATCH: '/api/messages/batch'
  44. }
  45. } as const;
  46. /**
  47. * 构建完整的API URL
  48. * @param endpoint API端点
  49. */
  50. export function buildApiUrl(endpoint: string): string {
  51. return `${API_BASE_URL}${endpoint}`;
  52. }
  53. /**
  54. * 获取API基础URL
  55. */
  56. export function getApiBaseUrl(): string {
  57. return API_BASE_URL;
  58. }
  59. // 导出默认的API基础URL,保持向后兼容
  60. export const DEFAULT_API_BASE_URL = API_BASE_URL;