Files
Ydisks-Xianyu-Helper/frontend/types.ts
T
ChristandClaude Opus 4.8 3f7954af84 feat: token 保活 + 通知系统 + 批量铺货 + 卡密批量 + 前端路由与样式对齐
后端
- token 刷新:session 过期立即触发密码登录兜底(不再空跑5次冷却);
  FAIL_SYS_SESSION_EXPIRED 识别为凭证失效;token 刷新成功日志;
  在线定时刷新 token 间隔从 1h 调整为 15min,持续续期 cookie
- QR 登录:修复自动验证成功状态被 EXPIRED 覆盖的竞态(前端拿不到 cookie)
- 通知系统:Notifier 加 NotifyAccountAlert/SendToChannel;engine Handler
  加 OnAccountAlert(warn/critical/风控三触发点);handlerAdapter 接 notifier;
  通知渠道测试发送端点 POST /notification-channels/{id}/test;
  NotificationChannelRow 加 json tag 修复前端读不到字段
- 卡密批量:POST /cards/batch 批量创建卡密组;POST /cards/{id}/append-data
  往 data 组充卡密;DB AppendBatchData
- 通知渠道启用切换修复(全量更新避免 type CHECK 约束报错)

前端
- history 路由(/app/ 前缀避开 API 冲突,刷新不丢位置,popstate 同步)
- 通知设置页:渠道管理 + 账号绑定 + 配置指南 + SMTP(从系统设置移入)
- 卡密批量导入弹窗(批量建组 + 单组充卡密)
- 商品卡片缩小约 2/3;Rules/Notifications 头部样式对齐标准页
- 初始化提示按 OS 区分命令(Windows/macOS)
- updateChannel 全量更新修复启用切换失败

文档
- docs/批量铺货使用文档.md(给铺货 agent 的资料包准备规格)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 12:27:37 +08:00

257 lines
5.6 KiB
TypeScript

// API Response Bases
export interface ApiResponse {
success?: boolean;
message?: string;
msg?: string;
}
export interface PaginatedResponse<T> {
success: boolean;
data: T[];
total: number;
page: number;
page_size: number;
total_pages: number;
}
// Auth
export interface LoginResponse {
success: boolean;
token?: string;
message?: string;
user_id?: number;
username?: string;
is_admin?: boolean;
}
// Accounts
export interface AccountDetail {
id: string;
value?: string; // cookie value from backend
cookie?: string; // alias for value
enabled: boolean;
auto_confirm: boolean;
remark?: string;
note?: string; // alias for remark
pause_duration?: number;
// 登录信息
username?: string;
login_password?: string;
show_browser?: boolean;
// Frontend helpers
nickname?: string;
avatar_url?: string;
profile_error?: string;
runtime_state?: 'starting' | 'connecting' | 'online' | 'reconnecting' | 'auth_expired' | 'verification_required' | 'error' | 'stopped' | 'disabled';
runtime_message?: string;
runtime_connected?: boolean;
runtime_updated_at?: string;
// AI设置
ai_enabled?: boolean;
max_discount_percent?: number;
max_discount_amount?: number;
max_bargain_rounds?: number;
custom_prompts?: string;
}
// Orders
export type OrderStatus =
| 'processing'
| 'pending_ship'
| 'shipped'
| 'completed'
| 'cancelled'
| 'refunding';
export interface Order {
id: string;
order_id: string;
cookie_id: string;
item_id: string;
item_title?: string;
item_image?: string;
item_price?: string;
buyer_id: string;
quantity: number;
amount: string;
status: OrderStatus;
order_status?: OrderStatus;
receiver_name?: string;
receiver_phone?: string;
receiver_address?: string;
created_at?: string;
updated_at?: string;
}
// Cards
export interface Card {
id: number;
name: string;
type: 'api' | 'text' | 'data' | 'image';
description?: string;
enabled: boolean;
// 文本类型
text_content?: string;
// 批量数据类型
data_content?: string;
// API 类型配置
api_config?: {
url: string;
method: 'GET' | 'POST';
timeout?: number;
headers?: string;
params?: string;
};
// 图片类型
image_url?: string;
// 通用配置
delay_seconds?: number;
// 多规格配置
is_multi_spec?: boolean;
spec_name?: string;
spec_value?: string;
created_at: string;
updated_at: string;
}
// Items
export interface Item {
id: string | number;
cookie_id: string;
item_id: string;
item_title?: string;
item_description?: string;
item_price?: string;
item_image?: string; // Inferred from common usage, though not explicitly in list model sometimes
item_category?: string;
item_detail?: string;
is_multi_spec?: number | boolean;
multi_quantity_delivery?: number | boolean;
is_multi_qty_ship?: number | boolean;
created_at?: string;
}
export type AutomationTriggerType = 'order_paid' | 'buyer_reviewed' | 'review_missing_timeout';
export type AutomationActionType = 'confirm_shipment' | 'send_card' | 'send_text';
// Rules
export interface ShippingRule {
id: string;
name: string;
trigger_type: AutomationTriggerType;
item_keyword: string; // Legacy UI helper
cookie_id?: string;
item_id?: string;
item_title?: string;
card_group_id: number; // First send_card action card id
card_group_name?: string; // UI helper
priority: number;
enabled: boolean;
config_json?: string;
actions: AutomationAction[];
variants: ShippingVariant[];
}
export interface AutomationAction {
id?: string;
action_type: AutomationActionType;
card_id?: number;
card_name?: string;
delivery_count?: number;
message_template?: string;
delay_seconds?: number;
config_json?: string;
enabled: boolean;
sort_order?: number;
}
export interface ShippingVariant {
id?: string;
spec_name: string;
spec_value: string;
card_id: number;
card_name?: string;
card_type?: Card['type'];
delivery_count: number;
enabled: boolean;
config_json?: string;
}
export interface ReplyRule {
id: string;
keyword: string;
reply_content: string;
match_type: 'exact' | 'fuzzy';
enabled: boolean;
}
// Stats
export interface AdminStats {
total_users: number;
total_cookies: number;
active_cookies: number;
total_cards: number;
total_keywords: number;
total_orders: number;
}
export interface OrderAnalytics {
revenue_stats: {
total_amount: number;
total_orders: number;
};
daily_stats: Array<{ date: string; amount: number }>;
item_stats?: Array<{
item_id: string;
order_count: number;
total_amount: number;
avg_amount: number;
}>;
}
// Settings
export interface SystemSettings {
ai_model?: string;
ai_api_key?: string;
ai_api_url?: string;
ai_base_url?: string;
default_reply?: string;
registration_enabled?: boolean;
smtp_server?: string;
[key: string]: any;
}
export interface AIReplySettings {
ai_enabled: boolean;
model_name?: string;
api_key?: string;
base_url?: string;
max_discount_percent: number;
max_discount_amount?: number;
max_bargain_rounds: number;
custom_prompts: string;
}
// Default Reply
export interface DefaultReply {
cookie_id: string;
enabled: boolean;
reply_content: string;
reply_once: boolean;
reply_image_url?: string;
}
// 通知渠道
export type NotificationChannelType = 'dingtalk' | 'feishu' | 'bark' | 'webhook' | 'wechat' | 'telegram' | 'email';
export interface NotificationChannel {
id: string;
name: string;
type: NotificationChannelType;
config: Record<string, unknown>;
enabled: boolean;
created_at?: string;
updated_at?: string;
}