feat: 大部分注册登录功能

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-24 18:02:42 +08:00
parent 5ab74ad9dd
commit 5294528148
23 changed files with 858 additions and 167 deletions
+7 -7
View File
@@ -1,20 +1,20 @@
/**
* 所有服务端接口的统一响应结构
* 前端调用 /api/* 时收到的永远是这个格式
* 所有服务端接口的统一响应结构
* 前端调用 /api/* 时统一接收这个格式
*/
export interface ApiResponse<T = any> {
export interface ICommonResponse<T = any> {
/** 业务状态码:0 = 成功,其他值为对应错误码 */
code: number;
/** 响应数据:成功时为实际数据,无数据或失败时为 null */
data: T | null;
/** 提示信息:成功时默认 "请求成功",失败时为错误原因描述 */
/** 提示信息:成功或失败时展示给前端的文案 */
msg: string;
}
/** 语义化的成功响应类型,code 固定为字面量 0,便于类型收窄 */
export type SuccessResponse<T = any> = ApiResponse<T> & { code: 0 };
export type ISuccessResponse<T = any> = ICommonResponse<T> & { code: 0 };
/** 语义化的错误响应类型data 固定为 null */
export type ErrorResponse = ApiResponse<null> & { code: number };
/** 语义化的错误响应类型 */
export type IErrorResponse = ICommonResponse<null> & { code: number };
export * from "./user";
+28 -18
View File
@@ -1,33 +1,31 @@
/**
* 用户注册请求体
* 对应 NewAPI POST /api/user/register 接口
* 所有字段均为可选,上游接口本身不强制任何字段
* 用户注册请求体
* 对应 NewAPI POST /api/user/register 接口
*/
export interface UserRegisterRequest {
export interface IUserRegisterRequest {
/** 用户名 */
username?: string;
/** 登录密码 */
password?: string;
/** 邮箱地址 */
email?: string;
/** 邮箱验证码注册时若开启邮箱验证则需要填写 */
/** 邮箱验证码注册时若开启邮箱验证则需要填写 */
verification_code?: string;
/** 推广码 / 邀请码 */
aff_code?: string;
}
/**
* 注册成功时上游接口返回的数据类型
* NewAPI 注册接口成功时直接返回字符串 "成功"
* 注册成功时上游接口返回的数据类型
* NewAPI 注册接口成功时通常直接返回字符串
*/
export type UserRegisterResult = string;
export type IUserRegisterData = string;
/**
* 用户登录请求体
* 对应 NewAPI POST /api/user/login 接口
* 所有字段均为可选,上游接口本身不强制任何字段
* 用户登录请求体
* 对应 NewAPI POST /api/user/login 接口
*/
export interface UserLoginRequest {
export interface IUserLoginRequest {
/** 用户名 */
username?: string;
/** 登录密码 */
@@ -35,13 +33,25 @@ export interface UserLoginRequest {
}
/**
* 登录成功时上游接口返回的数据类型
* NewAPI 登录接口成功时响应体为空,此处用 null 表示
* 登录成功后返回的用户信息。
*/
export type UserLoginResult = null;
export interface IUserLoginData {
/** 用户 ID */
id: number;
/** 用户名 */
username: string;
/** 展示名称 */
display_name: string;
/** 用户分组 */
group: string;
/** 用户角色 */
role: number;
/** 用户状态 */
status: number;
}
/**
* 登出成功时上游接口返回的数据类型
* NewAPI 登出接口通常无业务数据返回,此处用 null 表示
* 登出成功时上游接口返回的数据类型
* NewAPI 登出接口通常无业务数据返回,此处用 null 表示
*/
export type UserLogoutResult = null;
export type IUserLogoutData = null;