feat(admin): 从已有玩家升级代理、修复 i18n 与过期 .js 冲突

- 新建一级代理改为选择已有玩家;新建用户可选一级代理

- 操作日志/注单等扁平 key 翻译;清理 src 内误生成 .js,Vite 优先解析 .ts

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-03 15:42:15 +08:00
parent cbfa18d1d3
commit 3b739982a1
27 changed files with 625 additions and 165 deletions

View File

@@ -1,9 +1,17 @@
import { FormValidationError } from '../i18n/form-validation';
export interface AgentCreateForm {
export interface PromotableUserOption {
id: string;
username: string;
password: string;
confirmPassword: string;
status: string;
parentId: string | null;
parentUsername: string | null;
phone: string | null;
email: string | null;
}
export interface AgentCreateForm {
userId: string;
creditLimit: number;
cashbackRate: number;
phone: string;
@@ -54,9 +62,7 @@ export interface AgentDetail extends AgentRow {
export function emptyAgentCreateForm(): AgentCreateForm {
return {
username: '',
password: 'Agent@123',
confirmPassword: 'Agent@123',
userId: '',
creditLimit: 50000,
cashbackRate: 0,
phone: '',
@@ -82,14 +88,20 @@ export function editFormFromAgentDetail(d: AgentDetail): AgentEditForm {
};
}
export function applyPromotableUserToForm(
form: AgentCreateForm,
user: PromotableUserOption,
): void {
form.userId = user.id;
form.phone = user.phone ?? '';
form.email = user.email ?? '';
}
export function buildCreateAgentPayload(form: AgentCreateForm) {
if (!form.username.trim()) throw new FormValidationError('err.username_required');
if (form.password.length < 8) throw new FormValidationError('err.password_min');
if (form.password !== form.confirmPassword) throw new FormValidationError('err.password_mismatch');
if (!form.userId) throw new FormValidationError('err.user_required');
if (form.creditLimit < 0) throw new FormValidationError('err.credit_negative');
return {
username: form.username.trim(),
password: form.password,
userId: form.userId,
creditLimit: form.creditLimit,
cashbackRate: form.cashbackRate,
phone: form.phone.trim() || undefined,