/** * API 路径常量 */ export const API_PATHS = { // 认证相关 AUTH: { LOGIN: '/api/auth/login', REGISTER: '/api/auth/register', REFRESH: '/api/auth/refresh', LOGOUT: '/api/auth/logout', ME: '/api/auth/me', PASSWORD: '/api/auth/password', PROFILE: '/api/auth/profile', }, // 用户管理 USERS: { LIST: '/api/users', CREATE: '/api/users', UPDATE: (id: number) => `/api/users/${id}`, DELETE: (id: number) => `/api/users/${id}`, }, // 平台账号 ACCOUNTS: { LIST: '/api/accounts', CREATE: '/api/accounts', UPDATE: (id: number) => `/api/accounts/${id}`, DELETE: (id: number) => `/api/accounts/${id}`, REFRESH: (id: number) => `/api/accounts/${id}/refresh`, QR_CODE: '/api/accounts/qrcode', QR_STATUS: '/api/accounts/qrcode/status', }, // 账号分组 ACCOUNT_GROUPS: { LIST: '/api/account-groups', CREATE: '/api/account-groups', UPDATE: (id: number) => `/api/account-groups/${id}`, DELETE: (id: number) => `/api/account-groups/${id}`, }, // 发布任务 PUBLISH: { LIST: '/api/publish', CREATE: '/api/publish', DETAIL: (id: number) => `/api/publish/${id}`, CANCEL: (id: number) => `/api/publish/${id}/cancel`, RETRY: (id: number) => `/api/publish/${id}/retry`, DELETE: (id: number) => `/api/publish/${id}`, }, // 作品管理 WORKS: { LIST: '/api/works', DELETE_PLATFORM: (id: number) => `/api/works/${id}/delete-platform`, }, // 评论管理 COMMENTS: { LIST: '/api/comments', STATS: '/api/comments/stats', MARK_READ: '/api/comments/read', REPLY: '/api/comments/reply', BATCH_REPLY: '/api/comments/batch-reply', }, // 数据分析 ANALYTICS: { SUMMARY: '/api/analytics/summary', TREND: '/api/analytics/trend', PLATFORMS: '/api/analytics/platforms', RANKING: '/api/analytics/ranking', EXPORT: '/api/analytics/export', }, // 定时任务 TASKS: { LIST: '/api/tasks', CREATE: '/api/tasks', UPDATE: (id: number) => `/api/tasks/${id}`, DELETE: (id: number) => `/api/tasks/${id}`, LOGS: (id: number) => `/api/tasks/${id}/logs`, }, // 系统 SYSTEM: { HEALTH: '/api/health', CONFIG: '/api/system/config', }, // 文件上传 UPLOAD: { VIDEO: '/api/upload/video', IMAGE: '/api/upload/image', }, } as const; /** * WebSocket 事件 */ export const WS_EVENTS = { // 连接 CONNECT: 'connect', DISCONNECT: 'disconnect', ERROR: 'error', // 认证 AUTH: 'auth', AUTH_SUCCESS: 'auth:success', AUTH_ERROR: 'auth:error', // 账号 ACCOUNT_ADDED: 'account:added', ACCOUNT_UPDATED: 'account:updated', ACCOUNT_DELETED: 'account:deleted', // 任务 TASK_CREATED: 'task:created', TASK_STATUS_CHANGED: 'task:status_changed', TASK_PROGRESS: 'task:progress', // 发布 PUBLISH_PROGRESS: 'publish:progress', // 验证码 CAPTCHA_REQUIRED: 'captcha:required', CAPTCHA_SUBMIT: 'captcha:submit', CAPTCHA_RESULT: 'captcha:result', // 登录(AI 辅助) LOGIN_AI_ANALYSIS: 'login:aiAnalysis', LOGIN_VERIFICATION_NEEDED: 'login:verificationNeeded', LOGIN_NAVIGATION_SUGGESTION: 'login:navigationSuggestion', LOGIN_RESULT: 'login:result', // 评论 COMMENT_NEW: 'comment:new', COMMENT_REPLIED: 'comment:replied', COMMENT_SYNCED: 'comment:synced', COMMENT_SYNC_STARTED: 'comment:sync_started', COMMENT_SYNC_PROGRESS: 'comment:sync_progress', COMMENT_SYNC_FAILED: 'comment:sync_failed', // 数据 ANALYTICS_UPDATED: 'analytics:updated', // 心跳 PING: 'ping', PONG: 'pong', } as const; /** * 错误代码 */ export const ERROR_CODES = { // 通用 UNKNOWN: 'UNKNOWN_ERROR', VALIDATION: 'VALIDATION_ERROR', NOT_FOUND: 'NOT_FOUND', // 认证 UNAUTHORIZED: 'UNAUTHORIZED', TOKEN_EXPIRED: 'TOKEN_EXPIRED', TOKEN_INVALID: 'TOKEN_INVALID', FORBIDDEN: 'FORBIDDEN', // 用户 USER_EXISTS: 'USER_EXISTS', USER_NOT_FOUND: 'USER_NOT_FOUND', INVALID_CREDENTIALS: 'INVALID_CREDENTIALS', REGISTRATION_DISABLED: 'REGISTRATION_DISABLED', // 账号 ACCOUNT_EXISTS: 'ACCOUNT_EXISTS', ACCOUNT_NOT_FOUND: 'ACCOUNT_NOT_FOUND', COOKIE_INVALID: 'COOKIE_INVALID', COOKIE_EXPIRED: 'COOKIE_EXPIRED', // 发布 PUBLISH_FAILED: 'PUBLISH_FAILED', VIDEO_TOO_LARGE: 'VIDEO_TOO_LARGE', VIDEO_FORMAT_UNSUPPORTED: 'VIDEO_FORMAT_UNSUPPORTED', // 评论 COMMENT_NOT_FOUND: 'COMMENT_NOT_FOUND', REPLY_FAILED: 'REPLY_FAILED', // 服务 SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE', } as const; /** * HTTP 状态码 */ export const HTTP_STATUS = { OK: 200, CREATED: 201, NO_CONTENT: 204, BAD_REQUEST: 400, UNAUTHORIZED: 401, FORBIDDEN: 403, NOT_FOUND: 404, CONFLICT: 409, UNPROCESSABLE_ENTITY: 422, INTERNAL_SERVER_ERROR: 500, SERVICE_UNAVAILABLE: 503, } as const;