阶段七:完成AccountAutomation React feature化与任务边界

This commit is contained in:
Christ committed 2026-08-15 02:03:21 +08:00
1 parent c6da6d96c1
commit 867ced6849
12 files changed
+685 -394

No files matched your search

File diff suppressed because it is too large. Load diff
+3 -1
View File
@@ -178,7 +178,8 @@ app shell / routes
- 已完成阶段 7 第七个 PR 切片“React Dashboard feature 化与统计/趋势查询行为边界”:按 `app/features/dashboard` 提取 Dashboard API 适配层、统计数据 Hook、趋势/排行派生状态和请求边界;概览、趋势和有效订单支持并行加载、刷新取消、失败重试与过期响应保护;新增统计派生数据、API 取消信号和请求代次测试,保留旧页面入口和 API 路径;前端类型检查、全量测试、注释检查和构建门禁通过并合并为一个可回滚提交;
- 已完成阶段 7 第八个 PR 切片“React Settings feature 化与系统配置校验边界”:按 `app/features/settings` 提取系统配置/模型/凭据 API 适配层、配置常量、表单状态和敏感字段校验;配置读取与保存支持并行加载、请求取消、失败重试和过期响应保护,登录凭据提交保留现有校验与重登录语义;新增配置裁剪、凭据校验、API 取消信号和请求代次测试,保留旧页面入口和 API 路径;
- 已完成阶段 7 第九个 PR 切片“React Chat feature 化与会话消息行为边界”:按 `app/features/chat` 提取聊天 API、会话筛选/消息合并状态、账号/会话/消息分页 Hook;会话切换、联系人分页和消息加载支持取消与请求代次保护,文本/图片发送支持失败重试,WebSocket 和滚动语义保持不变;新增会话筛选、消息去重、分页过期响应、发送取消与 API 取消信号测试,保留旧页面入口和 API 路径;
- 阶段 7 下一 PR 切片为“React AccountAutomation feature 化与任务设置行为边界”:提取账号任务设置/执行 API、任务表单状态和运行结果面板,补充账号切换取消、重复执行阻断和失败重试测试;
- 已完成阶段 7 第十个 PR 切片“React AccountAutomation feature 化与任务设置行为边界”:按 `app/features/accountAutomation` 提取账号任务 API、默认设置与重复执行状态模型、任务设置 Hook;账号切换支持取消和请求代次保护,保存/立即执行支持重复提交阻断、失败重试和结果刷新;新增默认值、动作门禁、API 取消信号测试,保留旧弹窗入口和 API 路径;
- 阶段 7 下一 PR 切片为“React AccountList 子模块收口与页面组合边界”:收口账号编辑、密码登录、AI 设置和通知绑定子模块的共享状态,补充账号编辑过期响应与跨子模块刷新测试;
- 禁止跳过当前入口直接开始 Engine、Automation 或 DB 的大规模拆分。
## 6. 阶段 0:治理文档与强约束
@@ -606,3 +607,4 @@ npm --prefix frontend run build
| 2026-08-15 | 完成阶段 7 第七个 PR 切片“React Dashboard feature 化与统计/趋势查询行为边界” | 按 `app/features/dashboard` 提取 Dashboard API 适配层、统计数据 Hook、趋势/排行派生状态和请求边界;概览、趋势和有效订单支持并行加载、刷新取消、失败重试与过期响应保护;新增统计派生数据、API 取消信号和请求代次测试,保留旧页面入口和 API 路径;前端类型检查、全量测试、注释检查和构建门禁通过并合并为一个可回滚提交 | 阶段 7:React Settings feature 化与系统配置校验边界 |
| 2026-08-15 | 完成阶段 7 第八个 PR 切片“React Settings feature 化与系统配置校验边界” | 按 `app/features/settings` 提取系统配置/模型/凭据 API 适配层、配置常量、表单状态和敏感字段校验;配置读取与保存支持并行加载、请求取消、失败重试和过期响应保护,登录凭据提交保留现有校验与重登录语义;新增配置裁剪、凭据校验、API 取消信号和请求代次测试,保留旧页面入口和 API 路径 | 阶段 7:React Chat feature 化与会话消息行为边界 |
| 2026-08-15 | 完成阶段 7 第九个 PR 切片“React Chat feature 化与会话消息行为边界” | 按 `app/features/chat` 提取聊天 API、会话筛选/消息合并状态、账号/会话/消息分页 Hook;会话切换、联系人分页和消息加载支持取消与请求代次保护,文本/图片发送支持失败重试,WebSocket 和滚动语义保持不变;新增会话筛选、消息去重、分页过期响应、发送取消与 API 取消信号测试,保留旧页面入口和 API 路径 | 阶段 7:React AccountAutomation feature 化与任务设置行为边界 |
| 2026-08-15 | 完成阶段 7 第十个 PR 切片“React AccountAutomation feature 化与任务设置行为边界” | 按 `app/features/accountAutomation` 提取账号任务 API、默认设置与重复执行状态模型、任务设置 Hook;账号切换支持取消和请求代次保护,保存/立即执行支持重复提交阻断、失败重试和结果刷新;新增默认值、动作门禁、API 取消信号测试,保留旧弹窗入口和 API 路径 | 阶段 7:React AccountList 子模块收口与页面组合边界 |
@@ -0,0 +1,2 @@
/** AccountAutomation feature 使用的账号任务 API。 */
export { getAccountTaskSettings, runAccountTask, updateAccountTaskSettings } from '../../../services/api';
@@ -0,0 +1,125 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import type { AccountTaskSettings, AccountTaskSummary } from '../../../types';
import { getAccountTaskSettings, runAccountTask, updateAccountTaskSettings } from './api';
import { accountTaskErrorMessage, buildAccountTaskDefaults, canStartAccountTask, isAccountTaskAbortError, isCurrentAccountTaskRequest } from './state';
import type { AccountAutomationOptions, AccountAutomationState, AccountTaskType } from './types';
/** AccountAutomation Hook 的完整返回值。 */
export type UseAccountAutomationResult = AccountAutomationState & {
/** 更新任务设置草稿。 */
setForm: React.Dispatch<React.SetStateAction<AccountTaskSettings>>;
/** 保存任务设置。 */
save: () => Promise<void>;
/** 立即运行指定任务。 */
run: (taskType: AccountTaskType) => Promise<void>;
/** 重试最近一次失败动作。 */
retry: () => Promise<void>;
};
/** 管理账号自动评价和自动擦亮的设置、执行、取消与重试。 */
export const useAccountAutomation = ({ account, onSaved }: AccountAutomationOptions): UseAccountAutomationResult => {
// form 保存当前账号任务设置草稿。
const [form, setForm] = useState<AccountTaskSettings>(() => buildAccountTaskDefaults(account));
// loading 表示账号任务设置是否正在读取。
const [loading, setLoading] = useState(true);
// saving 表示任务设置是否正在保存。
const [saving, setSaving] = useState(false);
// running 保存当前执行中的任务类型。
const [running, setRunning] = useState<'' | AccountTaskType>('');
// error 保存最近一次任务操作错误。
const [error, setError] = useState('');
// summary 保存最近一次任务执行统计。
const [summary, setSummary] = useState<AccountTaskSummary | null>(null);
// retryAction 保存最近一次失败动作。
const [retryAction, setRetryAction] = useState<(() => Promise<void>) | null>(null);
// requestSequence 隔离账号切换后的旧响应。
const requestSequence = useRef(0);
// requestController 保存当前账号任务请求控制器。
const requestController = useRef<AbortController | null>(null);
useEffect(() => {
const sequence = ++requestSequence.current;
requestController.current?.abort();
const controller = new AbortController();
requestController.current = controller;
setForm(buildAccountTaskDefaults(account));
setSummary(null);
setError('');
setSaving(false);
setRunning('');
setRetryAction(null);
setLoading(true);
getAccountTaskSettings(account.id, { signal: controller.signal }).then(settings => {
if (!isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal)) return;
setForm(settings);
}).catch(loadError => {
if (isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal) && !isAccountTaskAbortError(loadError)) setError(accountTaskErrorMessage(loadError, '加载任务设置失败'));
}).finally(() => {
if (isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal)) setLoading(false);
});
return () => controller.abort();
}, [account.id]);
useEffect(() => () => requestController.current?.abort(), []);
/** 保存任务设置并在成功后同步账号列表。 */
const save = useCallback(async (): Promise<void> => {
if (!canStartAccountTask(saving, running)) return;
const sequence = ++requestSequence.current;
requestController.current?.abort();
const controller = new AbortController();
requestController.current = controller;
setSaving(true);
setError('');
setRetryAction(null);
try {
const stored = await updateAccountTaskSettings(account.id, form, { signal: controller.signal });
if (!isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal)) return;
setForm(stored);
onSaved(stored);
} catch (saveError) {
if (isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal) && !isAccountTaskAbortError(saveError)) {
setError(accountTaskErrorMessage(saveError, '保存失败'));
setRetryAction(() => save);
}
} finally {
if (isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal)) setSaving(false);
}
}, [account.id, form, onSaved, running, saving]);
/** 保存设置后立即执行指定账号任务并刷新结果。 */
const run = useCallback(async (taskType: AccountTaskType): Promise<void> => {
if (!canStartAccountTask(saving, running) || !account.enabled) return;
const sequence = ++requestSequence.current;
requestController.current?.abort();
const controller = new AbortController();
requestController.current = controller;
setRunning(taskType);
setError('');
setSummary(null);
setRetryAction(null);
try {
await updateAccountTaskSettings(account.id, form, { signal: controller.signal });
const result = await runAccountTask(account.id, taskType, { signal: controller.signal });
const stored = await getAccountTaskSettings(account.id, { signal: controller.signal });
if (!isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal)) return;
setSummary(result.summary);
setForm(stored);
onSaved(stored);
} catch (runError) {
if (isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal) && !isAccountTaskAbortError(runError)) {
setError(accountTaskErrorMessage(runError, '任务执行失败'));
setRetryAction(() => () => run(taskType));
}
} finally {
if (isCurrentAccountTaskRequest(requestSequence.current, sequence, controller.signal)) setRunning('');
}
}, [account.enabled, account.id, form, onSaved, running, saving]);
/** 重试最近一次保存或执行动作。 */
const retry = useCallback(async (): Promise<void> => {
if (retryAction) await retryAction();
}, [retryAction]);
return { form, loading, saving, running, summary, error, retryAvailable: retryAction !== null, setForm, save, run, retry };
};
@@ -0,0 +1,27 @@
import { expect, test } from 'vitest';
import type { AccountDetail } from '../../../types';
import { buildAccountTaskDefaults, canStartAccountTask, isCurrentAccountTaskRequest } from './state';
// accountFixture 是覆盖任务默认值和账号禁用边界的最小账号数据。
const accountFixture: AccountDetail = {
id: 'a1', enabled: true, auto_confirm: false, auto_rate_enabled: true, rate_content: '交易愉快', auto_polish_enabled: false, polish_time: '03:00',
};
test('账号任务默认设置继承账号配置并保持安全文案',
// 默认值测试验证新账号没有文案时仍使用明确的中文好评内容。
() => {
expect(buildAccountTaskDefaults(accountFixture)).toMatchObject({ account_id: 'a1', auto_rate_enabled: true, rate_content: '交易愉快', polish_time: '03:00' });
expect(buildAccountTaskDefaults({ ...accountFixture, rate_content: '' }).rate_content).toBe('不错的买家,交易愉快');
});
test('账号任务阻断重复提交并拒绝过期响应',
// 动作边界测试验证保存或执行中不会重复发起任务,账号切换后的旧响应不能写入。
() => {
const controller = new AbortController();
expect(canStartAccountTask(false, '')).toBe(true);
expect(canStartAccountTask(true, '')).toBe(false);
expect(canStartAccountTask(false, 'auto_rate')).toBe(false);
expect(isCurrentAccountTaskRequest(4, 4, controller.signal)).toBe(true);
expect(isCurrentAccountTaskRequest(3, 4, controller.signal)).toBe(false);
controller.abort();
expect(isCurrentAccountTaskRequest(4, 4, controller.signal)).toBe(false);
});
@@ -0,0 +1,28 @@
import type { AccountDetail, AccountTaskSettings } from '../../../types';
import type { AccountTaskType } from './types';
/** 根据账号详情创建任务设置初始草稿。 */
export const buildAccountTaskDefaults = (account: AccountDetail): AccountTaskSettings => ({
account_id: account.id,
auto_rate_enabled: account.auto_rate_enabled === true,
rate_content: account.rate_content || '不错的买家,交易愉快',
auto_polish_enabled: account.auto_polish_enabled === true,
polish_time: account.polish_time || '03:00',
last_rate_scan_at: account.last_rate_scan_at,
last_polish_date: account.last_polish_date,
last_polish_at: account.last_polish_at,
});
/** 判断账号任务响应是否仍属于当前编辑账号和请求代次。 */
export const isCurrentAccountTaskRequest = (currentSequence: number, requestSequence: number, signal: AbortSignal): boolean => (
currentSequence === requestSequence && !signal.aborted
);
/** 统一提取账号任务请求错误文本。 */
export const accountTaskErrorMessage = (error: unknown, fallback: string): string => error instanceof Error ? error.message : fallback;
/** 判断错误是否来自请求主动取消。 */
export const isAccountTaskAbortError = (error: unknown): boolean => error instanceof Error && error.message === '请求已取消';
/** 判断账号任务动作是否允许重复提交。 */
export const canStartAccountTask = (saving: boolean, running: '' | AccountTaskType): boolean => !saving && running === '';
@@ -0,0 +1,30 @@
import type { AccountDetail, AccountTaskSettings, AccountTaskSummary } from '../../../types';
/** 账号任务类型。 */
export type AccountTaskType = 'auto_rate' | 'auto_polish';
/** AccountAutomation Hook 的输入参数。 */
export type AccountAutomationOptions = {
/** 当前编辑的账号。 */
account: AccountDetail;
/** 保存成功后的页面同步回调。 */
onSaved: (settings: AccountTaskSettings) => void;
};
/** AccountAutomation Hook 的状态和动作。 */
export type AccountAutomationState = {
/** 账号任务设置草稿。 */
form: AccountTaskSettings;
/** 初始设置加载状态。 */
loading: boolean;
/** 保存设置状态。 */
saving: boolean;
/** 当前运行中的任务类型。 */
running: '' | AccountTaskType;
/** 最近一次任务统计。 */
summary: AccountTaskSummary | null;
/** 当前错误信息。 */
error: string;
/** 是否存在可重试动作。 */
retryAvailable: boolean;
};
+7 -50
View File
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import React from 'react';
import { CalendarClock, Loader2, MessageSquareQuote, Play, Save, Sparkles, X } from 'lucide-react';
import { AccountDetail, AccountTaskSettings, AccountTaskSummary } from '../types';
import { getAccountTaskSettings, runAccountTask, updateAccountTaskSettings } from '../services/api';
import { AccountDetail, AccountTaskSettings } from '../types';
import { useAccountAutomation } from '../app/features/accountAutomation/hooks';
interface Props {
account: AccountDetail;
@@ -17,52 +17,8 @@ const Toggle: React.FC<{checked: boolean; onChange: () => void; label: string}>
);
const AccountAutomationModal: React.FC<Props> = ({ account, onClose, onSaved }) => {
const [form, setForm] = useState<AccountTaskSettings>({
account_id: account.id,
auto_rate_enabled: account.auto_rate_enabled === true,
rate_content: account.rate_content || '不错的买家,交易愉快',
auto_polish_enabled: account.auto_polish_enabled === true,
polish_time: account.polish_time || '03:00',
last_rate_scan_at: account.last_rate_scan_at,
last_polish_date: account.last_polish_date,
last_polish_at: account.last_polish_at,
});
const [saving, setSaving] = useState(false);
const [running, setRunning] = useState<'' | 'auto_rate' | 'auto_polish'>('');
const [error, setError] = useState('');
const [summary, setSummary] = useState<AccountTaskSummary | null>(null);
const save = async () => {
setSaving(true);
setError('');
try {
const stored = await updateAccountTaskSettings(account.id, form);
setForm(stored);
onSaved(stored);
} catch (saveError) {
setError(saveError instanceof Error ? saveError.message : '保存失败');
} finally {
setSaving(false);
}
};
const run = async (taskType: 'auto_rate' | 'auto_polish') => {
setRunning(taskType);
setError('');
setSummary(null);
try {
await updateAccountTaskSettings(account.id, form);
const result = await runAccountTask(account.id, taskType);
const stored = await getAccountTaskSettings(account.id);
setSummary(result.summary);
setForm(stored);
onSaved(stored);
} catch (runError) {
setError(runError instanceof Error ? runError.message : '任务执行失败');
} finally {
setRunning('');
}
};
// automationState 是账号任务 feature Hook 提供的表单和动作状态。
const { form, loading, saving, running, error, summary, retryAvailable, setForm, save, run, retry } = useAccountAutomation({ account, onSaved });
return (
<div className="modal-overlay-centered">
@@ -78,6 +34,7 @@ const AccountAutomationModal: React.FC<Props> = ({ account, onClose, onSaved })
</div>
<div className="modal-body space-y-5">
{loading && <div className="rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500">正在读取任务设置...</div>}
<section className="rounded-2xl border border-slate-200 bg-white p-5">
<div className="flex items-start gap-4">
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600"><MessageSquareQuote className="h-5 w-5" /></div>
@@ -135,7 +92,7 @@ const AccountAutomationModal: React.FC<Props> = ({ account, onClose, onSaved })
本次发现 {summary.found} 项,成功 {summary.success},失败 {summary.failed},跳过 {summary.skipped}。{summary.message || ''}
</div>
)}
{error && <div className="rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700">{error}</div>}
{error && <div className="flex items-center justify-between gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-medium text-red-700"><span>{error}</span>{retryAvailable && <button type="button" className="font-bold underline" onClick={() => void retry()}>重试</button>}</div>}
</div>
<div className="modal-footer">
+18
View File
@@ -109,6 +109,24 @@ test('account task APIs keep rating and polish account-scoped', async () => {
expect(JSON.parse(fetchMock.mock.calls[1][1].body)).toEqual({ task_type: 'auto_rate' });
});
test('账号自动任务 API 转发外部取消信号', async () => {
// fetchMock 验证读取、保存和执行账号任务都支持请求取消。
const fetchMock = vi.fn()
.mockResolvedValueOnce(jsonResponse({ account_id: 'a1', auto_rate_enabled: true, rate_content: '交易愉快', auto_polish_enabled: false, polish_time: '03:00' }))
.mockResolvedValueOnce(jsonResponse({ account_id: 'a1', auto_rate_enabled: true, rate_content: '交易愉快', auto_polish_enabled: false, polish_time: '03:00' }))
.mockResolvedValueOnce(jsonResponse({ success: true, summary: { task_type: 'auto_rate', found: 1, success: 1, failed: 0, skipped: 0 } }));
vi.stubGlobal('fetch', fetchMock);
// controller 是 AccountAutomation feature Hook 使用的请求控制器。
const controller = new AbortController();
const settings = { account_id: 'a1', auto_rate_enabled: true, rate_content: '交易愉快', auto_polish_enabled: false, polish_time: '03:00' };
await getAccountTaskSettings('a1', { signal: controller.signal });
await updateAccountTaskSettings('a1', settings, { signal: controller.signal });
await runAccountTask('a1', 'auto_rate', { signal: controller.signal });
expect(fetchMock).toHaveBeenNthCalledWith(1, '/api/v1/account-tasks/a1', expect.objectContaining({ signal: expect.any(AbortSignal) }));
expect(fetchMock).toHaveBeenNthCalledWith(2, '/api/v1/account-tasks/a1', expect.objectContaining({ signal: expect.any(AbortSignal) }));
expect(fetchMock).toHaveBeenNthCalledWith(3, '/api/v1/account-tasks/a1/run', expect.objectContaining({ signal: expect.any(AbortSignal) }));
});
test('getItemPublishBatches unwraps persisted batch list', async () => {
const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ batches: [{ id: 'batch-1', status: 'running' }] }));
vi.stubGlobal('fetch', fetchMock);
+6 -6
View File
@@ -97,14 +97,14 @@ export const getAccountDetails = async (options?: RequestControlOptions): Promis
}));
};
export const getAccountTaskSettings = async (id: string): Promise<AccountTaskSettingsResponse> =>
get(`/api/v1/account-tasks/${id}`);
export const getAccountTaskSettings = async (id: string, options?: RequestControlOptions): Promise<AccountTaskSettingsResponse> =>
get(`/api/v1/account-tasks/${id}`, undefined, options);
export const updateAccountTaskSettings = async (id: string, settings: AccountTaskSettings): Promise<AccountTaskSettingsResponse> =>
put(`/api/v1/account-tasks/${id}`, settings);
export const updateAccountTaskSettings = async (id: string, settings: AccountTaskSettings, options?: RequestControlOptions): Promise<AccountTaskSettingsResponse> =>
put(`/api/v1/account-tasks/${id}`, settings, options);
export const runAccountTask = async (id: string, taskType: 'auto_rate' | 'auto_polish'): Promise<AccountTaskRunResponseEnvelope> =>
post(`/api/v1/account-tasks/${id}/run`, { task_type: taskType }, { timeoutMs: 120_000 });
export const runAccountTask = async (id: string, taskType: 'auto_rate' | 'auto_polish', options?: RequestControlOptions): Promise<AccountTaskRunResponseEnvelope> =>
post(`/api/v1/account-tasks/${id}/run`, { task_type: taskType }, { timeoutMs: 120_000, ...options });
export interface ChatSessionPage { sessions: ChatSession[]; has_more: boolean; next_cursor?: number }
@@ -1,20 +1,20 @@
import{j as e,r,c as Is,b as Me,d as ar}from"./react-vendor-C_od1ZSF.js";import{L as rr,U as fa,M as ys,C as Os,B as ya,S as ja,Z as js,a as Rt,b as Ps,G as Bs,c as Es,d as Ts,e as lr,f as va,g as pt,A as Fs,D as nr,P as Na,h as Ft,E as _a,T as ir,i as or,j as Ce,X as Oe,k as cr,l as dr,m as Ds,n as wa,o as ot,p as at,q as ka,K as xr,r as ft,s as ut,Q as ls,t as jt,u as kt,v as Mt,R as He,w as Ca,x as mr,y as st,z as At,F as qt,H as ct,I as zs,J as Ct,N as ur,O as pr,V as hr,W as Sa,Y as Aa,_ as La,$ as gr,a0 as br,a1 as ns,a2 as Wt,a3 as vs,a4 as fr,a5 as yr,a6 as Ns,a7 as Us,a8 as jr,a9 as vr,aa as Bt,ab as Ws,ac as Yt,ad as Ra,ae as Nr,af as _r,ag as as,ah as Ia,ai as wr,aj as kr,ak as Cr,al as Sr,am as Ar,an as Lr,ao as Gs}from"./icons-vendor-i_74xDZy.js";import{R as Xt,B as Rr,X as Js,Y as Qs,T as es,a as Ir,C as _s,A as Or,b as Pr,c as Er,P as Vs,d as Ks,L as Tr}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))l(n);new MutationObserver(n=>{for(const x of n)if(x.type==="childList")for(const p of x.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&l(p)}).observe(document,{childList:!0,subtree:!0});function a(n){const x={};return n.integrity&&(x.integrity=n.integrity),n.referrerPolicy&&(x.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?x.credentials="include":n.crossOrigin==="anonymous"?x.credentials="omit":x.credentials="same-origin",x}function l(n){if(n.ep)return;n.ep=!0;const x=a(n);fetch(n.href,x)}})();const Dr=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),ws=({sizeClass:t="w-12 h-12",logoClassName:s="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23Line truncated
import{j as e,r,c as Es,b as Me,d as cr}from"./react-vendor-C_od1ZSF.js";import{L as dr,U as wa,M as Ns,C as Ts,B as ka,S as Ca,Z as _s,a as It,b as Ds,G as Us,c as $s,d as Ms,e as xr,f as Sa,g as ht,A as Ws,D as mr,P as Aa,h as zt,E as Ra,T as ur,i as pr,j as Ce,X as Oe,k as hr,l as gr,m as qs,n as La,o as ct,p as at,q as Ia,K as br,r as yt,s as pt,Q as ns,t as vt,u as Ct,v as qt,R as He,w as Oa,x as fr,y as st,z as Rt,F as Bt,H as dt,I as Gs,J as St,N as yr,O as jr,V as vr,W as Pa,Y as Ea,_ as Ta,$ as Nr,a0 as _r,a1 as is,a2 as Gt,a3 as ws,a4 as wr,a5 as kr,a6 as ks,a7 as Js,a8 as Cr,a9 as Sr,aa as Ft,ab as Qs,ac as Xt,ad as Da,ae as Ar,af as Rr,ag as rs,ah as $a,ai as Lr,aj as Ir,ak as Or,al as Pr,am as Er,an as Tr,ao as Vs}from"./icons-vendor-i_74xDZy.js";import{R as es,B as Dr,X as Ks,Y as Hs,T as ts,a as $r,C as Cs,A as Mr,b as qr,c as Br,P as Zs,d as Ys,L as Fr}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))l(n);new MutationObserver(n=>{for(const x of n)if(x.type==="childList")for(const p of x.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&l(p)}).observe(document,{childList:!0,subtree:!0});function a(n){const x={};return n.integrity&&(x.integrity=n.integrity),n.referrerPolicy&&(x.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?x.credentials="include":n.crossOrigin==="anonymous"?x.credentials="omit":x.credentials="same-origin",x}function l(n){if(n.ep)return;n.ep=!0;const x=a(n);fetch(n.href,x)}})();const zr=({className:t="w-full h-full text-white"})=>e.jsx("svg",{className:t,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),Ss=({sizeClass:t="w-12 h-12",logoClassName:s="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${t} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23Line truncated
例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(Ps,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Ge,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:ge,children:"取消"}),e.jsxs("button",{onClick:c,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:ge,children:[ge?e.jsx(Ce,{className:"w-4 h-4 animate-spin"}):e.jsx(ot,{className:"w-4 h-4"}),ge?"保存中...":"保存"]})]})})]})}),document.body)]})},En=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],Tn=t=>{const s=typeof t=="object"&&t!==null?t:{},a=Array.isArray(s.results)?s.results:[];return{total:Number(s.total||0),success_count:Number(s.success_count||0),failed_count:Number(s.failed_count||0),results:a.map(Dn)}},Dn=t=>{const s=typeof t=="object"&&t!==null?t:{};return{order_id:String(s.order_id||"unknown"),success:s.success===!0,message:String(s.message||"")}},$n=t=>(t==null?void 0:t.results.filter(Mn))||[],Mn=t=>!t.success,qn=(t,s)=>t!==null&&!s,Bn=t=>{if(!t)return"请选择订单文件";const s=t.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(s)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},yt=(t,s)=>t===s,Fn=(t,s)=>t instanceof Error&&t.message?t.message:s,zn=({filter:t,onFilterChange:s,accountFilter:a,onAccountFilterChange:l,accounts:n,accountName:x,searchText:p,onSearchChange:f})=>{const u=b=>s(b.currentTarget.dataset.status||"all"),j=b=>l(b.target.value),m=b=>f(b.target.value);return e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:En.map(b=>e.jsx("button",{"data-status":b.key,onClick:u,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${t===b.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:b.label},b.key))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(jt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:a,onChange:j,className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),n.map(b=>e.jsx("option",{value:b.id,children:x(b.id)},b.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(At,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:p,onChange:m,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Un=t=>{const s=x=>{var p;t.setImportFile(((p=x.target.files)==null?void 0:p[0])||null)},a=()=>t.closeImportModal(),l=()=>void t.handleImportOrders(),n=()=>void t.handleRetryImport();return t.showImportModal?Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:a,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:s,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xl Line truncated
例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(Ds,{className:"w-4 h-4"}),"AI如何工作"]}),e.jsxs("ul",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("li",{children:"• 自动识别买家的砍价请求"}),e.jsx("li",{children:"• 根据设定的策略智能回复"}),e.jsx("li",{children:"• 在合理范围内同意降价或礼貌拒绝"}),e.jsx("li",{children:"• 保持专业友好的沟通风格"})]})]})]}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:Ge,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:ge,children:"取消"}),e.jsxs("button",{onClick:c,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:ge,children:[ge?e.jsx(Ce,{className:"w-4 h-4 animate-spin"}):e.jsx(ct,{className:"w-4 h-4"}),ge?"保存中...":"保存"]})]})})]})}),document.body)]})},Bn=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],Fn=t=>{const s=typeof t=="object"&&t!==null?t:{},a=Array.isArray(s.results)?s.results:[];return{total:Number(s.total||0),success_count:Number(s.success_count||0),failed_count:Number(s.failed_count||0),results:a.map(zn)}},zn=t=>{const s=typeof t=="object"&&t!==null?t:{};return{order_id:String(s.order_id||"unknown"),success:s.success===!0,message:String(s.message||"")}},Un=t=>(t==null?void 0:t.results.filter(Wn))||[],Wn=t=>!t.success,Gn=(t,s)=>t!==null&&!s,Jn=t=>{if(!t)return"请选择订单文件";const s=t.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(s)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},jt=(t,s)=>t===s,Qn=(t,s)=>t instanceof Error&&t.message?t.message:s,Vn=({filter:t,onFilterChange:s,accountFilter:a,onAccountFilterChange:l,accounts:n,accountName:x,searchText:p,onSearchChange:f})=>{const u=g=>s(g.currentTarget.dataset.status||"all"),j=g=>l(g.target.value),m=g=>f(g.target.value);return e.jsxs("div",{className:"p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full",children:Bn.map(g=>e.jsx("button",{"data-status":g.key,onClick:u,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${t===g.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:g.label},g.key))}),e.jsxs("div",{className:"flex w-full md:w-auto flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(vt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:a,onChange:j,className:"ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm",children:[e.jsx("option",{value:"",children:"全部账号"}),n.map(g=>e.jsx("option",{value:g.id,children:x(g.id)},g.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(Rt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors"}),e.jsx("input",{type:"text",placeholder:"搜索订单号/商品/买家...",value:p,onChange:m,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Kn=t=>{const s=x=>{var p;t.setImportFile(((p=x.target.files)==null?void 0:p[0])||null)},a=()=>t.closeImportModal(),l=()=>void t.handleImportOrders(),n=()=>void t.handleRetryImport();return t.showImportModal?Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:a,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-600"})})]})}),e.jsxs("div",{className:"modal-body space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"选择Excel文件"}),e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv,.json",onChange:s,className:"w-full ios-input px-4 py-3 rounded-xl text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持 .xl Line truncated
VIP-002
VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["预览:",a.appendPreview.length," 个有效卡密,空行自动忽略。"]})]}),a.appendError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-200 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.appendError}),e.jsx("button",{type:"button",onClick:m,disabled:a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),a.appendResult&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",a.appendResult.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:p,className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),a.batchTab==="create"?e.jsxs("button",{onClick:L,disabled:!a.batchFile||a.batchBusy,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(Ce,{className:"w-4 h-4 animate-spin"}):e.jsx(qt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:F,disabled:!a.appendTargetId||a.appendPreview.length===0||a.batchBusy||t.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(Ce,{className:"w-4 h-4 animate-spin"}):e.jsx(ct,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},Vn=({type:t})=>{switch(t){case"text":return e.jsx(Aa,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(Sa,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(hr,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(Os,{className:"w-5 h-5 text-gray-500"})}},Kn=(t,s,a)=>{const l=a.trim().toLocaleLowerCase();return t.filter(n=>(!s||n.type===s)&&(!l||n.name.toLocaleLowerCase().includes(l)))},Ja=t=>t.split(`
`).map(s=>s.trim()).filter(Boolean),Hn=(t,s,a)=>!!(t&&Ja(s).length>0&&!a),_t=(t,s,a,l)=>t===s&&a===l,Zn=()=>{const[t,s]=r.useState([]),[a,l]=r.useState(!0),n=r.useRef(0),x=r.useRef(null),p=r.useCallback(async()=>{var j;const f=++n.current;(j=x.current)==null||j.abort();const u=new AbortController;x.current=u,l(!0);try{const m=await Ms({signal:u.signal});if(f!==n.current)return;s(m)}catch(m){f===n.current&&!u.signal.aborted&&console.error("加载卡密库存失败:",m)}finally{f===n.current&&l(!1)}},[]);return r.useEffect(()=>(p(),()=>{var u;n.current+=1,(u=x.current)==null||u.abort()}),[p]),{cards:t,setCards:s,loading:a,loadCards:p}},Yn=t=>{const s=t.dataCards,a=t.loadCards,[l,n]=r.useState(!1),[x,p]=r.useState("create"),[f,u]=r.useState(null),[j,m]=r.useState(null),[b,v]=r.useState(!1),[L,F]=r.useState(""),[y,O]=r.useState(""),[R,W]=r.useState(null),[K,X]=r.useState(""),_=r.useRef(0),k=r.useRef(null),Z=r.useRef(""),M=r.useMemo(()=>Ja(y),[y]),G=r.useCallback(()=>{var w;p("create"),u(null),m(null),F((w=s[0])!=null&&w.id?String(s[0].id):""),O(""),W(null),X(""),n(!0)},[s]),d=r.useCallback(()=>{var w;_.current+=1,(w=k.current)==null||w.abort(),v(!1),n(!1)},[]),$=r.useCallback(async()=>{var A;if(!f||b)return;const w=++_.current;(A=k.current)==null||A.abort();const T=new AbortController;k.current=T,v(!0),m(null);try{const z=await Pl(f,{signal:T.signal});if(!_t(w,_.current,"",""))return;m(z),z.created>0&&await a()}catch(z){if(!_t(w,_.current,"",""))return;m({error:(z==null?void 0:z.message)||"上传失败"})}finally{_t(w,_.current,"","")&&v(!1)}},[b,f,a]),H=r.useCallback(async()=>{var z;if(!Hn(L,y,b))return;const w=L,T=++_.current;Z.current=w,(z=k.current)==null||z.abort();const A=new AbortController;k.current=A,v(!0),W(null),X("");try{const U=await El(w,y,{signal:A.signal});if(!_t(T,_.current,w,L))return;W({added:U.added}),O(""),await a()}catch(U){if(!_t(T,_.current,w,L))return;X((U==null?void 0:U.message)||"追加失败")}finally{_t(T,_.current,w,L)&&v(!1)}},[y,L,b,a]),P=r.useCallback(async()=>{await $()},[$]),h=r.useCallback(async()=>{Z.current&&L!==Z.current||await H()},[L,H]);return{showBatchModal:l,setShowBatchModal:n,batchTab:x,setBatchTab:p,batchFile:f,setBatchFile:u,batchResult:j,batchBusy:b,appendTargetId:L,setAppendTargetId:F,appendContent:y,setAppendContent:O,appendResult:R,appendError:K,appendPreview:M,openBatchModal:G,closeBatchModal:d,handleBatchCreate:$,handleBatchAppend:H,handleRetryBatchCreate:P,handleRetryBatchAppend:h}},oa=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),Xn=()=>{const{cards:t,loadCards:s}=Zn(),[a,l]=r.useState(!1),[n,x]=r.useState(!1),[p,f]=r.useState(null),[u,j]=r.useState({}),[m,b]=r.useState(oa),[v,L]=r.useState(""),[F,y]=r.useState(""),O=r.useMemo(()=>t.filter(d=>d.type==="data"),[t]),R=Yn({dataCards:O,loadCards:s}),W=d=>{var $,H,P,h,w;f(d),j({id:d.id,name:d.name||"",type:d.type||"text",api_url:(($=d.api_config)==null?void 0:$.url)||"",api_method:((H=d.api_config)==null?void 0:H.method)||"GET",api_timeout:((P=d.api_config)==null?void 0:P.timeout)||10,api_headers:((h=d.api_config)==null?void 0:h.headers)||"",api_params:((w=d.api_config)==null?void 0:w.params)||"",text_content:d.text_content||"",data_content:d.data_content||"",image_url:d.image_url||"",delay_seconds:d.delay_seconds||0,description:d.description||"",enabled:d.enabled}),l(!0)},K=async()=>{var d,$,H,P,h,w,T,A;if(p){if(!((d=u.name)!=null&&d.trim())){alert("请输入卡密名称");return}if(!u.type){alert("请选择卡密类型");return}try{const z={name:u.name.trim(),type:u.type,description:($=u.description)==null?void 0:$.trim(),delay_seconds:u.delay_seconds||0,enabled:u.enabled??!0};u.type==="api"?z.api_config={url:((H=u.api_url)==null?void 0:H.trim())||"",method:u.api_method,timeout:u.api_timeout||10,headers:((P=u.api_headers)==null?void 0:P.trim())||void 0,params:((h=u.api_params)==null?void 0:h.trim())||void 0}:u.type==="text"?z.text_content=((w=u.text_content)==null?void 0:w.trim())||"":u.type==="data"?z.data_content=((T=u.data_content)==null?void 0:T.trim())||"":u.type==="image"&&(z.image_url=((A=u.image_url)==null?void 0:A.trim())||""),await ta(p.id,z),l(!1),await s()}catch(z){console.error("更新卡密失败:",z),alert("更新失败,请重试")}}},X=async d=>{if(confirm("确认删除该卡密吗?"))try{await Ol(d),await s()}catch($){console.error("删除卡密失败:",$),alert("删除失败,请重试")}},_=async()=>{if(!m.name.trim()){alert("请输入卡密名称");return}if(!m.content.trim()){alert(m.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const d={name:m.name.trim(),type:m.type,description:m.description.trim(),enabled:m.enabled,delay_seconds:m.delay_seconds};m.type==="text"&&(d.text_content=m.content.trim()),m.type==="data"&&(d.data_content=m.content.trim()),m.type==="image"&&(d.image_url=m.content.trim()),m.type==="api"&&(d.api_config={url:m.content.trim(),method:m.api_me Line truncated
VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["预览:",a.appendPreview.length," 个有效卡密,空行自动忽略。"]})]}),a.appendError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-200 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:a.appendError}),e.jsx("button",{type:"button",onClick:m,disabled:a.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),a.appendResult&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",a.appendResult.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:p,className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),a.batchTab==="create"?e.jsxs("button",{onClick:C,disabled:!a.batchFile||a.batchBusy,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(Ce,{className:"w-4 h-4 animate-spin"}):e.jsx(Bt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:D,disabled:!a.appendTargetId||a.appendPreview.length===0||a.batchBusy||t.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[a.batchBusy?e.jsx(Ce,{className:"w-4 h-4 animate-spin"}):e.jsx(dt,{className:"w-4 h-4"}),a.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},ei=({type:t})=>{switch(t){case"text":return e.jsx(Ea,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(Pa,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(vr,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(Ts,{className:"w-5 h-5 text-gray-500"})}},ti=(t,s,a)=>{const l=a.trim().toLocaleLowerCase();return t.filter(n=>(!s||n.type===s)&&(!l||n.name.toLocaleLowerCase().includes(l)))},Ya=t=>t.split(`
`).map(s=>s.trim()).filter(Boolean),si=(t,s,a)=>!!(t&&Ya(s).length>0&&!a),wt=(t,s,a,l)=>t===s&&a===l,ai=()=>{const[t,s]=r.useState([]),[a,l]=r.useState(!0),n=r.useRef(0),x=r.useRef(null),p=r.useCallback(async()=>{var j;const f=++n.current;(j=x.current)==null||j.abort();const u=new AbortController;x.current=u,l(!0);try{const m=await Fs({signal:u.signal});if(f!==n.current)return;s(m)}catch(m){f===n.current&&!u.signal.aborted&&console.error("加载卡密库存失败:",m)}finally{f===n.current&&l(!1)}},[]);return r.useEffect(()=>(p(),()=>{var u;n.current+=1,(u=x.current)==null||u.abort()}),[p]),{cards:t,setCards:s,loading:a,loadCards:p}},ri=t=>{const s=t.dataCards,a=t.loadCards,[l,n]=r.useState(!1),[x,p]=r.useState("create"),[f,u]=r.useState(null),[j,m]=r.useState(null),[g,v]=r.useState(!1),[C,D]=r.useState(""),[_,I]=r.useState(""),[L,W]=r.useState(null),[K,X]=r.useState(""),y=r.useRef(0),N=r.useRef(null),F=r.useRef(""),O=r.useMemo(()=>Ya(_),[_]),z=r.useCallback(()=>{var k;p("create"),u(null),m(null),D((k=s[0])!=null&&k.id?String(s[0].id):""),I(""),W(null),X(""),n(!0)},[s]),d=r.useCallback(()=>{var k;y.current+=1,(k=N.current)==null||k.abort(),v(!1),n(!1)},[]),q=r.useCallback(async()=>{var R;if(!f||g)return;const k=++y.current;(R=N.current)==null||R.abort();const $=new AbortController;N.current=$,v(!0),m(null);try{const G=await Ml(f,{signal:$.signal});if(!wt(k,y.current,"",""))return;m(G),G.created>0&&await a()}catch(G){if(!wt(k,y.current,"",""))return;m({error:(G==null?void 0:G.message)||"上传失败"})}finally{wt(k,y.current,"","")&&v(!1)}},[g,f,a]),Z=r.useCallback(async()=>{var G;if(!si(C,_,g))return;const k=C,$=++y.current;F.current=k,(G=N.current)==null||G.abort();const R=new AbortController;N.current=R,v(!0),W(null),X("");try{const J=await ql(k,_,{signal:R.signal});if(!wt($,y.current,k,C))return;W({added:J.added}),I(""),await a()}catch(J){if(!wt($,y.current,k,C))return;X((J==null?void 0:J.message)||"追加失败")}finally{wt($,y.current,k,C)&&v(!1)}},[_,C,g,a]),E=r.useCallback(async()=>{await q()},[q]),h=r.useCallback(async()=>{F.current&&C!==F.current||await Z()},[C,Z]);return{showBatchModal:l,setShowBatchModal:n,batchTab:x,setBatchTab:p,batchFile:f,setBatchFile:u,batchResult:j,batchBusy:g,appendTargetId:C,setAppendTargetId:D,appendContent:_,setAppendContent:I,appendResult:L,appendError:K,appendPreview:O,openBatchModal:z,closeBatchModal:d,handleBatchCreate:q,handleBatchAppend:Z,handleRetryBatchCreate:E,handleRetryBatchAppend:h}},pa=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),li=()=>{const{cards:t,loadCards:s}=ai(),[a,l]=r.useState(!1),[n,x]=r.useState(!1),[p,f]=r.useState(null),[u,j]=r.useState({}),[m,g]=r.useState(pa),[v,C]=r.useState(""),[D,_]=r.useState(""),I=r.useMemo(()=>t.filter(d=>d.type==="data"),[t]),L=ri({dataCards:I,loadCards:s}),W=d=>{var q,Z,E,h,k;f(d),j({id:d.id,name:d.name||"",type:d.type||"text",api_url:((q=d.api_config)==null?void 0:q.url)||"",api_method:((Z=d.api_config)==null?void 0:Z.method)||"GET",api_timeout:((E=d.api_config)==null?void 0:E.timeout)||10,api_headers:((h=d.api_config)==null?void 0:h.headers)||"",api_params:((k=d.api_config)==null?void 0:k.params)||"",text_content:d.text_content||"",data_content:d.data_content||"",image_url:d.image_url||"",delay_seconds:d.delay_seconds||0,description:d.description||"",enabled:d.enabled}),l(!0)},K=async()=>{var d,q,Z,E,h,k,$,R;if(p){if(!((d=u.name)!=null&&d.trim())){alert("请输入卡密名称");return}if(!u.type){alert("请选择卡密类型");return}try{const G={name:u.name.trim(),type:u.type,description:(q=u.description)==null?void 0:q.trim(),delay_seconds:u.delay_seconds||0,enabled:u.enabled??!0};u.type==="api"?G.api_config={url:((Z=u.api_url)==null?void 0:Z.trim())||"",method:u.api_method,timeout:u.api_timeout||10,headers:((E=u.api_headers)==null?void 0:E.trim())||void 0,params:((h=u.api_params)==null?void 0:h.trim())||void 0}:u.type==="text"?G.text_content=((k=u.text_content)==null?void 0:k.trim())||"":u.type==="data"?G.data_content=(($=u.data_content)==null?void 0:$.trim())||"":u.type==="image"&&(G.image_url=((R=u.image_url)==null?void 0:R.trim())||""),await la(p.id,G),l(!1),await s()}catch(G){console.error("更新卡密失败:",G),alert("更新失败,请重试")}}},X=async d=>{if(confirm("确认删除该卡密吗?"))try{await $l(d),await s()}catch(q){console.error("删除卡密失败:",q),alert("删除失败,请重试")}},y=async()=>{if(!m.name.trim()){alert("请输入卡密名称");return}if(!m.content.trim()){alert(m.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const d={name:m.name.trim(),type:m.type,description:m.description.trim(),enabled:m.enabled,delay_seconds:m.delay_seconds};m.type==="text"&&(d.text_content=m.content.trim()),m.type==="data"&&(d.data_content=m.content.trim()),m.type==="image"&&(d.image_url=m.content.trim()),m.type==="api"&&(d.api_config={url:m.content.trim(),method:m.api_me Line truncated
VIP-MONTH-002
VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(T=>T.map(A=>`"${String(A).replace(/"/g,'""')}"`).join(",")).join(`
`),P=new Blob(["\uFEFF"+H],{type:"text/csv;charset=utf-8"}),h=URL.createObjectURL(P),w=document.createElement("a");w.href=h,w.download="卡密组批量导入模板.csv",document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(h)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:R.openBatchModal,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(qt,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>x(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(ct,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-surface-muted p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(La,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:v,onChange:d=>L(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(At,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:F,onChange:d=>y(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",M.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:M.map(d=>{let $="";return d.type==="data"&&d.data_content?$=`库存: ${d.data_content.split(`
`).filter(P=>P.trim()).length} 条`:d.type==="text"&&d.text_content?$=d.text_content:d.type==="api"&&d.api_config?$=d.api_config.url:d.type==="image"&&d.image_url&&($="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(Vn,{type:d.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:d.name,children:d.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>Z(d.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:d.id}),e.jsx(gr,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${d.type==="text"?"bg-blue-50 text-blue-600":d.type==="data"?"bg-purple-50 text-purple-600":d.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:d.type==="text"?"文本":d.type==="data"?"批量":d.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:$,children:$})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:d.description||"-",children:d.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>k(d),className:`w-12 h-8 rounded-full relative transition-colors ${d.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${d.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>W(d),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(Ct,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>X(d.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(st,{className:"h-4 w-4"})})]})})]},d.id)})})]})}),M.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(Na,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),a&&p&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>l(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:u.name||"",onChange:d=>j({...u,name:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:u.type||"text",onChange:d=>j({...u,type:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(p==null?void 0:p.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),u.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:u.api_url||"",onChange:d=>j({...u,api_url:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxsLine truncated
VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map($=>$.map(R=>`"${String(R).replace(/"/g,'""')}"`).join(",")).join(`
`),E=new Blob(["\uFEFF"+Z],{type:"text/csv;charset=utf-8"}),h=URL.createObjectURL(E),k=document.createElement("a");k.href=h,k.download="卡密组批量导入模板.csv",document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(h)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:L.openBatchModal,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Bt,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>x(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(dt,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-surface-muted p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(Ta,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:v,onChange:d=>C(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(Rt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:D,onChange:d=>_(d.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",O.length," / ",t.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:O.map(d=>{let q="";return d.type==="data"&&d.data_content?q=`库存: ${d.data_content.split(`
`).filter(E=>E.trim()).length} 条`:d.type==="text"&&d.text_content?q=d.text_content:d.type==="api"&&d.api_config?q=d.api_config.url:d.type==="image"&&d.image_url&&(q="图片链接"),e.jsxs("tr",{className:"hover:bg-warning-50/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(ei,{type:d.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:d.name,children:d.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>F(d.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:d.id}),e.jsx(Nr,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${d.type==="text"?"bg-blue-50 text-blue-600":d.type==="data"?"bg-purple-50 text-purple-600":d.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:d.type==="text"?"文本":d.type==="data"?"批量":d.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:q,children:q})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:d.description||"-",children:d.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>N(d),className:`w-12 h-8 rounded-full relative transition-colors ${d.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${d.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>W(d),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(St,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>X(d.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(st,{className:"h-4 w-4"})})]})})]},d.id)})})]})}),O.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(Aa,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:t.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),a&&p&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>l(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:u.name||"",onChange:d=>j({...u,name:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:u.type||"text",onChange:d=>j({...u,type:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(p==null?void 0:p.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),u.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:u.api_url||"",onChange:d=>j({...u,api_url:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxsLine truncated
卡号1:密码1
卡号2:密码2
或者
兑换码1
兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:u.data_content?u.data_content.split(`
`).filter(d=>d.trim()).length:0})," 条"]})]})]}),u.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:u.image_url||"",onChange:d=>j({...u,image_url:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),u.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:u.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:d=>{d.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:u.delay_seconds||0,onChange:d=>j({...u,delay_seconds:parseInt(d.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:u.description||"",onChange:d=>j({...u,description:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>j({...u,enabled:!u.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${u.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${u.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>l(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:K,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ot,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),n&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>x(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:m.name,onChange:d=>b({...m,name:d.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>b({...m,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${m.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(Os,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>b({...m,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${m.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Aa,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>b({...m,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${m.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children: Line truncated
`).filter(d=>d.trim()).length:0})," 条"]})]})]}),u.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:u.image_url||"",onChange:d=>j({...u,image_url:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),u.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:u.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:d=>{d.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:u.delay_seconds||0,onChange:d=>j({...u,delay_seconds:parseInt(d.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:u.description||"",onChange:d=>j({...u,description:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>j({...u,enabled:!u.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${u.enabled?"bg-brand":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${u.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>l(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:K,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ct,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),n&&Me.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>x(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:m.name,onChange:d=>g({...m,name:d.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>g({...m,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${m.type==="data"?"bg-brand text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(Ts,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>g({...m,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${m.type==="text"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(Ea,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>g({...m,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${m.type==="image"?"bg-brand text-white":"bg-gray-100 text-gray-600"}`,children: Line truncated
CODE-789012
...`:"请输入每次发货时发送的固定文字"}),m.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-brand",children:m.content.split(`
`).filter(d=>d.trim()).length})," 条"]})]}),m.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:m.api_method,onChange:d=>b({...m,api_method:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:m.api_timeout,onChange:d=>b({...m,api_timeout:parseInt(d.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:m.api_headers,onChange:d=>b({...m,api_headers:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:m.api_params,onChange:d=>b({...m,api_params:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:m.description,onChange:d=>b({...m,description:d.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:m.delay_seconds,onChange:d=>b({...m,delay_seconds:parseInt(d.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>x(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:_,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ct,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),e.jsx(Qn,{dataCards:O,downloadCardTemplate:G,...R})]})},ca="ydisks-amap-js-api",ei="c9b68d4ce9a2a97f22a4a439404488ca";let Pt=null;const ti=()=>ei,si=()=>window.AMap?Promise.resolve(window.AMap):Pt||(Pt=new Promise((t,s)=>{const a=document.getElementById(ca),l=a||document.createElement("script"),n=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(p)},x=()=>{window.AMap?(n(),t(window.AMap)):(n(),s(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},p=window.setTimeout(()=>{n(),s(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=x,l.id=ca,l.async=!0,l.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(ti())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,l.onerror=()=>{n(),s(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},a||document.head.appendChild(l)}).catch(t=>{throw Pt=null,t}),Pt),ss=t=>Number.isFinite(t)&&t!==0,ai=t=>{var n,x;const s=Number((n=t.location)==null?void 0:n.lng),a=Number((x=t.location)==null?void 0:x.lat),l={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:s,latitude:a,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!l.division_id||!l.province||!l.city||!l.poi_id||!l.poi_name||!ss(s)||!ss(a)||s<-180||s>180||a<-90||a>90?null:l},ri=async(t,s)=>{if(!ss(t)||!ss(s)||t<-180||t>180||s<-90||s>90)throw new Error("经纬度无效");const a=await si();return new Promise((l,n)=>{new a.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,s],1e3,(p,f)=>{var j;if(p!=="complete"){if(p==="no_data"){l([]);return}n(new Error("高德地图附近地址查询失败,请稍后重试"));return}const u=(((j=f==null?void 0:f.poiList)==null?void 0:j.pois)||[]).map(ai).filter(m=>m!==null);l(u)})})},li=t=>t.find(s=>s.status==="running"||s.status==="canceling"),Ls=t=>t==="running"||t==="canceling",ni=t=>!!(t!=null&&t.previ Line truncated
`),Le=new Blob(["\uFEFF"+ie],{type:"text/csv;charset=utf-8"}),tt=URL.createObjectURL(Le),Ge=document.createElement("a");Ge.href=tt,Ge.download="批量铺货模板.csv",document.body.appendChild(Ge),Ge.click(),Ge.remove(),URL.revokeObjectURL(tt)},ee=()=>{T(c=>({...c,cookie_id:f||c.cookie_id})),W(!0)},ne=()=>{z(c=>({...c,cookie_id:f||c.cookie_id})),X(!0)},le=async c=>{if(!(c?f:A.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");k(!0),navigator.geolocation.getCurrentPosition(async ie=>{try{const Le=await ri(ie.coords.longitude,ie.coords.latitude);if(!Le.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");c?(Te(Le),Ue(Le[0])):(M(Le),d(Le[0]))}catch(Le){alert((Le==null?void 0:Le.message)||"获取发货地失败")}finally{k(!1)}},ie=>{k(!1),alert(ie.code===ie.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},ve=c=>l.filter(Q=>Q.cookie_id===c.cookie_id&&Q.item_id===c.item_id).length>0?l.filter(Q=>Q.cookie_id===c.cookie_id&&Q.item_id===c.item_id):l.filter(Q=>Q.cookie_id===c.cookie_id&&!Q.item_id),We=r.useMemo(()=>new Map(x.map(c=>[c.id,c])),[x]),Ae=r.useMemo(()=>j?s.filter(c=>c.cookie_id===j):s,[j,s]),ze=c=>{const Q=We.get(c),ie=(Q==null?void 0:Q.remark)||(Q==null?void 0:Q.nickname);return ie?`${ie} · ${c.slice(0,6)}`:`账号 ${c.slice(0,8)}`},Ne=c=>{const Q=We.get(c);return(Q==null?void 0:Q.remark)||(Q==null?void 0:Q.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(br,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:j,onChange:c=>m(c.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),x.map(c=>e.jsx("option",{value:c.id,children:ze(c.id)},c.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(jt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:f,onChange:c=>u(c.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),x.map(c=>e.jsx("option",{value:c.id,children:ze(c.id)},c.id))]})]})]}),e.jsxs("button",{onClick:Ke,disabled:b||!f,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(He,{className:`w-4 h-4 ${b?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ee,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(ct,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:ne,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(ns,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Ye(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Wt,{className:"w-4 h-4"}),ue&&["running","canceling"].includes(ue.status)?"继续批量任务":"批量铺货"]}),ue&&!["running","canceling"].includes(ue.status)&&e.jsx("button",{onClick:()=>void Xe(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[Ae.map(c=>{const Q=ve(c),ie=Q.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex fl Line truncated
`).filter(d=>d.trim()).length})," 条"]})]}),m.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:m.api_method,onChange:d=>g({...m,api_method:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:m.api_timeout,onChange:d=>g({...m,api_timeout:parseInt(d.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:m.api_headers,onChange:d=>g({...m,api_headers:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:m.api_params,onChange:d=>g({...m,api_params:d.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:m.description,onChange:d=>g({...m,description:d.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:m.delay_seconds,onChange:d=>g({...m,delay_seconds:parseInt(d.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>x(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:y,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(dt,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),e.jsx(Xn,{dataCards:I,downloadCardTemplate:z,...L})]})},ha="ydisks-amap-js-api",ni="c9b68d4ce9a2a97f22a4a439404488ca";let Et=null;const ii=()=>ni,oi=()=>window.AMap?Promise.resolve(window.AMap):Et||(Et=new Promise((t,s)=>{const a=document.getElementById(ha),l=a||document.createElement("script"),n=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(p)},x=()=>{window.AMap?(n(),t(window.AMap)):(n(),s(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},p=window.setTimeout(()=>{n(),s(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=x,l.id=ha,l.async=!0,l.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(ii())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,l.onerror=()=>{n(),s(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},a||document.head.appendChild(l)}).catch(t=>{throw Et=null,t}),Et),as=t=>Number.isFinite(t)&&t!==0,ci=t=>{var n,x;const s=Number((n=t.location)==null?void 0:n.lng),a=Number((x=t.location)==null?void 0:x.lat),l={area:String(t.adname||"").trim(),city:String(t.cityname||"").trim(),division_id:String(t.adcode||"").trim(),longitude:s,latitude:a,poi_id:String(t.id||"").trim(),poi_name:String(t.name||"").trim(),province:String(t.pname||"").trim()};return!l.division_id||!l.province||!l.city||!l.poi_id||!l.poi_name||!as(s)||!as(a)||s<-180||s>180||a<-90||a>90?null:l},di=async(t,s)=>{if(!as(t)||!as(s)||t<-180||t>180||s<-90||s>90)throw new Error("经纬度无效");const a=await oi();return new Promise((l,n)=>{new a.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[t,s],1e3,(p,f)=>{var j;if(p!=="complete"){if(p==="no_data"){l([]);return}n(new Error("高德地图附近地址查询失败,请稍后重试"));return}const u=(((j=f==null?void 0:f.poiList)==null?void 0:j.pois)||[]).map(ci).filter(m=>m!==null);l(u)})})},xi=t=>t.find(s=>s.status==="running"||s.status==="canceling"),Os=t=>t==="running"||t==="canceling",mi=t=>!!(t!=null&&t.previ Line truncated
`),Re=new Blob(["\uFEFF"+ie],{type:"text/csv;charset=utf-8"}),tt=URL.createObjectURL(Re),Ge=document.createElement("a");Ge.href=tt,Ge.download="批量铺货模板.csv",document.body.appendChild(Ge),Ge.click(),Ge.remove(),URL.revokeObjectURL(tt)},ee=()=>{$(c=>({...c,cookie_id:f||c.cookie_id})),W(!0)},ne=()=>{G(c=>({...c,cookie_id:f||c.cookie_id})),X(!0)},le=async c=>{if(!(c?f:R.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");N(!0),navigator.geolocation.getCurrentPosition(async ie=>{try{const Re=await di(ie.coords.longitude,ie.coords.latitude);if(!Re.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");c?(Te(Re),Ue(Re[0])):(O(Re),d(Re[0]))}catch(Re){alert((Re==null?void 0:Re.message)||"获取发货地失败")}finally{N(!1)}},ie=>{N(!1),alert(ie.code===ie.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},ve=c=>l.filter(V=>V.cookie_id===c.cookie_id&&V.item_id===c.item_id).length>0?l.filter(V=>V.cookie_id===c.cookie_id&&V.item_id===c.item_id):l.filter(V=>V.cookie_id===c.cookie_id&&!V.item_id),We=r.useMemo(()=>new Map(x.map(c=>[c.id,c])),[x]),Ae=r.useMemo(()=>j?s.filter(c=>c.cookie_id===j):s,[j,s]),ze=c=>{const V=We.get(c),ie=(V==null?void 0:V.remark)||(V==null?void 0:V.nickname);return ie?`${ie} · ${c.slice(0,6)}`:`账号 ${c.slice(0,8)}`},Ne=c=>{const V=We.get(c);return(V==null?void 0:V.remark)||(V==null?void 0:V.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(_r,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:j,onChange:c=>m(c.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),x.map(c=>e.jsx("option",{value:c.id,children:ze(c.id)},c.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(vt,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:f,onChange:c=>u(c.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),x.map(c=>e.jsx("option",{value:c.id,children:ze(c.id)},c.id))]})]})]}),e.jsxs("button",{onClick:Ke,disabled:g||!f,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(He,{className:`w-4 h-4 ${g?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ee,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(dt,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:ne,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(is,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Ye(),className:"px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(Gt,{className:"w-4 h-4"}),ue&&["running","canceling"].includes(ue.status)?"继续批量任务":"批量铺货"]}),ue&&!["running","canceling"].includes(ue.status)&&e.jsx("button",{onClick:()=>void Xe(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[Ae.map(c=>{const V=ve(c),ie=V.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex fl Line truncated
+1 -1
View File
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ydisks闲鱼助手 - 自动发货与管家系统</title>
<meta name="description" content="Ydisks闲鱼助手 - 自动回复、自动发货、订单管理、AI智能议价一体化解决方案" />
<script type="module" crossorigin src="/static/assets/index-DMOAPZ9K.js"></script>
<script type="module" crossorigin src="/static/assets/index-CQUrFUKL.js"></script>
<link rel="modulepreload" crossorigin href="/static/assets/react-vendor-C_od1ZSF.js">
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-i_74xDZy.js">
<link rel="modulepreload" crossorigin href="/static/assets/vendor-D-Edl3pr.js">