/** * 账号管理 Mock API * * 模拟多平台账号绑定/解绑操作 * 支持平台:抖音、快手、小红书、微信视频号 */ /* ── 类型定义 ───────────────────────────────────────────── */ /** 平台 ID */ export type PlatformId = "douyin" | "kuaishou" | "xiaohongshu" | "wechat"; /** 账号状态 */ export type AccountStatus = "active" | "expired" | "limited"; /** 已绑定的账号 */ export interface Account { id: string; platform_id: PlatformId; name: string; avatar?: string; status: AccountStatus; bound_at: string; } /** 平台信息 */ export interface Platform { id: PlatformId; name: string; subName: string; icon: string; gradient: string; } /** 绑定账号请求 */ export interface BindAccountRequest { platform_id: PlatformId; name: string; } /* ── 平台配置 ───────────────────────────────────────────── */ export const PLATFORMS: Platform[] = [ { id: "douyin", name: "抖音", subName: "短视频发布平台", icon: "📱", gradient: "linear-gradient(135deg, #fe2c55, #25f4ee)", }, { id: "kuaishou", name: "快手", subName: "短视频发布平台", icon: "🎬", gradient: "linear-gradient(135deg, #ff4906, #ffba00)", }, { id: "xiaohongshu", name: "小红书", subName: "种草笔记发布平台", icon: "📕", gradient: "linear-gradient(135deg, #ff2442, #ff6b6b)", }, { id: "wechat", name: "微信视频号", subName: "视频号发布平台", icon: "💬", gradient: "linear-gradient(135deg, #07c160, #4cd964)", }, ]; /* ── Mock 数据 ───────────────────────────────────────────── */ let MOCK_ACCOUNTS: Account[] = [ { id: "acc-001", platform_id: "douyin", name: "小虾官方号", avatar: "🦐", status: "active", bound_at: "2025-12-01T10:00:00Z", }, { id: "acc-002", platform_id: "douyin", name: "小虾日常", avatar: "🐟", status: "active", bound_at: "2025-12-15T14:30:00Z", }, { id: "acc-003", platform_id: "kuaishou", name: "小虾剪辑", avatar: "🎬", status: "active", bound_at: "2026-01-05T09:00:00Z", }, { id: "acc-004", platform_id: "xiaohongshu", name: "小虾种草", avatar: "📕", status: "limited", bound_at: "2026-02-20T16:00:00Z", }, ]; /* ── 模拟延迟 ───────────────────────────────────────────── */ const delay = (ms: number) => new Promise((r) => setTimeout(r, ms)); /* ── API 函数 ───────────────────────────────────────────── */ /** 获取指定平台的账号列表 */ export async function getAccountsByPlatform( platformId: PlatformId, ): Promise { await delay(300); return MOCK_ACCOUNTS.filter((a) => a.platform_id === platformId); } /** 获取所有平台的账号总数 */ export async function getAllAccounts(): Promise { await delay(200); return [...MOCK_ACCOUNTS]; } /** 绑定新账号 */ export async function bindAccount(data: BindAccountRequest): Promise { await delay(500); const newAccount: Account = { id: `acc-${Date.now()}`, platform_id: data.platform_id, name: data.name, avatar: undefined, status: "active", bound_at: new Date().toISOString(), }; MOCK_ACCOUNTS = [...MOCK_ACCOUNTS, newAccount]; return newAccount; } /** 解绑账号 */ export async function unbindAccount(accountId: string): Promise { await delay(400); MOCK_ACCOUNTS = MOCK_ACCOUNTS.filter((a) => a.id !== accountId); } /* ── 状态配置 ───────────────────────────────────────────── */ export const ACCOUNT_STATUS_CONFIG: Record< AccountStatus, { label: string; className: string } > = { active: { label: "正常", className: "acc-status--active" }, expired: { label: "已过期", className: "acc-status--expired" }, limited: { label: "受限", className: "acc-status--limited" }, };