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,57 +1,26 @@
import type { PaginationRequest, PaginationResponse } from 'types/common';
import type { ModelComment, AIModel } from './base';
import type { CommentSortType } from './enum';
// AI模型榜单项接口
export interface AIModelRankingItem {
model: AIModel;
rank: number;
change?: 'up' | 'down' | 'same'; // 排名变化,未来扩展
}
// 获取AI模型广场数据请求接口
export interface GetAIPlazaRequest {
// 模型卡片数据是静态配置(手动维护)的,不需要分页参数
}
// 获取AI模型广场数据响应接口
export interface GetAIPlazaResponse {
models: AIModel[]; // 模型卡片列表,由管理员预定义
hotRankings: AIModelRankingItem[]; // 热评模型榜单
clickRankings: AIModelRankingItem[]; // 点击排行榜
}
// 获取模型详情请求接口
export interface GetModelDetailRequest {
modelId: string;
page?: number; // 评论页码
limit?: number; // 每页评论数量
sortBy?: CommentSortType; // 评论排序方式,未来扩展功能
export interface GetModelsRequest extends PaginationRequest {
// 够了
}
// 获取模型详情响应接口
export interface GetModelDetailResponse {
model: AIModel;
comments: ModelComment[]; // 使用新的ModelComment类型已经是数组
totalComments: number;
hasMoreComments: boolean; // 是否还有更多评论,支持无限滚动加载
export interface GetModelsResponse extends PaginationResponse<AIModel> {
// 够了
}
// 批量获取模型评论请求接口
export interface GetModelCommentsRequest {
export interface GetModelCommentsRequest extends PaginationRequest {
modelId: string;
page?: number; // 页码
limit?: number; // 每页评论数量
sortBy?: CommentSortType; // 评论排序方式
parentId?: string; // 父评论ID用于获取回复
parentId?: string; // 父评论ID
}
// 批量获取模型评论响应接口
export interface GetModelCommentsResponse {
comments: ModelComment[]; // 评论列表
total: number; // 总数
page: number; // 当前页码
limit: number; // 每页数量
hasMore: boolean; // 是否有更多数据
export interface GetModelCommentsResponse extends PaginationResponse<ModelComment> {
// 够了
}
// 发表模型评论请求接口
@@ -63,98 +32,19 @@ export interface CreateModelCommentRequest {
// 发表模型评论响应接口
export interface CreateModelCommentResponse {
comment: ModelComment; // 使用新的ModelComment类型
}
// 点赞模型评论请求接口
export interface LikeModelCommentRequest {
commentId: string;
}
// 点赞模型评论响应接口
export interface LikeModelCommentResponse {
success: boolean;
}
// 记录模型点击请求接口
export interface RecordModelClickRequest {
// 点赞模型请求接口
export interface LikeModelRequest {
modelId: string;
}
// 记录模型点击响应接口
export interface RecordModelClickResponse {
success: boolean;
clickCount: number; // 更新后的总点击数
}
// 后面的都暂时不考虑
// 删除模型评论请求接口
export interface DeleteModelCommentRequest {
commentId: string;
}
// 删除模型评论响应接口
export interface DeleteModelCommentResponse {
// 点赞模型响应接口
export interface LikeModelResponse {
success: boolean;
}
// 更新模型评论请求接口
export interface UpdateModelCommentRequest {
commentId: string;
content?: string; // 更新内容
}
// 更新模型评论响应接口
export interface UpdateModelCommentResponse {
success: boolean;
comment: ModelComment; // 返回更新后的评论
}
// 批量点赞模型评论请求接口
export interface BatchLikeModelCommentsRequest {
commentIds: string[]; // 评论ID列表
}
// 批量点赞模型评论响应接口
export interface BatchLikeModelCommentsResponse {
results: Array<{
commentId: string;
success: boolean;
comment?: ModelComment; // 成功时返回更新后的评论
error?: string; // 失败时的错误信息
}>;
}
// 批量删除模型评论请求接口
export interface BatchDeleteModelCommentsRequest {
commentIds: string[]; // 评论ID列表
}
// 批量删除模型评论响应接口
export interface BatchDeleteModelCommentsResponse {
results: Array<{
commentId: string;
success: boolean;
error?: string; // 失败时的错误信息
}>;
}
// 批量更新模型评论请求接口
export interface BatchUpdateModelCommentsRequest {
updates: Array<{
commentId: string;
content?: string; // 更新内容
rating?: number; // 更新评分
}>;
}
// 批量更新模型评论响应接口
export interface BatchUpdateModelCommentsResponse {
results: Array<{
commentId: string;
success: boolean;
comment?: ModelComment; // 成功时返回更新后的评论
error?: string; // 失败时的错误信息
}>;
}

View File

@@ -1,32 +1,17 @@
import type { BaseEntity, BaseUser } from '../post/base';
// AI模型评论统计信息接口
export interface ModelCommentStats {
stars: number; // 收藏数
likes: number; // 点赞数
comments: number; // 评论数
replies: number; // 回复数
}
import type { BaseEntity, BaseStats } from '../common';
// AI模型评论接口
export interface ModelComment extends BaseEntity {
modelId: string; // 模型ID
authorId: string; // 作者ID
author: BaseUser; // 作者信息
content: string; // 评论内容
parentId?: string; // 父评论ID用于嵌套评论
// 其实没必要
stats: ModelCommentStats; // 统计信息
}
// AI模型接口
export interface AIModel {
id: string;
export interface AIModel extends BaseEntity, BaseStats {
name: string;
description: string;
avatar?: string; // 模型头像
tags?: string[]; // 模型标签
website?: string; // 官方网站
clickCount?: number; // 点击次数
likeCount?: number; // 点赞次数
tags: string[]; // 模型标签(这个反正是静态的,必须有)
website: string; // 官方网站(必须有)
}

View File

@@ -1,7 +0,0 @@
// AI模型评论排序枚举
// 和post的重复了而且字段还不一样
export enum CommentSortType {
LATEST = 'latest', // 最新
HOTTEST = 'hottest', // 最热
HIGHEST_RATING = 'highest_rating' // 评分最高
}

View File

@@ -1,4 +1,4 @@
// 导出所有模型相关的类型定义
export * from './base';
export * from './api';
export * from './enum';
export * from './types';

2
types/model/types.ts Normal file
View File

@@ -0,0 +1,2 @@
// 只有排序
// 暂时不排序