feat: 前后端联调 — 任务创建 + 账户信息 + 预估花费 (0.0.18)

- task: device_id 改为必填参数,API 层 Omit 封装 + getDeviceId() 自动注入
- pricing.ts: Python 后端 calculate_cost 完整移植,六种定价模式 + 6 个 Bug 修复
  (浮点冗余/维度匹配不一致/null 守卫/matrix 数据提取/unit_scale 等)
- ModelInputForm: 三层兜底预估消费展示 + React Hooks 顺序修复
- AccountInfo: VIP 等级列表匹配,套餐详情展示(说明/周期/席位/到期)
- 模型列表加密缓存 (safe-storage, stale-while-revalidate)
- VIP API 模块 (激活码/等级/订单/模拟支付)
- device_id 统一使用 UUID v4 持久化 (与 login/register 对齐)
This commit is contained in:
2026-06-10 19:38:26 +08:00
parent 848fdeca3d
commit 95019316b2
19 changed files with 1681 additions and 292 deletions

View File

@@ -20,6 +20,34 @@ const AuthUrlObj = {
// 认证相关 DTO 传输模型
// ============================================================
export const UserRoleTypeEnum = {
User: "user",
Admin: "admin",
SuperAdmin: "superadmin",
} as const;
export type UserRoleTypeValue = typeof UserRoleTypeEnum[keyof typeof UserRoleTypeEnum];
export const UserRoleTypeLabelMap: Record<UserRoleTypeValue, string> = {
[UserRoleTypeEnum.User]: "用户账户",
[UserRoleTypeEnum.Admin]: "管理账户",
[UserRoleTypeEnum.SuperAdmin]: "超管账户"
}
export const UserAccountTypeEnum = {
Individual: 'individual',
Company: 'company',
Employee: 'employee',
} as const;
export type UserAccountTypeValue = typeof UserAccountTypeEnum[keyof typeof UserAccountTypeEnum];
export const UserAccountTypeLabelMap: Record<UserAccountTypeValue, string> = {
[UserAccountTypeEnum.Individual]: "个人用户",
[UserAccountTypeEnum.Company]: "企业用户",
[UserAccountTypeEnum.Employee]: "员工账号"
};
/** 短信验证码请求体 */
export interface SendSMSRequestBody {
phone: string;
@@ -53,10 +81,10 @@ export interface RegisterResponseBody {
refresh_expires_in: 0;
user_id: string;
username: string;
role: "user" | "admin" | "superadmin";
role: UserRoleTypeValue;
email: string;
balance_cent: 0;
account_type: "individual" | "company" | "employee";
account_type: UserAccountTypeValue;
display_name: string;
company_id: string;
real_name: string;
@@ -81,10 +109,10 @@ export interface LoginResponseBody {
refresh_expires_in: number;
user_id: string;
username: string;
role: "user" | "admin" | "superadmin";
role: UserRoleTypeValue;
email: string;
balance_cent: number;
account_type: "individual" | "company" | "employee";
account_type: UserAccountTypeValue;
display_name: string;
company_id: string;
real_name: string;
@@ -108,27 +136,27 @@ export interface RefreshTokenResponseBody {
export interface UserInfoBody {
id: string;
username: string;
email: string;
email: string | null;
balance_cent: number;
gift_balance_cent: number;
role: "user" | "admin" | "superadmin";
role: UserRoleTypeValue;
status: string;
account_type: "individual" | "company" | "employee";
display_name: string;
real_name: string;
account_type: UserAccountTypeValue;
display_name: string | null;
real_name: string | null;
phone: string;
company_id: string;
discount_rate: number;
company_id: string | null;
discount_rate: number | null;
subscription_plan: string;
subscription_expires_at: Date;
seat_limit: number;
seat_limit: number | null;
last_login_at: Date;
created_at: Date;
model_package_id: number;
vip_level_id: number;
software_expires_at: Date;
referral_code: string;
admin_permissions: string[];
referral_code: string | null;
admin_permissions: string[] | null;
}
export interface ChangePasswordRequestBody {