Files
knowai/api/common.ts
tobegold574 382e3aff21 feat(reset): 以构造器模式重构
- 加了大文件传输自定义分片协议

BREAKING CHANGES: 0.1.0(latest)
2025-11-30 20:27:53 +08:00

50 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ApiError错误接口
export interface ApiError {
status: number; // 状态码来自response的status
statusText: string; // 状态文本来自response的msg
code: string; // 错误码(字符串)
message: string; // 报错信息(字符串)
// 没有别的细节了,错误码直接对照常量映射
}
// 接口路径
export const API_ENDPOINTS = {
// 用户相关(自己和别人分开)
// 视图类
ME_PROFILE: '/me/profile',
USERS_PROFILES: '/users/profiles',
SOMEBODY_PROFILE: '/users/:userId/profile',
// 会话相关但是用的接口是在user文件夹定义的
AUTH_LOGIN: '/auth/login',
AUTH_REGISTER: '/auth/register',
AUTH_CHANGE_PASSWORD: '/auth/changePassword',
USER_CURRENT: '/auth/me', // 只用于校验会话状态
USER_PROFILE_UPDATE: '/me/profile/update',
USER_SEARCH: '/users/search',
USER_HOT_AUTHORS: '/users/hot',
USER_RANKING: '/users/ranking',
USER_NOTIFICATIONS: '/me/notifications',
// 聊天相关(这个也肯定只有自己的,就不写/me了
CHATS: '/chats', // GET 列表,搜索等等
CHAT_ONE_MESSAGES: '/chats/:chatId/messages', // GET 单条消息 / POST 新建消息等
// 模型相关(公共接口)
MODELS: '/models', // GET 列表(列表里是模型的完整信息)
MODEL_ONE_LIKES: '/models/:modelId/likes', // 操作
MODEL_ONE_COMMENTS: '/models/:modelId/comments', // 操作
// 帖子相关
POSTS: '/posts', // GET 列表
POST_ONE_LIKES: '/posts/:postId/likes', // 操作
POST_ONE_STARS: '/posts/:postId/stars', // 收藏数
POST_ONE_COMMENTS: '/posts/:postId/comments', // 操作
// 上传相关
UPLOAD_CHUNK: '/upload/chunk',
MERGE_CHUNKS: '/upload/merge',
CHECK_UPLOAD_STATUS: '/upload/status'
} as const;