Files
Ydisks-Xianyu-Helper/frontend/types.ts
T
ChristandClaude Opus 4.8 980de41b53 chore: 重构配套改动 + 包文档 + 构建产物清理
automation 重构期间的配套修改:
- browser:订单抓取/密码登录/二维码刷新/stealth 等适配新流程,删 search.go
- db:cookies/orders_ext/extras/sessions/users/password/repository 等调整
- xianyu:mtop client、protocol(sign/decrypt/msgpack/cookies)、qrlogin、ws、ua
- server:admin/analytics/auth/cookie/helpers/item/item_publish_batch handlers
- frontend:App/Dashboard/ItemList/Rules/Sidebar/api/types,删 Keywords/TestPage
- auth、notify、webui、go.mod 等

本次会话补充:
- cmd/server、cmd/init-admin 改为 // Package main 开头的标准包文档
- .gitignore 加 internal/webui/static/assets/(hash 化构建产物不入库)
- internal/webui/static/index.html 重新构建

全量 go build/vet/test + race + 前端 test/build 通过。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 21:41:03 +08:00

244 lines
5.3 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;
}