feat(reset): 以构造器模式重构

- 加了大文件传输自定义分片协议

BREAKING CHANGES: 0.1.0(latest)
This commit is contained in:
tobegold574
2025-11-30 20:27:53 +08:00
parent c5853847ae
commit 382e3aff21
82 changed files with 1421 additions and 7010 deletions

View File

@@ -1,30 +1,99 @@
import type { User } from './base';
import type { UserProfile } from './base';
import type { PaginationRequest } from '../common';
// 获取热门作者请求接口
export interface GetHotAuthorsRequest {
limit?: number; // 每页数量
days?: number; // 统计天数默认30天
// 获取当前用户个人资料相关接口不需要参数所以没有request
export interface GetMyProfileResponse {
profile: UserProfile;
}
// 获取他人档案相关接口
export interface GetUserProfileRequest {
userId: string;
}
export interface GetUserProfileResponse {
profile: UserProfile;
}
// 热门作者相关接口
export interface GetHotAuthorsRequest extends PaginationRequest {
// 已继承limit字段page字段默认不用了
}
// 获取热门作者响应接口
export interface GetHotAuthorsResponse {
// 其实应该用profile返回的
data: User[]; // 数据列表
data: UserProfile[]; // 数据列表
total: number; // 总数
}
// 获取作者榜单请求接口
export interface GetAuthorRankingRequest {
limit?: number; // 每页数量
period?: 'day' | 'week' | 'month'; // 统计周期
type?: 'posts' | 'views' | 'likes'; // 排序类型
// 登录注册相关接口
export interface LoginRequest {
username: string;
password: string;
}
export interface LoginResponse {
user: UserProfile;
sessionId: string;
}
export interface RegisterRequest {
username: string;
password: string;
}
export interface RegisterResponse {
user: UserProfile;
sessionId: string;
}
export interface ChangePasswordRequest {
oldPassword: string;
newPassword: string;
}
export interface ChangePasswordResponse {
user: UserProfile;
sessionId: string;
}
// 通知相关接口
export type NotificationType = 'like' | 'comment' | 'follow' | 'mention';
export interface UserNotification {
id: string;
type: NotificationType;
content: string;
isRead: boolean;
createdAt: Date;
}
// 个人资料更新相关接口
export interface UserProfileUpdateRequest {
avatar?: string;
introduction?: string;
level?: string;
}
export interface UserProfileUpdateResponse {
profile: UserProfile;
}
// 作者榜单相关接口
export interface GetAuthorRankingRequest extends PaginationRequest {
// 已继承limit字段page字段默认不用了
}
// 获取作者榜单响应接口
export interface GetAuthorRankingResponse {
data: User[]; // 数据列表
data: UserProfile[]; // 数据列表
total: number; // 总数
// 其实冗余了
period: 'day' | 'week' | 'month'; // 统计周期
type: 'posts' | 'views' | 'likes'; // 排序类型
}
// 用户搜索相关接口
export interface UserSearchRequest {
keyword: string;
}
export interface UserSearchResponse {
users: Array<UserProfile>;
total: number;
}

View File

@@ -1,53 +1,14 @@
import { NotificationType } from './enum';
// 最小用户信息
export interface User{
id: string;
username: string;
}
// 认证
export interface LoginRequest{
username: string;
password: string;
}
export interface LoginResponse{
export interface UserProfile{
user: User;
sessionId: string;
avatar: string;
introduction: string;
level: string;
}
export interface RegisterRequest {
username: string;
email: string;
password: string;
}
export interface RegisterResponse {
user: User;
sessionId: string;
}
export interface ChangePasswordRequest { // 暂时用不到
oldPassword: string;
newPassword: string;
}
// 目前只用得到session
// export interface RefreshTokenRequest {
// sessionId: string;
// }
// export interface RefreshTokenResponse {
// sessionId: string;
// }
// 用户通知(暂时用不到)
export interface UserNotification {
id: string;
userId: string;
type: NotificationType;
content: string;
isRead: boolean;
createdAt: Date;
}

View File

@@ -1,8 +0,0 @@
// 通知类型枚举
export enum NotificationType {
LIKE = 'like',
COMMENT = 'comment',
FOLLOW = 'follow',
MENTION = 'mention'
}

View File

@@ -1,5 +1,2 @@
export * from './base';
export * from './profile';
export * from './search';
export * from './enum';
export * from './api';
export * from './api';

View File

@@ -1,38 +0,0 @@
import type { User } from './base';
// 用户档案以及更新
export interface UserProfile{
user: User;
avatar: string;
introduction: string;
level: string;
}
export interface UserProfileUpdateRequest {
avatar?: string;
introduction?: string;
level?: string;
}
export interface UserProfileUpdateResponse {
profile: UserProfile;
}
// 用户关系
export interface UserRelation {
// 当前用户的id
id: string;
followerId: string[];
followingId: string[];
}
// 当前用户的id由cookie带上
export interface UserFollowRequest {
userId: string;
}
export interface UserFollowResponse {
success: boolean;
}

View File

@@ -1,13 +0,0 @@
import type { UserProfile } from './profile';
// 用户搜索结果
export interface UserSearchRequest {
keyword: string;
}
export interface UserSearchResponse {
// 这里逻辑是对的(可惜暂时不打算做)
users: Array<UserProfile>
total: number;
}