下沉 Rules 动作协调器

This commit is contained in:
Christ committed 2026-08-15 21:10:19 +08:00
1 parent 48a0a2c4bd
commit fdc67bf938
17 files changed
+669 -535

No files matched your search

@@ -191,6 +191,7 @@ app shell / routes
- 已完成阶段 7 当前 PR 切片“React OrderList 完整页面行为边界”:新增真实挂载 `OrderList` 的组合测试,覆盖筛选栏状态转发、同步与导入入口、详情弹窗、编辑字段映射、状态发货、单笔同步、删除分页分支和上一页/下一页函数式更新;分页按钮补充稳定的无障碍名称,测试隔离订单查询 Hook、导入状态、API 和筛选子组件,不跳过页面协调逻辑。OrderList 动作协调器进一步 feature 化、Rules/ItemList/CardList 等其他大型页面行为覆盖、页面级 Provider 组合和阶段 7 总体验收仍待完成;
- 已完成阶段 7 当前 PR 切片“React OrderList 动作协调器 feature 化”:新增 `app/features/orders/orderActions.ts` 与对应 Hook 测试,将订单同步、发货、详情、编辑草稿、单笔同步、删除分页回退和弹窗生命周期从 `OrderList` 根组件迁入 feature;根组件只保留查询、筛选、页面组合和展示字段更新,编辑字段通过函数式补丁进入协调器;成功、失败、取消和异常结果均有 Hook/页面回归证据。Rules/ItemList/CardList 等其他大型页面行为覆盖、页面级 Provider 组合和阶段 7 总体验收仍待完成;
- 已完成阶段 7 当前 PR 切片“React CardList 动作协调器 feature 化”:新增 `app/features/cards/cardActions.ts`,将卡密新增、编辑、删除、启停、筛选、复制和模板下载从 `CardList` 根组件迁入 cards feature;批量导入仍复用既有批量 Hook,页面根组件只负责状态组合和表单展示;新增动作 Hook 与真实页面组合测试,覆盖筛选、批量入口、新增/编辑字段映射、启停、复制和删除。Rules/ItemList 等其他大型页面行为覆盖、页面级 Provider 组合和阶段 7 总体验收仍待完成;
- 已完成阶段 7 当前 PR 切片“React Rules 动作协调器 feature 化”:新增 `app/features/rules/ruleActions.ts`,将自动化规则草稿、触发类型/规格编辑、保存删除、异常恢复、关键词回复和默认回复动作,以及商品页联动加载从 `Rules` 根组件迁入 rules feature;同步更新路由静态契约测试,新增 Hook 测试覆盖自动化规则归一化保存、三类回复保存、触发/规格编辑、删除和异常恢复;前端全量 366 个测试、类型检查、中文注释门禁和生产构建通过。ItemList 其他大型页面行为覆盖、页面级 Provider 组合和阶段 7 总体验收仍待完成;
- 禁止跳过当前入口直接开始 Engine、Automation 或 DB 的大规模拆分。
## 6. 阶段 0:治理文档与强约束
@@ -779,3 +780,4 @@ npm --prefix frontend run build
| 2026-08-15 | P2 React OrderList 完整页面行为边界 | 已完成本切片 | 新增 `frontend/components/OrderList.test.tsx`,真实挂载订单页面并隔离查询/导入 Hook、订单 API 和筛选/导入子组件;覆盖筛选转发、同步提示、导入入口、详情打开关闭、编辑字段转换、状态发货结果、单笔同步、删除时分页回退和分页函数式更新;分页按钮增加“上一页/下一页”无障碍名称。OrderList 动作协调器、Rules/ItemList/CardList 等其他大型页面、页面级 Provider 组合和阶段 7 总体验收仍未完成 |
| 2026-08-15 | P2 React OrderList 动作协调器 feature 化 | 已完成本切片 | 新增 `frontend/app/features/orders/orderActions.ts` 与 `orderActions.test.tsx`,将同步、发货、详情、编辑、单笔同步、删除分页回退和弹窗关闭状态从 `OrderList` 根组件迁入订单 feature;编辑表单通过 `updateEditingOrder` 函数式补丁更新,保留原有 API、提示和结果语义;Hook 测试覆盖同步/发货/编辑/删除异常、确认取消和弹窗清理,页面组合测试继续覆盖成功流程。Rules/ItemList/CardList 等其他大型页面行为覆盖、页面级 Provider 组合和阶段 7 总体验收仍未完成 |
| 2026-08-15 | P2 React CardList 动作协调器 feature 化 | 已完成本切片 | 新增 `frontend/app/features/cards/cardActions.ts` 和 `cardActions.test.tsx`,将卡密新增、编辑、删除、启停、筛选、复制和模板下载状态/动作从 `CardList` 根组件迁入 cards feature;新增 `CardList.test.tsx` 真实挂载页面,覆盖筛选计数、批量导入入口、新增/编辑字段映射、启停、复制和删除;补充行级按钮无障碍名称。Rules/ItemList 等其他大型页面行为覆盖、页面级 Provider 组合和阶段 7 总体验收仍未完成 |
| 2026-08-15 | P2 React Rules 动作协调器 feature 化 | 已完成本切片 | 新增 `frontend/app/features/rules/ruleActions.ts` 和 `ruleActions.test.tsx`,将自动化规则、关键词回复、默认回复的草稿与动作状态从 `Rules` 根组件迁入 rules feature;保留商品页联动加载、触发/规格编辑、归一化保存、异常恢复与确认语义,更新路由静态契约测试以跟随实现边界;前端全量 366 个测试、类型检查、中文注释门禁和生产构建通过。ItemList 其他大型页面行为覆盖、页面级 Provider 组合和阶段 7 总体验收仍未完成 |
@@ -0,0 +1,157 @@
// @vitest-environment jsdom
import { act, renderHook } from '@testing-library/react';
import { useState } from 'react';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import type { Card, DefaultReply, Item, ShippingRule } from './types';
import { clearDefaultReplyRecords, deleteDefaultReply, deleteReplyRule, deleteShippingRule, getDefaultReply, resolveAutomationRun, resolveDeferredAutomationTask, updateDefaultReply, updateReplyRule, updateShippingRule } from './api';
import { useRuleActions, type RuleActionsOptions } from './ruleActions';
vi.mock('./api', /* ruleActionsApiMockFactory 提供规则动作 Hook 的确定性 API 替身。 */ () => ({
clearDefaultReplyRecords: vi.fn(),
deleteDefaultReply: vi.fn(),
deleteReplyRule: vi.fn(),
deleteShippingRule: vi.fn(),
getCards: vi.fn(),
getDefaultReply: vi.fn(),
getItems: vi.fn(),
getShippingRules: vi.fn(),
resolveAutomationRun: vi.fn(),
resolveDeferredAutomationTask: vi.fn(),
updateDefaultReply: vi.fn(),
updateReplyRule: vi.fn(),
updateShippingRule: vi.fn(),
}));
// defaultReplyMock 是默认回复读取接口的可控替身。
const defaultReplyMock = vi.mocked(getDefaultReply);
// updateDefaultMock 是默认回复保存接口的可控替身。
const updateDefaultMock = vi.mocked(updateDefaultReply);
// updateReplyMock 是关键词回复保存接口的可控替身。
const updateReplyMock = vi.mocked(updateReplyRule);
// updateShippingMock 是自动化规则保存接口的可控替身。
const updateShippingMock = vi.mocked(updateShippingRule);
// deleteShippingMock 是自动化规则删除接口的可控替身。
const deleteShippingMock = vi.mocked(deleteShippingRule);
// resolveRunMock 是自动化运行恢复接口的可控替身。
const resolveRunMock = vi.mocked(resolveAutomationRun);
// resolveDeferredMock 是延迟任务恢复接口的可控替身。
const resolveDeferredMock = vi.mocked(resolveDeferredAutomationTask);
// deleteReplyMock 是关键词回复删除接口的可控替身。
const deleteReplyMock = vi.mocked(deleteReplyRule);
// deleteDefaultMock 是默认回复删除接口的可控替身。
const deleteDefaultMock = vi.mocked(deleteDefaultReply);
// clearRecordsMock 是默认回复记录清理接口的可控替身。
const clearRecordsMock = vi.mocked(clearDefaultReplyRecords);
// itemFixture 是自动化规则草稿使用的商品。
const itemFixture = { cookie_id: 'account-1', item_id: 'item-1', item_title: '测试商品', is_multi_spec: false } as Item;
// cardFixture 是规则动作依赖的卡密库存。
const cardFixture = { id: 7, name: '测试卡密', type: 'data' } as Card;
// defaultReplyFixture 是默认回复读取结果。
const defaultReplyFixture = { cookie_id: 'account-1', enabled: true, reply_content: '欢迎', reply_once: false, reply_image_url: '' } as DefaultReply;
// useRuleActionsHarness 创建带有真实 React 状态容器的规则动作 Hook。
const useRuleActionsHarness = () => {
// selectedAccountId 保存测试中的当前账号。
const [selectedAccountId, setSelectedAccountId] = useState('account-1');
// activeTab 保存测试中的当前页签。
const [, setActiveTab] = useState<'automation' | 'reply' | 'default'>('automation');
// items 保存测试中的商品参考数据。
const [items] = useState<Item[]>([itemFixture]);
// automationRules 保存外部联动写入的规则列表。
const [, setAutomationRules] = useState<ShippingRule[]>([]);
// cards 保存外部联动写入的卡密列表。
const [, setCards] = useState<Card[]>([cardFixture]);
// linkedItems 保存外部联动写入的商品列表。
const [, setItems] = useState<Item[]>([itemFixture]);
// loading 保存测试中的加载指示器。
const [, setLoading] = useState(false);
// loadAutomationRules 是自动化规则刷新替身。
const loadAutomationRules = vi.fn(async () => undefined);
// loadReferenceData 是规则参考数据刷新替身。
const loadReferenceData = vi.fn(async () => undefined);
// loadReplyRules 是关键词回复刷新替身。
const loadReplyRules = vi.fn(async () => undefined);
// loadDefaultReplies 是默认回复刷新替身。
const loadDefaultReplies = vi.fn(async () => undefined);
// options 是规则动作 Hook 的完整依赖。
const options: RuleActionsOptions = { selectedAccountId, setSelectedAccountId, setActiveTab, items, setAutomationRules, setCards, setItems: /* setItemsAction 写入外部联动商品列表。 */ linkedItems => setItems(linkedItems), setLoading, loadAutomationRules, loadReferenceData, loadReplyRules, loadDefaultReplies };
return useRuleActions(options);
};
describe('useRuleActions', /* 当前回调验证规则页面动作协调器的核心状态和副作用。 */ () => {
beforeEach(/* 当前回调重置规则动作 API 替身。 */ () => {
vi.clearAllMocks();
defaultReplyMock.mockResolvedValue(defaultReplyFixture);
updateDefaultMock.mockResolvedValue({ success: true });
updateReplyMock.mockResolvedValue({ success: true });
updateShippingMock.mockResolvedValue({ success: true });
deleteShippingMock.mockResolvedValue({ success: true });
resolveRunMock.mockResolvedValue({ success: true });
resolveDeferredMock.mockResolvedValue({ success: true });
deleteReplyMock.mockResolvedValue({ success: true });
deleteDefaultMock.mockResolvedValue({ success: true });
clearRecordsMock.mockResolvedValue({ success: true });
vi.stubGlobal('alert', vi.fn());
vi.stubGlobal('confirm', vi.fn(() => true));
});
afterEach(/* 当前回调清理规则动作测试中的全局替身。 */ () => vi.unstubAllGlobals());
test('创建并保存自动化规则时归一化规格和刷新数据', /* 当前回调验证自动化规则草稿与保存边界。 */ async () => {
// hook 是规则动作 Hook 的真实 React 状态实例。
const hook = renderHook(() => useRuleActionsHarness());
act(/* 当前回调打开新建自动化规则弹窗。 */ () => hook.result.current.openNewAutomationRule());
expect(hook.result.current.showAutomationModal).toBe(true);
act(/* 当前回调写入需要保存的卡密规格。 */ () => hook.result.current.setEditingAutomationRule(/* currentDraft 更新自动化规则草稿。 */ current => ({ ...current, cookie_id: 'account-1', variants: [{ id: 'variant-1', spec_name: '', spec_value: '', card_id: 7, delivery_count: 0, enabled: true }] })));
await act(/* 当前回调执行自动化规则保存。 */ async () => hook.result.current.handleSaveAutomationRule());
expect(updateShippingMock).toHaveBeenCalledWith(expect.objectContaining({ cookie_id: 'account-1', variants: [expect.objectContaining({ card_id: 7, delivery_count: 1 })] }));
expect(hook.result.current.showAutomationModal).toBe(false);
hook.unmount();
});
test('关键词和默认回复动作分别读取、保存并刷新', /* 当前回调验证两个回复页签的动作边界。 */ async () => {
// hook 是规则动作 Hook 的真实 React 状态实例。
const hook = renderHook(() => useRuleActionsHarness());
act(/* 当前回调打开关键词新增弹窗。 */ () => hook.result.current.handleAddReplyRule());
act(/* 当前回调填写关键词回复草稿。 */ () => hook.result.current.setEditingReplyRule(/* currentDraft 更新关键词回复草稿。 */ current => ({ ...current, keyword: '你好', reply_content: '您好' })));
await act(/* 当前回调保存关键词回复规则。 */ async () => hook.result.current.handleSaveReplyRule());
expect(updateReplyMock).toHaveBeenCalledWith(expect.objectContaining({ keyword: '你好', match_type: 'fuzzy', enabled: true }), 'account-1');
await act(/* 当前回调打开默认回复弹窗并加载服务端数据。 */ async () => hook.result.current.openDefaultReplyModal());
expect(hook.result.current.defaultForm).toEqual(expect.objectContaining({ reply_content: '欢迎', enabled: true }));
await act(/* 当前回调保存默认回复配置。 */ async () => hook.result.current.handleSaveDefaultReply());
expect(updateDefaultMock).toHaveBeenCalledWith('account-1', expect.objectContaining({ reply_content: '欢迎', enabled: true }));
hook.unmount();
});
test('规则编辑、异常恢复和删除动作均通过统一协调器', /* 当前回调覆盖规则动作 Hook 的剩余公开方法。 */ async () => {
// hook 是规则动作 Hook 的真实 React 状态实例。
const hook = renderHook(() => useRuleActionsHarness());
act(/* 当前回调打开自动化规则草稿。 */ () => hook.result.current.openNewAutomationRule());
act(/* 当前回调切换规则触发类型。 */ () => hook.result.current.handleTriggerChange('buyer_reviewed'));
act(/* 当前回调更新第一行规格。 */ () => hook.result.current.updateVariant(0, { card_id: 7 }));
act(/* 当前回调追加第二行规格。 */ () => hook.result.current.appendDeliveryContent());
expect(hook.result.current.displayVariants).toHaveLength(2);
act(/* 当前回调切换规则绑定商品。 */ () => hook.result.current.handleAutomationItemChange('item-1'));
// rule 是用于切换和删除动作的自动化规则样本。
const rule = { id: 'rule-1', cookie_id: 'account-1', trigger_type: 'order_paid', enabled: true } as ShippingRule;
await act(/* 当前回调切换规则启用状态。 */ async () => hook.result.current.handleToggleAutomation(rule));
await act(/* 当前回调删除自动化规则。 */ async () => hook.result.current.handleDeleteAutomation('rule-1'));
await act(/* 当前回调恢复暂停中的自动化运行。 */ async () => hook.result.current.handleResolveRunIssue(1, 'retry'));
await act(/* 当前回调恢复延迟自动化任务。 */ async () => hook.result.current.handleResolveDeferredIssue(2, 'dismiss'));
await act(/* 当前回调删除关键词回复规则。 */ async () => hook.result.current.handleDeleteReply('reply-1'));
await act(/* 当前回调删除默认回复配置。 */ async () => hook.result.current.handleDeleteDefaultReply('account-1'));
await act(/* 当前回调清空默认回复记录。 */ async () => hook.result.current.handleClearDefaultReplyRecords('account-1'));
expect(updateShippingMock).toHaveBeenCalledWith(expect.objectContaining({ id: 'rule-1', enabled: false }));
expect(deleteShippingMock).toHaveBeenCalledWith('rule-1');
expect(resolveRunMock).toHaveBeenCalledWith(1, 'retry');
expect(resolveDeferredMock).toHaveBeenCalledWith(2, 'dismiss');
expect(deleteReplyMock).toHaveBeenCalledWith('reply-1', 'account-1');
expect(deleteDefaultMock).toHaveBeenCalledWith('account-1');
expect(clearRecordsMock).toHaveBeenCalledWith('account-1');
hook.unmount();
});
});
+460
View File
@@ -0,0 +1,460 @@
import { useCallback, useEffect, useMemo, useState, type Dispatch, type SetStateAction } from 'react';
import type { AutomationTriggerType, Card, Item, ReplyRule, ShippingRule, ShippingVariant } from './types';
import {
clearDefaultReplyRecords,
deleteDefaultReply,
deleteReplyRule,
deleteShippingRule,
getCards,
getDefaultReply,
getItems,
getShippingRules,
resolveAutomationRun,
resolveDeferredAutomationTask,
updateDefaultReply,
updateReplyRule,
updateShippingRule,
} from './api';
import { boolFlag, buildReviewConfig, cardActionsForTrigger, defaultRuleName, emptyVariant, parseJSONObject, shouldReplaceGeneratedName, triggerMeta } from './utils';
import type { DefaultReplyForm, RulesProps, RulesTab } from './types';
import { finishRuleSubmission, idleRuleSubmitState, startRuleSubmission, type RuleSubmitState } from './interactionState';
// RuleActionsOptions 描述规则动作协调器依赖的页面数据、刷新函数和外部联动目标。
export interface RuleActionsOptions {
// selectedAccountId 保存当前规则页面选择的账号。
selectedAccountId: string;
// setSelectedAccountId 更新当前规则页面选择的账号。
setSelectedAccountId: Dispatch<SetStateAction<string>>;
// setActiveTab 将外部联动切换到自动化页签。
setActiveTab: Dispatch<SetStateAction<RulesTab>>;
// items 保存规则编辑器可绑定的商品列表。
items: Item[];
// setAutomationRules 写入外部联动场景加载的自动化规则。
setAutomationRules: Dispatch<SetStateAction<ShippingRule[]>>;
// setCards 写入外部联动场景加载的卡密库存。
setCards: Dispatch<SetStateAction<Card[]>>;
// setItems 写入外部联动场景加载的商品列表。
setItems: Dispatch<SetStateAction<Item[]>>;
// setLoading 更新规则页面的加载指示器。
setLoading: Dispatch<SetStateAction<boolean>>;
// loadAutomationRules 刷新自动化规则和异常任务。
loadAutomationRules: () => Promise<void>;
// loadReferenceData 刷新规则编辑器参考数据。
loadReferenceData: () => Promise<void>;
// loadReplyRules 刷新关键词回复规则。
loadReplyRules: () => Promise<void>;
// loadDefaultReplies 刷新账号默认回复。
loadDefaultReplies: () => Promise<void>;
// initialDeliveryTarget 保存商品页跳转到规则页的目标。
initialDeliveryTarget?: RulesProps['initialDeliveryTarget'];
// onDeliveryTargetHandled 通知父页面外部跳转已完成。
onDeliveryTargetHandled?: () => void;
}
// RuleActionsState 暴露规则页弹窗状态、编辑草稿和业务动作。
export interface RuleActionsState {
// showAutomationModal 表示自动化规则弹窗是否打开。
showAutomationModal: boolean;
// setShowAutomationModal 更新自动化规则弹窗展示状态。
setShowAutomationModal: Dispatch<SetStateAction<boolean>>;
// showReplyModal 表示关键词回复弹窗是否打开。
showReplyModal: boolean;
// setShowReplyModal 更新关键词回复弹窗展示状态。
setShowReplyModal: Dispatch<SetStateAction<boolean>>;
// showDefaultModal 表示默认回复弹窗是否打开。
showDefaultModal: boolean;
// setShowDefaultModal 更新默认回复弹窗展示状态。
setShowDefaultModal: Dispatch<SetStateAction<boolean>>;
// automationSubmitState 保存自动化规则提交状态。
automationSubmitState: RuleSubmitState;
// replySubmitState 保存关键词回复提交状态。
replySubmitState: RuleSubmitState;
// defaultReplySubmitState 保存默认回复提交状态。
defaultReplySubmitState: RuleSubmitState;
// editingAutomationRule 保存当前自动化规则草稿。
editingAutomationRule: Partial<ShippingRule> | null;
// setEditingAutomationRule 更新自动化规则草稿。
setEditingAutomationRule: Dispatch<SetStateAction<Partial<ShippingRule> | null>>;
// editingReplyRule 保存当前关键词回复草稿。
editingReplyRule: Partial<ReplyRule> | null;
// setEditingReplyRule 更新关键词回复草稿。
setEditingReplyRule: Dispatch<SetStateAction<Partial<ReplyRule> | null>>;
// defaultForm 保存当前默认回复草稿。
defaultForm: DefaultReplyForm;
// setDefaultForm 更新默认回复草稿。
setDefaultForm: Dispatch<SetStateAction<DefaultReplyForm>>;
// selectedRuleItem 保存当前规则草稿绑定的商品。
selectedRuleItem: Item | undefined;
// isMultiSpecRule 表示当前商品是否需要多规格字段。
isMultiSpecRule: boolean;
// currentTrigger 保存当前规则草稿的触发类型。
currentTrigger: AutomationTriggerType;
// currentMeta 保存当前触发类型的展示元数据。
currentMeta: typeof triggerMeta[AutomationTriggerType];
// reviewConfig 保存当前评价规则配置对象。
reviewConfig: Record<string, unknown>;
// displayVariants 保存至少包含一行的规格草稿。
displayVariants: ShippingVariant[];
// buildAutomationDraft 创建指定触发类型的规则草稿。
buildAutomationDraft: (trigger?: AutomationTriggerType, cookieID?: string, itemID?: string) => Partial<ShippingRule>;
// openAutomationRule 打开指定自动化规则的编辑弹窗。
openAutomationRule: (rule: ShippingRule) => void;
// openNewAutomationRule 打开新建自动化规则弹窗。
openNewAutomationRule: (trigger?: AutomationTriggerType) => void;
// handleTriggerChange 切换当前规则的触发类型。
handleTriggerChange: (trigger: AutomationTriggerType) => void;
// handleAutomationItemChange 切换当前规则绑定的商品。
handleAutomationItemChange: (itemID: string) => void;
// updateVariant 更新指定发货规格的字段。
updateVariant: (index: number, patch: Partial<ShippingVariant>) => void;
// appendDeliveryContent 追加一行发货规格。
appendDeliveryContent: () => void;
// handleSaveAutomationRule 保存当前自动化规则。
handleSaveAutomationRule: () => Promise<void>;
// handleDeleteAutomation 删除指定自动化规则。
handleDeleteAutomation: (id: string) => Promise<void>;
// handleToggleAutomation 切换指定自动化规则启用状态。
handleToggleAutomation: (rule: ShippingRule) => Promise<void>;
// handleResolveRunIssue 处理暂停中的自动化运行。
handleResolveRunIssue: (id: number, resolution: 'continue' | 'retry' | 'cancel') => Promise<void>;
// handleResolveDeferredIssue 处理等待重试的自动化任务。
handleResolveDeferredIssue: (id: number, resolution: 'retry' | 'dismiss') => Promise<void>;
// handleAddReplyRule 打开新增关键词回复弹窗。
handleAddReplyRule: () => void;
// handleSaveReplyRule 保存当前关键词回复规则。
handleSaveReplyRule: () => Promise<void>;
// handleDeleteReply 删除指定关键词回复规则。
handleDeleteReply: (id: string) => Promise<void>;
// openDefaultReplyModal 打开指定账号的默认回复弹窗。
openDefaultReplyModal: (cookieID?: string) => Promise<void>;
// handleSaveDefaultReply 保存当前默认回复配置。
handleSaveDefaultReply: () => Promise<void>;
// handleDeleteDefaultReply 删除指定账号的默认回复配置。
handleDeleteDefaultReply: (cookieID: string) => Promise<void>;
// handleClearDefaultReplyRecords 清空指定账号的默认回复记录。
handleClearDefaultReplyRecords: (cookieID: string) => Promise<void>;
}
// useRuleActions 集中管理规则页三类规则的编辑、保存、删除和异常恢复动作。
export const useRuleActions = ({
selectedAccountId,
setSelectedAccountId,
setActiveTab,
items,
setAutomationRules,
setCards,
setItems,
setLoading,
loadAutomationRules,
loadReferenceData,
loadReplyRules,
loadDefaultReplies,
initialDeliveryTarget,
onDeliveryTargetHandled,
}: RuleActionsOptions): RuleActionsState => {
// showAutomationModal 表示自动化规则弹窗是否打开。
const [showAutomationModal, setShowAutomationModal] = useState(false);
// showReplyModal 表示关键词回复弹窗是否打开。
const [showReplyModal, setShowReplyModal] = useState(false);
// showDefaultModal 表示默认回复弹窗是否打开。
const [showDefaultModal, setShowDefaultModal] = useState(false);
// automationSubmitState 保存自动化规则提交状态。
const [automationSubmitState, setAutomationSubmitState] = useState<RuleSubmitState>(idleRuleSubmitState);
// replySubmitState 保存关键词回复提交状态。
const [replySubmitState, setReplySubmitState] = useState<RuleSubmitState>(idleRuleSubmitState);
// defaultReplySubmitState 保存默认回复提交状态。
const [defaultReplySubmitState, setDefaultReplySubmitState] = useState<RuleSubmitState>(idleRuleSubmitState);
// editingAutomationRule 保存当前自动化规则草稿。
const [editingAutomationRule, setEditingAutomationRule] = useState<Partial<ShippingRule> | null>(null);
// editingReplyRule 保存当前关键词回复草稿。
const [editingReplyRule, setEditingReplyRule] = useState<Partial<ReplyRule> | null>(null);
// defaultForm 保存当前默认回复草稿。
const [defaultForm, setDefaultForm] = useState<DefaultReplyForm>({ cookie_id: '', enabled: false, reply_content: '', reply_once: false, reply_image_url: '' });
// selectedRuleItem 查找当前自动化规则草稿绑定的商品。
const selectedRuleItem = useMemo(
/* 当前回调计算规则草稿绑定的商品。 */ () => editingAutomationRule?.cookie_id && editingAutomationRule.item_id
? items.find(/* 当前回调查找匹配的商品。 */ item => item.cookie_id === editingAutomationRule.cookie_id && item.item_id === editingAutomationRule.item_id)
: undefined,
[editingAutomationRule?.cookie_id, editingAutomationRule?.item_id, items],
);
// isMultiSpecRule 表示当前商品是否需要填写规格名称和值。
const isMultiSpecRule = boolFlag(selectedRuleItem?.is_multi_spec);
// currentTrigger 保存当前规则草稿的触发类型。
const currentTrigger = (editingAutomationRule?.trigger_type || 'order_paid') as AutomationTriggerType;
// currentMeta 保存当前触发类型的页面展示元数据。
const currentMeta = triggerMeta[currentTrigger];
// reviewConfig 将当前评价规则配置解析为对象。
const reviewConfig = parseJSONObject(editingAutomationRule?.config_json);
// displayVariants 为编辑器提供至少一行规格数据。
const displayVariants = editingAutomationRule?.variants?.length ? editingAutomationRule.variants : [emptyVariant()];
// buildAutomationDraft 创建指定触发类型的默认规则草稿。
const buildAutomationDraft = useCallback(/* buildDraftAction 创建规则默认草稿。 */ (trigger: AutomationTriggerType = 'order_paid', cookieID = selectedAccountId, itemID = ''): Partial<ShippingRule> => {
// item 保存规则绑定的商品。
const item = items.find(/* 当前回调查找规则绑定的商品。 */ candidate => candidate.cookie_id === cookieID && candidate.item_id === itemID);
// itemLabel 保存规则名称使用的商品标签。
const itemLabel = item?.item_title || itemID;
return {
name: defaultRuleName(trigger, itemLabel), trigger_type: trigger, cookie_id: cookieID, item_id: itemID,
item_title: item?.item_title || '', item_keyword: itemLabel, card_group_id: 0, priority: 100, enabled: true,
config_json: trigger === 'review_missing_timeout' ? buildReviewConfig() : '{}', actions: cardActionsForTrigger(trigger),
variants: trigger === 'review_missing_timeout' ? [] : [emptyVariant()],
};
}, [items, selectedAccountId]);
// openAutomationRule 将已有规则复制为草稿并打开编辑弹窗。
const openAutomationRule = useCallback(/* openRuleAction 打开已有规则草稿。 */ (rule: ShippingRule) => {
// trigger 保存已有规则的触发类型。
const trigger = (rule.trigger_type || 'order_paid') as AutomationTriggerType;
setEditingAutomationRule({
...rule,
trigger_type: trigger,
config_json: trigger === 'review_missing_timeout' ? buildReviewConfig(rule.config_json) : (rule.config_json || '{}'),
actions: rule.actions?.length ? rule.actions.map(/* 当前回调复制自动化动作。 */ action => ({ ...action })) : cardActionsForTrigger(trigger, rule.card_group_id),
variants: rule.variants?.length ? rule.variants.map(/* 当前回调复制发货规格。 */ variant => ({ ...variant })) : (trigger === 'review_missing_timeout' ? [] : [emptyVariant()]),
});
setShowAutomationModal(true);
}, []);
// useEffect 处理商品页跳转到规则页时的异步加载和取消。
useEffect(/* 当前回调处理外部商品联动。 */ () => {
if (!initialDeliveryTarget) return;
// cancelled 标记外部跳转加载是否已经失效。
let cancelled = false;
// openLinkedRule 加载跳转目标对应的规则、商品和卡密数据。
const openLinkedRule = async () => {
setActiveTab('automation');
setSelectedAccountId(initialDeliveryTarget.cookieId);
setLoading(true);
try {
// ruleList 保存当前账号的自动化规则。
const [ruleList, itemList, cardList] = await Promise.all([
getShippingRules(), getItems(), getCards().catch(/* error 表示卡密参考数据加载异常。 */ error => {
console.warn('加载卡密库存失败,不阻断打开自动化规则', error);
return [];
}),
]);
if (cancelled) return;
setAutomationRules(ruleList);
setItems(itemList);
setCards(cardList);
// rule 保存跳转商品已有的订单支付规则。
const rule = ruleList.find(/* 当前回调查找跳转目标规则。 */ candidate => candidate.cookie_id === initialDeliveryTarget.cookieId && candidate.item_id === initialDeliveryTarget.itemId && candidate.trigger_type === 'order_paid');
if (rule) {
openAutomationRule(rule);
} else {
// item 保存跳转商品的参考数据。
const item = itemList.find(/* 当前回调查找跳转目标商品。 */ candidate => candidate.cookie_id === initialDeliveryTarget.cookieId && candidate.item_id === initialDeliveryTarget.itemId);
setEditingAutomationRule({
...buildAutomationDraft('order_paid', initialDeliveryTarget.cookieId, initialDeliveryTarget.itemId),
item_title: item?.item_title || '', item_keyword: item?.item_title || initialDeliveryTarget.itemId,
name: defaultRuleName('order_paid', item?.item_title || initialDeliveryTarget.itemId),
});
setShowAutomationModal(true);
}
} catch (/* error 表示外部联动加载异常。 */ error) {
console.error('打开商品自动化规则失败', error);
alert('无法加载该商品的自动化规则');
} finally {
if (!cancelled) {
setLoading(false);
onDeliveryTargetHandled?.();
}
}
};
void openLinkedRule();
return /* 当前回调取消外部联动请求。 */ () => { cancelled = true; };
}, [buildAutomationDraft, initialDeliveryTarget, onDeliveryTargetHandled, openAutomationRule, setActiveTab, setAutomationRules, setCards, setItems, setLoading, setSelectedAccountId]);
// openNewAutomationRule 创建指定类型的规则草稿并打开弹窗。
const openNewAutomationRule = useCallback(/* openNewAction 创建新规则草稿。 */ (trigger: AutomationTriggerType = 'order_paid') => {
if (!selectedAccountId) {
alert('请先选择账号');
return;
}
setEditingAutomationRule(buildAutomationDraft(trigger));
setShowAutomationModal(true);
}, [buildAutomationDraft, selectedAccountId]);
// handleTriggerChange 切换规则触发类型并保留当前卡密组。
const handleTriggerChange = useCallback(/* triggerAction 切换规则触发类型。 */ (trigger: AutomationTriggerType) => {
if (!editingAutomationRule) return;
// currentCardID 保存当前规则选中的卡密组。
const currentCardID = editingAutomationRule.variants?.find(/* 当前回调查找当前卡密组。 */ variant => variant.card_id)?.card_id || editingAutomationRule.actions?.find(/* 当前回调查找发卡动作。 */ action => action.action_type === 'send_card')?.card_id || editingAutomationRule.card_group_id || 0;
// itemLabel 保存当前规则商品名称。
const itemLabel = selectedRuleItem?.item_title || editingAutomationRule.item_title || editingAutomationRule.item_id || '';
setEditingAutomationRule({
...editingAutomationRule, trigger_type: trigger,
name: shouldReplaceGeneratedName(editingAutomationRule.name) ? defaultRuleName(trigger, itemLabel) : editingAutomationRule.name,
card_group_id: currentCardID, config_json: trigger === 'review_missing_timeout' ? buildReviewConfig(editingAutomationRule.config_json) : '{}',
actions: cardActionsForTrigger(trigger, currentCardID),
variants: trigger === 'review_missing_timeout' ? [] : (editingAutomationRule.variants?.length ? editingAutomationRule.variants : [{ ...emptyVariant(), card_id: currentCardID }]),
});
}, [editingAutomationRule, selectedRuleItem]);
// handleAutomationItemChange 切换规则商品并同步商品标题和默认名称。
const handleAutomationItemChange = useCallback(/* itemAction 切换规则绑定商品。 */ (itemID: string) => {
if (!editingAutomationRule) return;
// item 保存当前账号下选择的商品。
const item = items.find(/* 当前回调查找切换后的商品。 */ candidate => candidate.cookie_id === (editingAutomationRule.cookie_id || selectedAccountId) && candidate.item_id === itemID);
// itemLabel 保存商品名称或商品 ID。
const itemLabel = item?.item_title || itemID;
setEditingAutomationRule({
...editingAutomationRule, item_id: itemID, item_title: item?.item_title || '', item_keyword: itemLabel,
name: shouldReplaceGeneratedName(editingAutomationRule.name) ? defaultRuleName(currentTrigger, itemLabel) : editingAutomationRule.name,
});
}, [currentTrigger, editingAutomationRule, items, selectedAccountId]);
// updateVariant 更新规则中的一行发货规格。
const updateVariant = useCallback(/* variantAction 更新规则规格。 */ (index: number, patch: Partial<ShippingVariant>) => {
if (!editingAutomationRule) return;
// next 保存合并后的规格列表。
const next = displayVariants.map(/* 当前回调合并指定规格字段。 */ (variant, variantIndex) => variantIndex === index ? { ...variant, ...patch } : variant);
setEditingAutomationRule({ ...editingAutomationRule, variants: next, card_group_id: next[0]?.card_id || 0 });
}, [displayVariants, editingAutomationRule]);
// appendDeliveryContent 在规格编辑器末尾追加一行。
const appendDeliveryContent = useCallback(/* appendVariantAction 追加规则规格。 */ () => {
if (!editingAutomationRule) return;
// previous 保存上一行规格,用于多规格商品复制规格名称和值。
const previous = displayVariants[displayVariants.length - 1];
setEditingAutomationRule({
...editingAutomationRule,
variants: [...displayVariants, { ...emptyVariant(), spec_name: isMultiSpecRule ? previous?.spec_name || '' : '', spec_value: isMultiSpecRule ? previous?.spec_value || '' : '' }],
});
}, [displayVariants, editingAutomationRule, isMultiSpecRule]);
// handleSaveAutomationRule 校验并保存当前自动化规则。
const handleSaveAutomationRule = useCallback(/* saveRuleAction 保存自动化规则。 */ async () => {
if (!editingAutomationRule || automationSubmitState.submitting) return;
// trigger 保存当前规则触发类型。
const trigger = (editingAutomationRule.trigger_type || 'order_paid') as AutomationTriggerType;
if (!editingAutomationRule.cookie_id) return alert('请选择账号');
// variants 保存当前规格列表。
const variants = editingAutomationRule.variants?.length ? editingAutomationRule.variants : [];
if (trigger !== 'review_missing_timeout') {
if (!variants.length || variants.some(/* 当前回调校验卡密组是否已选择。 */ variant => !variant.card_id)) return alert(trigger === 'buyer_reviewed' ? '请选择评价赠品卡密库存' : '请选择发货卡密库存');
if (isMultiSpecRule && variants.some(/* 当前回调校验多规格字段。 */ variant => !variant.spec_name.trim() || !variant.spec_value.trim())) return alert('多规格商品必须填写每一行的规格名称和规格值');
}
if (trigger === 'review_missing_timeout') {
// text 保存求评价动作的文案。
const text = editingAutomationRule.actions?.find(/* 当前回调查找求评价文案动作。 */ action => action.action_type === 'send_text')?.message_template || '';
if (!text.trim()) return alert('请填写求评价文案');
}
// saveVariants 保存归一化后的发货规格。
const saveVariants = trigger === 'review_missing_timeout' ? [] : variants.map(/* 当前回调归一化发货规格字段。 */ variant => ({ ...variant, spec_name: isMultiSpecRule ? variant.spec_name.trim() : '', spec_value: isMultiSpecRule ? variant.spec_value.trim() : '', delivery_count: Math.max(1, Number(variant.delivery_count) || 1), enabled: variant.enabled !== false }));
setAutomationSubmitState(startRuleSubmission(automationSubmitState));
// succeeded 记录保存是否成功。
let succeeded = false;
try {
await updateShippingRule({ ...editingAutomationRule, trigger_type: trigger, name: (editingAutomationRule.name || '').trim() || defaultRuleName(trigger, selectedRuleItem?.item_title || editingAutomationRule.item_id || ''), config_json: trigger === 'review_missing_timeout' ? buildReviewConfig(editingAutomationRule.config_json) : (editingAutomationRule.config_json || '{}'), actions: editingAutomationRule.actions?.length ? editingAutomationRule.actions : cardActionsForTrigger(trigger, saveVariants[0]?.card_id || editingAutomationRule.card_group_id || 0), variants: saveVariants });
setShowAutomationModal(false);
await Promise.all([loadAutomationRules(), loadReferenceData()]);
alert('保存成功');
succeeded = true;
} catch (/* error 表示自动化规则保存异常。 */ error) {
console.error('保存自动化规则失败:', error);
alert('保存失败:' + (error as Error).message);
} finally {
setAutomationSubmitState(/* current 保存自动化提交状态。 */ current => finishRuleSubmission(current, succeeded));
}
}, [automationSubmitState, editingAutomationRule, isMultiSpecRule, loadAutomationRules, loadReferenceData, selectedRuleItem]);
// handleDeleteAutomation 删除自动化规则并刷新列表。
const handleDeleteAutomation = useCallback(/* deleteRuleAction 删除自动化规则。 */ async (id: string) => {
if (!confirm('确定删除该自动化规则吗?')) return;
try { await deleteShippingRule(id); await loadAutomationRules(); alert('删除成功'); } catch (/* error 表示自动化规则删除异常。 */ error) { alert('删除失败:' + (error as Error).message); }
}, [loadAutomationRules]);
// handleToggleAutomation 切换规则启用状态并刷新列表。
const handleToggleAutomation = useCallback(/* toggleRuleAction 切换自动化规则状态。 */ async (rule: ShippingRule) => {
try { await updateShippingRule({ ...rule, enabled: !rule.enabled }); await loadAutomationRules(); } catch (/* error 表示自动化规则状态更新异常。 */ error) { alert('操作失败:' + (error as Error).message); }
}, [loadAutomationRules]);
// handleResolveRunIssue 处理自动化运行的人工恢复决策。
const handleResolveRunIssue = useCallback(/* resolveRunAction 处理自动化运行异常。 */ async (id: number, resolution: 'continue' | 'retry' | 'cancel') => {
// prompt 保存当前恢复操作的确认文案。
const prompt = resolution === 'continue' ? '确认外部动作已经执行成功,并跳到下一步吗?' : resolution === 'retry' ? '确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。' : '确认终止该自动化运行吗?';
if (!confirm(prompt)) return;
try { await resolveAutomationRun(id, resolution); await loadAutomationRules(); } catch (/* error 表示自动化运行恢复异常。 */ error) { alert('处理失败:' + (error as Error).message); }
}, [loadAutomationRules]);
// handleResolveDeferredIssue 处理延迟自动化任务的重试或忽略。
const handleResolveDeferredIssue = useCallback(/* resolveDeferredAction 处理延迟任务异常。 */ async (id: number, resolution: 'retry' | 'dismiss') => {
if (!confirm(resolution === 'retry' ? '确认重新执行该任务吗?' : '确认忽略并删除该异常任务吗?')) return;
try { await resolveDeferredAutomationTask(id, resolution); await loadAutomationRules(); } catch (/* error 表示延迟任务恢复异常。 */ error) { alert('处理失败:' + (error as Error).message); }
}, [loadAutomationRules]);
// handleAddReplyRule 打开一个空的关键词回复草稿。
const handleAddReplyRule = useCallback(/* addReplyAction 创建关键词回复草稿。 */ () => {
if (!selectedAccountId) return alert('请先选择账号');
setEditingReplyRule({ keyword: '', reply_content: '', image_url: '', item_id: '', type: 'text', match_type: 'fuzzy', enabled: true });
setShowReplyModal(true);
}, [selectedAccountId]);
// handleSaveReplyRule 校验并保存关键词回复规则。
const handleSaveReplyRule = useCallback(/* saveReplyAction 保存关键词回复。 */ async () => {
if (!editingReplyRule || !selectedAccountId || replySubmitState.submitting) return;
// hasReplyContent 表示当前回复是否填写了文字或图片。
const hasReplyContent = editingReplyRule.type === 'image' ? Boolean(editingReplyRule.image_url?.trim()) : Boolean(editingReplyRule.reply_content?.trim());
if (!editingReplyRule.keyword?.trim() || !hasReplyContent) return alert('请填写关键词和回复内容');
setReplySubmitState(startRuleSubmission(replySubmitState));
// succeeded 记录保存是否成功。
let succeeded = false;
try { await updateReplyRule({ ...editingReplyRule, match_type: 'fuzzy', enabled: true }, selectedAccountId); setShowReplyModal(false); await loadReplyRules(); alert('保存成功'); succeeded = true; } catch (/* error 表示关键词回复保存异常。 */ error) { alert('保存失败:' + (error as Error).message); } finally { setReplySubmitState(/* current 保存关键词提交状态。 */ current => finishRuleSubmission(current, succeeded)); }
}, [editingReplyRule, loadReplyRules, replySubmitState, selectedAccountId]);
// handleDeleteReply 删除指定关键词回复并刷新列表。
const handleDeleteReply = useCallback(/* deleteReplyAction 删除关键词回复。 */ async (id: string) => {
if (!selectedAccountId || !confirm('确定删除该回复规则吗?')) return;
try { await deleteReplyRule(id, selectedAccountId); await loadReplyRules(); alert('删除成功'); } catch (/* error 表示关键词回复删除异常。 */ error) { alert('删除失败:' + (error as Error).message); }
}, [loadReplyRules, selectedAccountId]);
// openDefaultReplyModal 加载指定账号的默认回复配置并打开弹窗。
const openDefaultReplyModal = useCallback(/* openDefaultAction 加载默认回复草稿。 */ async (cookieID = selectedAccountId) => {
if (!cookieID) return alert('请先选择账号');
try {
// data 保存服务端返回的默认回复配置。
const data = await getDefaultReply(cookieID);
setDefaultForm({ cookie_id: cookieID, enabled: data.enabled, reply_content: data.reply_content, reply_once: data.reply_once, reply_image_url: data.reply_image_url || '' });
} catch {
setDefaultForm({ cookie_id: cookieID, enabled: false, reply_content: '', reply_once: false, reply_image_url: '' });
}
setShowDefaultModal(true);
}, [selectedAccountId]);
// handleSaveDefaultReply 校验并保存账号默认回复。
const handleSaveDefaultReply = useCallback(/* saveDefaultAction 保存默认回复。 */ async () => {
if (defaultReplySubmitState.submitting) return;
if (!defaultForm.cookie_id) return alert('请先选择账号');
if (defaultForm.enabled && !defaultForm.reply_content.trim() && !defaultForm.reply_image_url.trim()) return alert('启用默认回复时,请填写回复内容或图片 URL');
setDefaultReplySubmitState(startRuleSubmission(defaultReplySubmitState));
// succeeded 记录保存是否成功。
let succeeded = false;
try { await updateDefaultReply(defaultForm.cookie_id, { enabled: defaultForm.enabled, reply_content: defaultForm.reply_content, reply_once: defaultForm.reply_once, reply_image_url: defaultForm.reply_image_url }); setShowDefaultModal(false); await loadDefaultReplies(); alert('保存成功'); succeeded = true; } catch (/* error 表示默认回复保存异常。 */ error) { alert('保存失败:' + (error as Error).message); } finally { setDefaultReplySubmitState(/* current 保存默认回复提交状态。 */ current => finishRuleSubmission(current, succeeded)); }
}, [defaultForm, defaultReplySubmitState, loadDefaultReplies]);
// handleDeleteDefaultReply 删除账号默认回复配置。
const handleDeleteDefaultReply = useCallback(/* deleteDefaultAction 删除默认回复。 */ async (cookieID: string) => {
if (!confirm('确定删除该账号默认回复吗?')) return;
try { await deleteDefaultReply(cookieID); await loadDefaultReplies(); alert('删除成功'); } catch (/* error 表示默认回复删除异常。 */ error) { alert('删除失败:' + (error as Error).message); }
}, [loadDefaultReplies]);
// handleClearDefaultReplyRecords 清空账号默认回复的会话记录。
const handleClearDefaultReplyRecords = useCallback(/* clearDefaultRecordsAction 清空默认回复记录。 */ async (cookieID: string) => {
if (!confirm('确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。')) return;
try { await clearDefaultReplyRecords(cookieID); alert('清空成功'); } catch (/* error 表示默认回复记录清理异常。 */ error) { alert('清空失败:' + (error as Error).message); }
}, []);
return {
showAutomationModal, setShowAutomationModal, showReplyModal, setShowReplyModal, showDefaultModal, setShowDefaultModal,
automationSubmitState, replySubmitState, defaultReplySubmitState, editingAutomationRule, setEditingAutomationRule,
editingReplyRule, setEditingReplyRule, defaultForm, setDefaultForm, selectedRuleItem, isMultiSpecRule, currentTrigger,
currentMeta, reviewConfig, displayVariants, buildAutomationDraft, openAutomationRule, openNewAutomationRule,
handleTriggerChange, handleAutomationItemChange, updateVariant, appendDeliveryContent, handleSaveAutomationRule,
handleDeleteAutomation, handleToggleAutomation, handleResolveRunIssue, handleResolveDeferredIssue, handleAddReplyRule,
handleSaveReplyRule, handleDeleteReply, openDefaultReplyModal, handleSaveDefaultReply, handleDeleteDefaultReply,
handleClearDefaultReplyRecords,
};
};
+31 -517
View File
@@ -1,21 +1,6 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { createPortal } from 'react-dom';
import type { AutomationTriggerType, ReplyRule, ShippingRule, ShippingVariant } from '../app/features/rules/types';
import {
clearDefaultReplyRecords,
deleteDefaultReply,
deleteReplyRule,
deleteShippingRule,
getCards,
getDefaultReply,
getItems,
getShippingRules,
updateDefaultReply,
updateReplyRule,
updateShippingRule,
resolveAutomationRun,
resolveDeferredAutomationTask,
} from '../app/features/rules/api';
import type { AutomationTriggerType } from '../app/features/rules/types';
import {
AlertCircle,
Bot,
@@ -39,9 +24,9 @@ import {
import { AutomationIssuePanel } from '../app/features/rules/components/AutomationIssuePanel';
import { useRulesData } from '../app/features/rules/hooks';
import { filterAutomationIssues } from '../app/features/rules/issueState';
import { triggerMeta, triggerOrder, emptyVariant, parseJSONObject, buildReviewConfig, defaultRuleName, shouldReplaceGeneratedName, cardActionsForTrigger, actionSummary, accentClasses, statusPill, accountLabel, boolFlag } from '../app/features/rules/utils';
import type { RulesProps, RulesTab, DefaultReplyForm } from '../app/features/rules/types';
import { finishRuleSubmission, idleRuleSubmitState, startRuleSubmission, type RuleSubmitState } from '../app/features/rules/interactionState';
import { triggerMeta, triggerOrder, actionSummary, accentClasses, statusPill, accountLabel, buildReviewConfig, cardActionsForTrigger } from '../app/features/rules/utils';
import type { RulesProps, RulesTab } from '../app/features/rules/types';
import { useRuleActions } from '../app/features/rules/ruleActions';
// Rules 是规则 feature 在旧页面目录下保留的兼容入口组件。
const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHandled }) => {
@@ -98,32 +83,33 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
refresh,
} = rulesData;
// [showAutomationModal, 解构得到当前 Hook 返回的状态和操作函数。
const [showAutomationModal, setShowAutomationModal] = useState(false);
// [showReplyModal, 解构得到当前 Hook 返回的状态和操作函数。
const [showReplyModal, setShowReplyModal] = useState(false);
// [showDefaultModal, 解构得到当前 Hook 返回的状态和操作函数。
const [showDefaultModal, setShowDefaultModal] = useState(false);
// automationSubmitState 防止自动化规则保存按钮在请求期间重复提交。
const [automationSubmitState, setAutomationSubmitState] = useState<RuleSubmitState>(idleRuleSubmitState);
// replySubmitState 防止关键词回复保存按钮在请求期间重复提交。
const [replySubmitState, setReplySubmitState] = useState<RuleSubmitState>(idleRuleSubmitState);
// defaultReplySubmitState 防止默认回复保存按钮在请求期间重复提交。
const [defaultReplySubmitState, setDefaultReplySubmitState] = useState<RuleSubmitState>(idleRuleSubmitState);
// [editingAutomationRule, 解构得到当前 Hook 返回的状态和操作函数。
const [editingAutomationRule, setEditingAutomationRule] = useState<Partial<ShippingRule> | null>(null);
// [editingReplyRule, 解构得到当前 Hook 返回的状态和操作函数。
const [editingReplyRule, setEditingReplyRule] = useState<Partial<ReplyRule> | null>(null);
// [defaultForm, 解构得到当前 Hook 返回的状态和操作函数。
const [defaultForm, setDefaultForm] = useState<DefaultReplyForm>({
cookie_id: '',
enabled: false,
reply_content: '',
reply_once: false,
reply_image_url: '',
// ruleActions 规则 feature 提供弹窗状态、编辑草稿和所有保存删除动作。
const ruleActions = useRuleActions({
selectedAccountId,
setSelectedAccountId,
setActiveTab,
items,
setAutomationRules,
setCards,
setItems,
setLoading,
loadAutomationRules,
loadReferenceData,
loadReplyRules,
loadDefaultReplies,
initialDeliveryTarget,
onDeliveryTargetHandled,
});
// selectedAccount 处理当前选择(ed账号)。
const selectedAccount = accounts.find(/* 当前回调处理集合中的单个元素。 */ account => account.id === selectedAccountId);
// 解构规则动作,保持旧页面 JSX 的字段名称和行为不变。
const {
showAutomationModal, setShowAutomationModal, showReplyModal, setShowReplyModal, showDefaultModal, setShowDefaultModal,
automationSubmitState, replySubmitState, defaultReplySubmitState, editingAutomationRule, setEditingAutomationRule,
editingReplyRule, setEditingReplyRule, defaultForm, setDefaultForm, selectedRuleItem, isMultiSpecRule, currentTrigger,
currentMeta, reviewConfig, displayVariants, openAutomationRule, openNewAutomationRule, handleTriggerChange,
handleAutomationItemChange, updateVariant, appendDeliveryContent, handleSaveAutomationRule, handleDeleteAutomation,
handleToggleAutomation, handleResolveRunIssue, handleResolveDeferredIssue, handleAddReplyRule, handleSaveReplyRule,
handleDeleteReply, openDefaultReplyModal, handleSaveDefaultReply, handleDeleteDefaultReply, handleClearDefaultReplyRecords,
} = ruleActions;
useEffect(/* 当前回调同步 React 副作用和资源生命周期。 */ () => {
// timer 定时器。
@@ -191,478 +177,6 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
return items.filter(/* 当前回调处理集合中的单个元素。 */ item => item.cookie_id === cookieID);
}, [editingAutomationRule?.cookie_id, items, selectedAccountId]);
// selectedRuleItem 处理当前选择(ed规则商品)。
const selectedRuleItem = useMemo(/* 当前回调计算并缓存派生数据。 */ () => {
if (!editingAutomationRule?.cookie_id || !editingAutomationRule?.item_id) return undefined;
return items.find(/* 当前回调处理集合中的单个元素。 */ item => item.cookie_id === editingAutomationRule.cookie_id && item.item_id === editingAutomationRule.item_id);
}, [editingAutomationRule?.cookie_id, editingAutomationRule?.item_id, items]);
// isMultiSpecRule isMultiSpec规则,负责当前功能中的对应处理。
const isMultiSpecRule = boolFlag(selectedRuleItem?.is_multi_spec);
// currentTrigger 当前触发条件。
const currentTrigger = (editingAutomationRule?.trigger_type || 'order_paid') as AutomationTriggerType;
// currentMeta 当前触发元数据。
const currentMeta = triggerMeta[currentTrigger];
// reviewConfig 评价配置。
const reviewConfig = parseJSONObject(editingAutomationRule?.config_json);
// buildAutomationDraft 构建自动化Draft,负责当前功能中的对应处理。
const buildAutomationDraft = useCallback(/* 当前回调封装可复用的交互处理逻辑。 */ (
trigger: AutomationTriggerType = 'order_paid',
cookieID = selectedAccountId,
itemID = '',
): Partial<ShippingRule> => {
// item 商品。
const item = items.find(/* 当前回调处理集合中的单个元素。 */ candidate => candidate.cookie_id === cookieID && candidate.item_id === itemID);
// itemLabel 商品标签,负责当前功能中的对应处理。
const itemLabel = item?.item_title || itemID;
return {
name: defaultRuleName(trigger, itemLabel),
trigger_type: trigger,
cookie_id: cookieID,
item_id: itemID,
item_title: item?.item_title || '',
item_keyword: itemLabel,
card_group_id: 0,
priority: 100,
enabled: true,
config_json: trigger === 'review_missing_timeout' ? buildReviewConfig() : '{}',
actions: cardActionsForTrigger(trigger),
variants: trigger === 'review_missing_timeout' ? [] : [emptyVariant()],
};
}, [items, selectedAccountId]);
// openAutomationRule 打开当前界面(自动化规则)。
const openAutomationRule = useCallback(/* 当前回调封装可复用的交互处理逻辑。 */ (rule: ShippingRule) => {
// trigger 触发条件。
const trigger = (rule.trigger_type || 'order_paid') as AutomationTriggerType;
setEditingAutomationRule({
...rule,
trigger_type: trigger,
config_json: trigger === 'review_missing_timeout' ? buildReviewConfig(rule.config_json) : (rule.config_json || '{}'),
actions: rule.actions?.length ? rule.actions.map(/* 当前回调处理集合中的单个元素。 */ action => ({ ...action })) : cardActionsForTrigger(trigger, rule.card_group_id),
variants: rule.variants?.length ? rule.variants.map(/* 当前回调处理集合中的单个元素。 */ variant => ({ ...variant })) : (trigger === 'review_missing_timeout' ? [] : [emptyVariant()]),
});
setShowAutomationModal(true);
}, []);
useEffect(/* 当前回调同步 React 副作用和资源生命周期。 */ () => {
if (!initialDeliveryTarget) return;
// cancelled 取消当前操作(led)。
let cancelled = false;
// openLinkedRule 打开当前界面(Linked规则)。
const openLinkedRule = async () => {
setActiveTab('automation');
setSelectedAccountId(initialDeliveryTarget.cookieId);
setLoading(true);
try {
// [ruleList, 解构得到当前 Hook 返回的状态和操作函数。
const [ruleList, itemList, cardList] = await Promise.all([
getShippingRules(),
getItems(),
getCards().catch(/* 当前回调处理异步操作结果。 */ error => {
console.warn('加载卡密库存失败,不阻断打开自动化规则', error);
return [];
}),
]);
if (cancelled) return;
setAutomationRules(ruleList);
setItems(itemList);
setCards(cardList);
// rule 规则。
const rule = ruleList.find(/* 当前回调处理集合中的单个元素。 */ candidate =>
candidate.cookie_id === initialDeliveryTarget.cookieId &&
candidate.item_id === initialDeliveryTarget.itemId &&
candidate.trigger_type === 'order_paid'
);
if (rule) {
openAutomationRule(rule);
} else {
// item 商品。
const item = itemList.find(/* 当前回调处理集合中的单个元素。 */ candidate =>
candidate.cookie_id === initialDeliveryTarget.cookieId &&
candidate.item_id === initialDeliveryTarget.itemId
);
setEditingAutomationRule({
...buildAutomationDraft('order_paid', initialDeliveryTarget.cookieId, initialDeliveryTarget.itemId),
item_title: item?.item_title || '',
item_keyword: item?.item_title || initialDeliveryTarget.itemId,
name: defaultRuleName('order_paid', item?.item_title || initialDeliveryTarget.itemId),
});
setShowAutomationModal(true);
}
} catch (/* error 表示错误。 */ error) {
console.error('打开商品自动化规则失败', error);
alert('无法加载该商品的自动化规则');
} finally {
if (!cancelled) {
setLoading(false);
onDeliveryTargetHandled?.();
}
}
};
void openLinkedRule();
return /* 当前回调处理用户交互或异步状态变化。 */ () => { cancelled = true; };
}, [buildAutomationDraft, initialDeliveryTarget, onDeliveryTargetHandled, openAutomationRule]);
// openNewAutomationRule 打开当前界面(New自动化规则)。
const openNewAutomationRule = (trigger: AutomationTriggerType = 'order_paid') => {
if (!selectedAccountId) {
alert('请先选择账号');
return;
}
setEditingAutomationRule(buildAutomationDraft(trigger));
setShowAutomationModal(true);
};
// handleTriggerChange 处理当前用户操作(触发条件Change)。
const handleTriggerChange = (trigger: AutomationTriggerType) => {
if (!editingAutomationRule) return;
// currentCardID 当前卡密组标识。
const currentCardID =
editingAutomationRule.variants?.find(/* 当前回调处理集合中的单个元素。 */ variant => variant.card_id)?.card_id ||
editingAutomationRule.actions?.find(/* 当前回调处理集合中的单个元素。 */ action => action.action_type === 'send_card')?.card_id ||
editingAutomationRule.card_group_id ||
0;
// itemLabel 商品标签,负责当前功能中的对应处理。
const itemLabel = selectedRuleItem?.item_title || editingAutomationRule.item_title || editingAutomationRule.item_id || '';
setEditingAutomationRule({
...editingAutomationRule,
trigger_type: trigger,
name: shouldReplaceGeneratedName(editingAutomationRule.name)
? defaultRuleName(trigger, itemLabel)
: editingAutomationRule.name,
card_group_id: currentCardID,
config_json: trigger === 'review_missing_timeout' ? buildReviewConfig(editingAutomationRule.config_json) : '{}',
actions: cardActionsForTrigger(trigger, currentCardID),
variants: trigger === 'review_missing_timeout'
? []
: (editingAutomationRule.variants?.length ? editingAutomationRule.variants : [{ ...emptyVariant(), card_id: currentCardID }]),
});
};
// handleAutomationItemChange 处理当前用户操作(自动化商品Change)。
const handleAutomationItemChange = (itemID: string) => {
if (!editingAutomationRule) return;
// item 商品。
const item = items.find(/* 当前回调处理集合中的单个元素。 */ candidate =>
candidate.cookie_id === (editingAutomationRule.cookie_id || selectedAccountId) &&
candidate.item_id === itemID
);
// itemLabel 商品标签,负责当前功能中的对应处理。
const itemLabel = item?.item_title || itemID;
setEditingAutomationRule({
...editingAutomationRule,
item_id: itemID,
item_title: item?.item_title || '',
item_keyword: itemLabel,
name: shouldReplaceGeneratedName(editingAutomationRule.name)
? defaultRuleName(currentTrigger, itemLabel)
: editingAutomationRule.name,
});
};
// displayVariants 展示规格列表。
const displayVariants = editingAutomationRule?.variants?.length
? editingAutomationRule.variants
: [emptyVariant()];
// updateVariant 更新当前数据(Variant)。
const updateVariant = (index: number, patch: Partial<ShippingVariant>) => {
if (!editingAutomationRule) return;
// next 下一项。
const next = displayVariants.map(/* 当前回调处理集合中的单个元素。 */ (variant, variantIndex) =>
variantIndex === index ? { ...variant, ...patch } : variant
);
setEditingAutomationRule({
...editingAutomationRule,
variants: next,
card_group_id: next[0]?.card_id || 0,
});
};
// appendDeliveryContent 追加发货内容。
const appendDeliveryContent = () => {
if (!editingAutomationRule) return;
// previous 上一项。
const previous = displayVariants[displayVariants.length - 1];
setEditingAutomationRule({
...editingAutomationRule,
variants: [
...displayVariants,
{
...emptyVariant(),
spec_name: isMultiSpecRule ? previous?.spec_name || '' : '',
spec_value: isMultiSpecRule ? previous?.spec_value || '' : '',
},
],
});
};
// handleSaveAutomationRule 处理当前用户操作(Save自动化规则)。
const handleSaveAutomationRule = async () => {
if (!editingAutomationRule || automationSubmitState.submitting) return;
// trigger 触发条件。
const trigger = (editingAutomationRule.trigger_type || 'order_paid') as AutomationTriggerType;
if (!editingAutomationRule.cookie_id) {
alert('请选择账号');
return;
}
// variants 规格列表。
const variants = editingAutomationRule.variants?.length ? editingAutomationRule.variants : [];
if (trigger !== 'review_missing_timeout') {
if (!variants.length || variants.some(/* 当前回调处理集合中的单个元素。 */ variant => !variant.card_id)) {
alert(trigger === 'buyer_reviewed' ? '请选择评价赠品卡密库存' : '请选择发货卡密库存');
return;
}
if (isMultiSpecRule && variants.some(/* 当前回调处理集合中的单个元素。 */ variant => !variant.spec_name.trim() || !variant.spec_value.trim())) {
alert('多规格商品必须填写每一行的规格名称和规格值');
return;
}
}
if (trigger === 'review_missing_timeout') {
// text 文本。
const text = editingAutomationRule.actions?.find(/* 当前回调处理集合中的单个元素。 */ action => action.action_type === 'send_text')?.message_template || '';
if (!text.trim()) {
alert('请填写求评价文案');
return;
}
}
// saveVariants 保存当前数据(Variants)。
const saveVariants = trigger === 'review_missing_timeout'
? []
: variants.map(variant => ({/* 当前回调处理集合中的单个元素。 */
...variant,
spec_name: isMultiSpecRule ? variant.spec_name.trim() : '',
spec_value: isMultiSpecRule ? variant.spec_value.trim() : '',
delivery_count: Math.max(1, Number(variant.delivery_count) || 1),
enabled: variant.enabled !== false,
}));
setAutomationSubmitState(startRuleSubmission(automationSubmitState));
// succeeded 是否成功。
let succeeded = false;
try {
await updateShippingRule({
...editingAutomationRule,
trigger_type: trigger,
name: (editingAutomationRule.name || '').trim() ||
defaultRuleName(trigger, selectedRuleItem?.item_title || editingAutomationRule.item_id || ''),
config_json: trigger === 'review_missing_timeout'
? buildReviewConfig(editingAutomationRule.config_json)
: (editingAutomationRule.config_json || '{}'),
actions: editingAutomationRule.actions?.length
? editingAutomationRule.actions
: cardActionsForTrigger(trigger, saveVariants[0]?.card_id || editingAutomationRule.card_group_id || 0),
variants: saveVariants,
});
setShowAutomationModal(false);
await Promise.all([loadAutomationRules(), loadReferenceData()]);
alert('保存成功');
succeeded = true;
} catch (/* error 表示错误。 */ error) {
console.error('保存自动化规则失败:', error);
alert('保存失败:' + (error as Error).message);
} finally {
setAutomationSubmitState(/* 当前回调处理用户交互或异步状态变化。 */ current => finishRuleSubmission(current, succeeded));
}
};
// handleDeleteAutomation 处理当前用户操作(Delete自动化)。
const handleDeleteAutomation = async (id: string) => {
if (!confirm('确定删除该自动化规则吗?')) return;
try {
await deleteShippingRule(id);
await loadAutomationRules();
alert('删除成功');
} catch (/* error 表示错误。 */ error) {
alert('删除失败:' + (error as Error).message);
}
};
// handleToggleAutomation 处理当前用户操作(Toggle自动化)。
const handleToggleAutomation = async (rule: ShippingRule) => {
try {
await updateShippingRule({ ...rule, enabled: !rule.enabled });
await loadAutomationRules();
} catch (/* error 表示错误。 */ error) {
alert('操作失败:' + (error as Error).message);
}
};
// handleResolveRunIssue 处理当前用户操作(ResolveRun问题)。
const handleResolveRunIssue = async (id: number, resolution: 'continue' | 'retry' | 'cancel') => {
// prompt 提示文案。
const prompt = resolution === 'continue'
? '确认外部动作已经执行成功,并跳到下一步吗?'
: resolution === 'retry'
? '确认外部动作没有执行,可以安全重试吗?错误判断可能造成重复发送。'
: '确认终止该自动化运行吗?';
if (!confirm(prompt)) return;
try {
await resolveAutomationRun(id, resolution);
await loadAutomationRules();
} catch (/* error 表示错误。 */ error) {
alert('处理失败:' + (error as Error).message);
}
};
// handleResolveDeferredIssue 处理当前用户操作(ResolveDeferred问题)。
const handleResolveDeferredIssue = async (id: number, resolution: 'retry' | 'dismiss') => {
if (!confirm(resolution === 'retry' ? '确认重新执行该任务吗?' : '确认忽略并删除该异常任务吗?')) return;
try {
await resolveDeferredAutomationTask(id, resolution);
await loadAutomationRules();
} catch (/* error 表示错误。 */ error) {
alert('处理失败:' + (error as Error).message);
}
};
// handleAddReplyRule 处理当前用户操作(Add回复规则)。
const handleAddReplyRule = () => {
if (!selectedAccountId) {
alert('请先选择账号');
return;
}
setEditingReplyRule({
keyword: '',
reply_content: '',
image_url: '',
item_id: '',
type: 'text',
match_type: 'fuzzy',
enabled: true,
});
setShowReplyModal(true);
};
// handleSaveReplyRule 处理当前用户操作(Save回复规则)。
const handleSaveReplyRule = async () => {
if (!editingReplyRule || !selectedAccountId || replySubmitState.submitting) return;
// hasReplyContent 是否包含回复内容。
const hasReplyContent = editingReplyRule.type === 'image'
? Boolean(editingReplyRule.image_url?.trim())
: Boolean(editingReplyRule.reply_content?.trim());
if (!editingReplyRule.keyword?.trim() || !hasReplyContent) {
alert('请填写关键词和回复内容');
return;
}
setReplySubmitState(startRuleSubmission(replySubmitState));
// succeeded 是否成功。
let succeeded = false;
try {
await updateReplyRule({ ...editingReplyRule, match_type: 'fuzzy', enabled: true }, selectedAccountId);
setShowReplyModal(false);
await loadReplyRules();
alert('保存成功');
succeeded = true;
} catch (/* error 表示错误。 */ error) {
alert('保存失败:' + (error as Error).message);
} finally {
setReplySubmitState(/* 当前回调处理用户交互或异步状态变化。 */ current => finishRuleSubmission(current, succeeded));
}
};
// handleDeleteReply 处理当前用户操作(Delete回复)。
const handleDeleteReply = async (id: string) => {
if (!selectedAccountId || !confirm('确定删除该回复规则吗?')) return;
try {
await deleteReplyRule(id, selectedAccountId);
await loadReplyRules();
alert('删除成功');
} catch (/* error 表示错误。 */ error) {
alert('删除失败:' + (error as Error).message);
}
};
// openDefaultReplyModal 打开当前界面(Default回复Modal)。
const openDefaultReplyModal = async (cookieID = selectedAccountId) => {
if (!cookieID) {
alert('请先选择账号');
return;
}
try {
// data 数据。
const data = await getDefaultReply(cookieID);
setDefaultForm({
cookie_id: cookieID,
enabled: data.enabled,
reply_content: data.reply_content,
reply_once: data.reply_once,
reply_image_url: data.reply_image_url || '',
});
} catch {
setDefaultForm({
cookie_id: cookieID,
enabled: false,
reply_content: '',
reply_once: false,
reply_image_url: '',
});
}
setShowDefaultModal(true);
};
// handleSaveDefaultReply 处理当前用户操作(SaveDefault回复)。
const handleSaveDefaultReply = async () => {
if (defaultReplySubmitState.submitting) return;
if (!defaultForm.cookie_id) {
alert('请先选择账号');
return;
}
if (defaultForm.enabled && !defaultForm.reply_content.trim() && !defaultForm.reply_image_url.trim()) {
alert('启用默认回复时,请填写回复内容或图片 URL');
return;
}
setDefaultReplySubmitState(startRuleSubmission(defaultReplySubmitState));
// succeeded 是否成功。
let succeeded = false;
try {
await updateDefaultReply(defaultForm.cookie_id, {
enabled: defaultForm.enabled,
reply_content: defaultForm.reply_content,
reply_once: defaultForm.reply_once,
reply_image_url: defaultForm.reply_image_url,
});
setShowDefaultModal(false);
await loadDefaultReplies();
alert('保存成功');
succeeded = true;
} catch (/* error 表示错误。 */ error) {
alert('保存失败:' + (error as Error).message);
} finally {
setDefaultReplySubmitState(/* 当前回调处理用户交互或异步状态变化。 */ current => finishRuleSubmission(current, succeeded));
}
};
// handleDeleteDefaultReply 处理当前用户操作(DeleteDefault回复)。
const handleDeleteDefaultReply = async (cookieID: string) => {
if (!confirm('确定删除该账号默认回复吗?')) return;
try {
await deleteDefaultReply(cookieID);
await loadDefaultReplies();
alert('删除成功');
} catch (/* error 表示错误。 */ error) {
alert('删除失败:' + (error as Error).message);
}
};
// handleClearDefaultReplyRecords 处理当前用户操作(ClearDefault回复Records)。
const handleClearDefaultReplyRecords = async (cookieID: string) => {
if (!confirm('确定清空该账号的默认回复记录吗?清空后可重新对所有会话使用“只回复一次”。')) return;
try {
await clearDefaultReplyRecords(cookieID);
alert('清空成功');
} catch (/* error 表示错误。 */ error) {
alert('清空失败:' + (error as Error).message);
}
};
// primaryActionLabel 主操作按钮文案。
const primaryActionLabel = activeTab === 'automation'
? '新建自动化'
+7 -6
View File
@@ -144,25 +144,26 @@ describe('frontend navigation routing', () => {
} /* 回调函数负责当前业务流程。 */);
test('item delivery shortcut opens existing automation rule modal', () => {
const rules = readFrontendFile('components/Rules.tsx'); /* rules 表示规则集合。 */
const existingRuleBranch = rules.match(/if \(rule\) \{([\s\S]*?)\} else \{/); /* existingRuleBranch 表示existing当前规则Branch。 */
const actions = readFrontendFile('app/features/rules/ruleActions.ts'); /* actions 表示规则动作协调器源码。 */
const existingRuleBranch = actions.match(/if \(rule\) \{([\s\S]*?)\} else \{/); /* existingRuleBranch 表示existing当前规则Branch。 */
expect(existingRuleBranch?.[1]).toContain('openAutomationRule(rule)');
} /* 回调函数负责当前业务流程。 */);
test('item delivery shortcut is not marked handled before async open completes', () => {
const rules = readFrontendFile('components/Rules.tsx'); /* rules 表示规则集合。 */
const actions = readFrontendFile('app/features/rules/ruleActions.ts'); /* actions 表示规则动作协调器源码。 */
expect(rules).not.toContain('handledDeliveryTarget.current = initialDeliveryTarget.requestId');
expect(rules).toContain('onDeliveryTargetHandled?.();');
expect(actions).not.toContain('handledDeliveryTarget.current = initialDeliveryTarget.requestId');
expect(actions).toContain('onDeliveryTargetHandled?.();');
} /* 回调函数负责当前业务流程。 */);
test('automation editor keeps multiple delivery contents for normal products', () => {
const rules = readFrontendFile('components/Rules.tsx'); /* rules 表示规则集合。 */
const actions = readFrontendFile('app/features/rules/ruleActions.ts'); /* actions 表示规则动作协调器源码。 */
expect(rules).toContain('添加发货内容');
expect(rules).toContain('{displayVariants.map((variant, index) => (');
expect(rules).toContain(': variants.map(variant => ({');
expect(actions).toContain('variants.map(');
expect(rules).not.toContain(': (isMultiSpecRule ? variants : [variants[0]]).map');
} /* 回调函数负责当前业务流程。 */);
@@ -1,3 +1,3 @@
import{r as l,j as e,b as ne,c as Ee}from"./react-vendor-C_od1ZSF.js";import{f as Ne,u as ve,r as Qe,h as $e,i as Ue,j as Be,k as Me,l as Oe,m as ze,n as Ge,o as We,p as Ve,s as Ke,q as He,t as Xe,v as Je,w as Ye,x as Ze,y as Fe,z as es,A as ss,B as ts,C as as}from"./index-CFJ5pUjO.js";import{X as oe,n as rs,f as K,o as ls,p as Se,q as Re,r as qe,s as se,t as Ae,K as ns,u as os,v as is,a as ds,w as ie,b as cs,i as Pe,x as xs,k as je,Q as we,R as us,y as ms,z as bs,F as ye,H as hs}from"./icons-vendor-ThcsWkZG.js";const _e=t=>({account_id:t.id,auto_rate_enabled:t.auto_rate_enabled===!0,rate_content:t.rate_content||"不错的买家,交易愉快",auto_polish_enabled:t.auto_polish_enabled===!0,polish_time:t.polish_time||"03:00",last_rate_scan_at:t.last_rate_scan_at,last_polish_date:t.last_polish_date,last_polish_at:t.last_polish_at}),J=(t,s,r)=>t===s&&!r.aborted,fe=(t,s)=>t instanceof Error?t.message:s,pe=t=>t instanceof Error&&t.message==="请求已取消",ke=(t,s)=>!t&&s==="",gs=({account:t,onSaved:s})=>{const[r,a]=l.useState(()=>_e(t)),[u,x]=l.useState(!0),[o,i]=l.useState(!1),[b,m]=l.useState(""),[p,h]=l.useState(""),[d,q]=l.useState(null),[k,g]=l.useState(null),f=l.useRef(0),L=l.useRef(null);l.useEffect(()=>{var v;const S=++f.current;(v=L.current)==null||v.abort();const w=new AbortController;return L.current=w,a(_e(t)),q(null),h(""),i(!1),m(""),g(null),x(!0),Ne(t.id,{signal:w.signal}).then(R=>{J(f.current,S,w.signal)&&a(R)}).catch(R=>{J(f.current,S,w.signal)&&!pe(R)&&h(fe(R,"加载任务设置失败"))}).finally(()=>{J(f.current,S,w.signal)&&x(!1)}),(()=>w.abort())},[t.id]),l.useEffect(()=>(()=>{var S;return(S=L.current)==null?void 0:S.abort()}),[]);const U=l.useCallback(async()=>{var v;if(!ke(o,b))return;const S=++f.current;(v=L.current)==null||v.abort();const w=new AbortController;L.current=w,i(!0),h(""),g(null);try{const R=await ve(t.id,r,{signal:w.signal});if(!J(f.current,S,w.signal))return;a(R),s(R)}catch(R){J(f.current,S,w.signal)&&!pe(R)&&(h(fe(R,"保存失败")),g(()=>U))}finally{J(f.current,S,w.signal)&&i(!1)}},[t.id,r,s,b,o]),B=l.useCallback(async S=>{var R;if(!ke(o,b)||!t.enabled)return;const w=++f.current;(R=L.current)==null||R.abort();const v=new AbortController;L.current=v,m(S),h(""),q(null),g(null);try{await ve(t.id,r,{signal:v.signal});const y=await Qe(t.id,S,{signal:v.signal}),A=await Ne(t.id,{signal:v.signal});if(!J(f.current,w,v.signal))return;q(y.summary),a(A),s(A)}catch(y){J(f.current,w,v.signal)&&!pe(y)&&(h(fe(y,"任务执行失败")),g(()=>(()=>B(S))))}finally{J(f.current,w,v.signal)&&m("")}},[t.enabled,t.id,r,s,b,o]),T=l.useCallback(async()=>{k&&await k()},[k]);return{form:r,loading:u,saving:o,running:b,summary:d,error:p,retryAvailable:k!==null,setForm:a,save:U,run:B,retry:T}},Ce=({checked:t,onChange:s,label:r})=>e.jsx("button",{type:"button","aria-label":r,"aria-pressed":t,onClick:s,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${t?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-6":""}`})}),fs=({account:t,onClose:s,onSaved:r})=>{const{form:a,loading:u,saving:x,running:o,error:i,summary:b,retryAvailable:m,setForm:p,save:h,run:d,retry:q}=gs({account:t,onSaved:r});return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(oe,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[u&&e.jsx("div",{className:"rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500",children:"正在读取任务设置..."}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(rs,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(Ce,{checked:a.auto_rate_enabled,onChange:(()=>p(k=>({...k,auto_rate_enabled:!k.auto_rate_enabled}))),label:"自动评价"})]}),e.jsx("label",{className:"mt-4Line truncated
import{r as l,j as e,b as ne,c as Ee}from"./react-vendor-C_od1ZSF.js";import{f as Ne,u as ve,r as Qe,h as $e,i as Ue,j as Be,k as Me,l as Oe,m as ze,n as Ge,o as We,p as Ve,s as Ke,q as He,t as Xe,v as Je,w as Ye,x as Ze,y as Fe,z as es,A as ss,B as ts,C as as}from"./index-CsLZwESi.js";import{X as oe,n as rs,f as K,o as ls,p as Se,q as Re,r as qe,s as se,t as Ae,K as ns,u as os,v as is,a as ds,w as ie,b as cs,i as Pe,x as xs,k as je,Q as we,R as us,y as ms,z as bs,F as ye,H as hs}from"./icons-vendor-ThcsWkZG.js";const _e=t=>({account_id:t.id,auto_rate_enabled:t.auto_rate_enabled===!0,rate_content:t.rate_content||"不错的买家,交易愉快",auto_polish_enabled:t.auto_polish_enabled===!0,polish_time:t.polish_time||"03:00",last_rate_scan_at:t.last_rate_scan_at,last_polish_date:t.last_polish_date,last_polish_at:t.last_polish_at}),J=(t,s,r)=>t===s&&!r.aborted,fe=(t,s)=>t instanceof Error?t.message:s,pe=t=>t instanceof Error&&t.message==="请求已取消",ke=(t,s)=>!t&&s==="",gs=({account:t,onSaved:s})=>{const[r,a]=l.useState(()=>_e(t)),[u,x]=l.useState(!0),[o,i]=l.useState(!1),[b,m]=l.useState(""),[p,h]=l.useState(""),[d,q]=l.useState(null),[k,g]=l.useState(null),f=l.useRef(0),L=l.useRef(null);l.useEffect(()=>{var v;const S=++f.current;(v=L.current)==null||v.abort();const w=new AbortController;return L.current=w,a(_e(t)),q(null),h(""),i(!1),m(""),g(null),x(!0),Ne(t.id,{signal:w.signal}).then(R=>{J(f.current,S,w.signal)&&a(R)}).catch(R=>{J(f.current,S,w.signal)&&!pe(R)&&h(fe(R,"加载任务设置失败"))}).finally(()=>{J(f.current,S,w.signal)&&x(!1)}),(()=>w.abort())},[t.id]),l.useEffect(()=>(()=>{var S;return(S=L.current)==null?void 0:S.abort()}),[]);const U=l.useCallback(async()=>{var v;if(!ke(o,b))return;const S=++f.current;(v=L.current)==null||v.abort();const w=new AbortController;L.current=w,i(!0),h(""),g(null);try{const R=await ve(t.id,r,{signal:w.signal});if(!J(f.current,S,w.signal))return;a(R),s(R)}catch(R){J(f.current,S,w.signal)&&!pe(R)&&(h(fe(R,"保存失败")),g(()=>U))}finally{J(f.current,S,w.signal)&&i(!1)}},[t.id,r,s,b,o]),B=l.useCallback(async S=>{var R;if(!ke(o,b)||!t.enabled)return;const w=++f.current;(R=L.current)==null||R.abort();const v=new AbortController;L.current=v,m(S),h(""),q(null),g(null);try{await ve(t.id,r,{signal:v.signal});const y=await Qe(t.id,S,{signal:v.signal}),A=await Ne(t.id,{signal:v.signal});if(!J(f.current,w,v.signal))return;q(y.summary),a(A),s(A)}catch(y){J(f.current,w,v.signal)&&!pe(y)&&(h(fe(y,"任务执行失败")),g(()=>(()=>B(S))))}finally{J(f.current,w,v.signal)&&m("")}},[t.enabled,t.id,r,s,b,o]),T=l.useCallback(async()=>{k&&await k()},[k]);return{form:r,loading:u,saving:o,running:b,summary:d,error:p,retryAvailable:k!==null,setForm:a,save:U,run:B,retry:T}},Ce=({checked:t,onChange:s,label:r})=>e.jsx("button",{type:"button","aria-label":r,"aria-pressed":t,onClick:s,className:`relative h-8 w-14 shrink-0 rounded-full transition-colors ${t?"bg-sky-500":"bg-slate-300"}`,children:e.jsx("span",{className:`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-sm transition-transform ${t?"translate-x-6":""}`})}),fs=({account:t,onClose:s,onSaved:r})=>{const{form:a,loading:u,saving:x,running:o,error:i,summary:b,retryAvailable:m,setForm:p,save:h,run:d,retry:q}=gs({account:t,onSaved:r});return e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"640px"},role:"dialog","aria-modal":"true","aria-labelledby":"account-task-title",children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"account-task-title",className:"text-2xl font-extrabold text-slate-950",children:"账号自动任务"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:t.nickname||t.remark||t.id})]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-xl p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"关闭",children:e.jsx(oe,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[u&&e.jsx("div",{className:"rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500",children:"正在读取任务设置..."}),e.jsx("section",{className:"rounded-2xl border border-slate-200 bg-white p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600",children:e.jsx(rs,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-black text-slate-900",children:"自动评价"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"持续扫描待评价订单,按订单执行;不是每日任务。"})]}),e.jsx(Ce,{checked:a.auto_rate_enabled,onChange:(()=>p(k=>({...k,auto_rate_enabled:!k.auto_rate_enabled}))),label:"自动评价"})]}),e.jsx("label",{className:"mt-4Line 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(cs,{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:u,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:r,children:"取消"}),e.jsxs("button",{onClick:(()=>void x()),className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:r,children:[r?e.jsx(K,{className:"w-4 h-4 animate-spin"}):e.jsx(qe,{className:"w-4 h-4"}),r?"保存中...":"保存"]})]})})]})}),document.body)},ws=(t,s)=>{if(!t||!s)return!1;const r=Date.parse(t),a=Date.parse(s);return Number.isFinite(r)&&Number.isFinite(a)&&a<r},ys=(t,s)=>t.map(r=>{const a=s[r.id];return!a||ws(r.runtime_updated_at,a.updated_at)?r:{...r,runtime_state:a.state,runtime_message:a.message||"",runtime_connected:a.connected,runtime_updated_at:a.updated_at}}),Ns=t=>{if(!t.enabled||t.runtime_state==="disabled")return{label:"已停用",badge:"bg-gray-100 text-gray-500",dot:"bg-gray-300"};switch(t.runtime_state){case"online":return{label:"在线",badge:"bg-green-100 text-green-700",dot:"bg-green-500"};case"starting":case"connecting":return{label:"连接中",badge:"bg-blue-100 text-blue-700",dot:"bg-blue-500"};case"reconnecting":return{label:"重连中",badge:"bg-amber-100 text-amber-700",dot:"bg-amber-500"};case"auth_expired":return{label:"登录已失效",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};case"verification_required":return{label:"需要验证",badge:"bg-orange-100 text-orange-700",dot:"bg-orange-500"};case"error":case"stopped":return{label:"运行异常",badge:"bg-red-100 text-red-700",dot:"bg-red-500"};default:return{label:"状态检测中",badge:"bg-gray-100 text-gray-600",dot:"bg-gray-400"}}},vs=Ee.memo(function({account:s,refreshing:r,deleting:a,onRefreshProfile:u,onReauthorize:x,onEdit:o,onAI:i,onTasks:b,onToggle:m,onDelete:p}){const h=Ns(s),d=s.runtime_state==="auth_expired"||s.runtime_state==="verification_required";return e.jsx("div",{className:"ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-5 sm:gap-8",children:[e.jsxs("div",{className:"relative",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.nickname||"账号头像",className:"w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"}):e.jsx("div",{className:"w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center",children:e.jsx(Pe,{className:"w-9 h-9"})}),e.jsx("div",{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${h.dot}`,children:s.runtime_state==="online"&&e.jsx(se,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-1",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900 break-words",children:s.nickname||s.remark||`账号 ${s.id.substring(0,6)}...`}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-lg text-xs font-bold ${h.badge}`,children:h.label}),s.ai_enabled&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1",children:[e.jsx(ie,{className:"w-3 h-3"})," AI"]}),s.auto_rate_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700",children:[e.jsx(xs,{className:"h-3 w-3"})," 自动评价"]}),s.auto_polish_enabled&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700",children:[e.jsx(Se,{className:"h-3 w-3"})," 每日擦亮"]}),s.auto_confirm&&e.jsxs("span",{className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700",children:[e.jsx(se,{className:"h-3 w-3"})," 自动确认发货"]}),s.profile_error&&e.jsxs("span",{className:"px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1",title:s.profile_error,children:[e.jsx(je,{className:"w-3 h-3"})," 资料未同步"]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between Line truncated
@@ -1,4 +1,4 @@
import{b as z,j as e,r}from"./react-vendor-C_od1ZSF.js";import{X as G,W as Y,J as $,Y as Q,f as U,N as V,C as H,_ as Z,$ as W,a0 as K,a1 as ee,I as te,a2 as ae,V as se,F as le,P as ne,r as re}from"./icons-vendor-ThcsWkZG.js";import{K as oe,L as ie,M as de,N as J,O as ce,P as xe}from"./index-CFJ5pUjO.js";const pe=({dataCards:c,downloadCardTemplate:d,...s})=>{var x;const u=a=>{var m;s.setBatchFile(((m=a.target.files)==null?void 0:m[0])||null)},p=a=>{s.setAppendContent(a.target.value)},_=a=>{s.setAppendTargetId(a.target.value)},j=()=>s.closeBatchModal(),f=()=>s.setBatchTab("create"),i=()=>s.setBatchTab("append"),A=()=>void s.handleRetryBatchCreate(),o=()=>void s.handleRetryBatchAppend(),y=s.batchResult&&"rows"in s.batchResult?s.batchResult:null,N=a=>e.jsxs("option",{value:String(a.id),children:[a.name,"(ID: ",a.id,")"]},a.id),b=()=>void s.handleBatchCreate(),l=()=>void s.handleBatchAppend();return s.showBatchModal?z.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:j,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(G,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:f,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${s.batchTab==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Y,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:i,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${s.batchTab==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx($,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),s.batchTab==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),"。 类型填 text/data/image;data 类型的“内容”按行存卡密(CSV 单元格内换行需用引号包裹)。"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:d,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm transition-colors",children:[e.jsx(Q,{className:"w-4 h-4"}),"下载模板"]}),e.jsxs("label",{className:"flex-1 px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm cursor-pointer transition-colors",children:[e.jsx($,{className:"w-4 h-4"}),s.batchFile?s.batchFile.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:u})]})]}),((x=s.batchResult)==null?void 0:x.error)&&e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:s.batchResult.error}),e.jsx("button",{type:"button",onClick:A,disabled:!s.batchFile||s.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),y&&e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4 space-y-2",children:[e.jsxs("div",{className:"text-sm font-bold text-gray-900",children:["共 ",y.total," 行 · 成功 ",y.created," · 失败 ",y.failed]}),y.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:y.rows.filter(a=>!a.success).map(a=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",a.row_no," 行「",a.name,"」:",a.error]},a.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:c.length===0?e.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-800",children:"暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"选择卡密组"}),e.jsx("select",{value:s.appendTargetId,onChange:_,className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:c.map(N)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"卡密号(每行一个)"}),e.jsx("textarea",{value:s.appendContent,onChange:p,placeholder:`Line truncated
import{b as z,j as e,r}from"./react-vendor-C_od1ZSF.js";import{X as G,W as Y,J as $,Y as Q,f as U,N as V,C as H,_ as Z,$ as W,a0 as K,a1 as ee,I as te,a2 as ae,V as se,F as le,P as ne,r as re}from"./icons-vendor-ThcsWkZG.js";import{K as oe,L as ie,M as de,N as J,O as ce,P as xe}from"./index-CsLZwESi.js";const pe=({dataCards:c,downloadCardTemplate:d,...s})=>{var x;const u=a=>{var m;s.setBatchFile(((m=a.target.files)==null?void 0:m[0])||null)},p=a=>{s.setAppendContent(a.target.value)},_=a=>{s.setAppendTargetId(a.target.value)},j=()=>s.closeBatchModal(),f=()=>s.setBatchTab("create"),i=()=>s.setBatchTab("append"),A=()=>void s.handleRetryBatchCreate(),o=()=>void s.handleRetryBatchAppend(),y=s.batchResult&&"rows"in s.batchResult?s.batchResult:null,N=a=>e.jsxs("option",{value:String(a.id),children:[a.name,"(ID: ",a.id,")"]},a.id),b=()=>void s.handleBatchCreate(),l=()=>void s.handleBatchAppend();return s.showBatchModal?z.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:j,className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(G,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:f,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${s.batchTab==="create"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Y,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:i,className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${s.batchTab==="append"?"bg-brand text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx($,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),s.batchTab==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),"。 类型填 text/data/image;data 类型的“内容”按行存卡密(CSV 单元格内换行需用引号包裹)。"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:d,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm transition-colors",children:[e.jsx(Q,{className:"w-4 h-4"}),"下载模板"]}),e.jsxs("label",{className:"flex-1 px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text-sm cursor-pointer transition-colors",children:[e.jsx($,{className:"w-4 h-4"}),s.batchFile?s.batchFile.name:"选择 .xlsx / .csv / .tsv",e.jsx("input",{type:"file",accept:".xlsx,.csv,.tsv",className:"hidden",onChange:u})]})]}),((x=s.batchResult)==null?void 0:x.error)&&e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:s.batchResult.error}),e.jsx("button",{type:"button",onClick:A,disabled:!s.batchFile||s.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),y&&e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4 space-y-2",children:[e.jsxs("div",{className:"text-sm font-bold text-gray-900",children:["共 ",y.total," 行 · 成功 ",y.created," · 失败 ",y.failed]}),y.failed>0&&e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:y.rows.filter(a=>!a.success).map(a=>e.jsxs("div",{className:"text-xs text-red-600",children:["第 ",a.row_no," 行「",a.name,"」:",a.error]},a.row_no))})]})]}):e.jsx("div",{className:"space-y-4",children:c.length===0?e.jsx("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-4 text-sm text-amber-800",children:"暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"选择卡密组"}),e.jsx("select",{value:s.appendTargetId,onChange:_,className:"w-full ios-input px-4 py-3 rounded-xl text-sm",children:c.map(N)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-800",children:"卡密号(每行一个)"}),e.jsx("textarea",{value:s.appendContent,onChange:p,placeholder:`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:["预览:",s.appendPreview.length," 个有效卡密,空行自动忽略。"]})]}),s.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:s.appendError}),e.jsx("button",{type:"button",onClick:o,disabled:s.batchBusy,className:"font-bold whitespace-nowrap",children:"重试"})]}),s.appendResult&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",s.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:j,className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),s.batchTab==="create"?e.jsxs("button",{onClick:b,disabled:!s.batchFile||s.batchBusy,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[s.batchBusy?e.jsx(U,{className:"w-4 h-4 animate-spin"}):e.jsx($,{className:"w-4 h-4"}),s.batchBusy?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:l,disabled:!s.appendTargetId||s.appendPreview.length===0||s.batchBusy||c.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[s.batchBusy?e.jsx(U,{className:"w-4 h-4 animate-spin"}):e.jsx(V,{className:"w-4 h-4"}),s.batchBusy?"处理中...":"追加卡密"]})]})]})}),document.body):null},me=({type:c})=>{switch(c){case"text":return e.jsx(K,{className:"w-5 h-5 text-blue-500"});case"image":return e.jsx(W,{className:"w-5 h-5 text-purple-500"});case"api":return e.jsx(Z,{className:"w-5 h-5 text-blue-500"});default:return e.jsx(H,{className:"w-5 h-5 text-gray-500"})}},he=(c,d,s)=>{const u=s.trim().toLocaleLowerCase();return c.filter(p=>(!d||p.type===d)&&(!u||p.name.toLocaleLowerCase().includes(u)))},X=c=>c.split(`
`).map(d=>d.trim()).filter(Boolean),ue=(c,d,s)=>!!(c&&X(d).length>0&&!s),F=(c,d,s,u)=>c===d&&s===u,be=()=>{const[c,d]=r.useState([]),[s,u]=r.useState(!0),p=r.useRef(0),_=r.useRef(null),j=r.useCallback(async()=>{var A;const f=++p.current;(A=_.current)==null||A.abort();const i=new AbortController;_.current=i,u(!0);try{const o=await oe({signal:i.signal});if(f!==p.current)return;d(o)}catch(o){f===p.current&&!i.signal.aborted&&console.error("加载卡密库存失败:",o)}finally{f===p.current&&u(!1)}},[]);return r.useEffect(()=>(j(),()=>{var i;p.current+=1,(i=_.current)==null||i.abort()}),[j]),{cards:c,setCards:d,loading:s,loadCards:j}},ge=c=>{const d=c.dataCards,s=c.loadCards,[u,p]=r.useState(!1),[_,j]=r.useState("create"),[f,i]=r.useState(null),[A,o]=r.useState(null),[y,N]=r.useState(!1),[b,l]=r.useState(""),[x,a]=r.useState(""),[m,E]=r.useState(null),[M,R]=r.useState(""),w=r.useRef(0),T=r.useRef(null),P=r.useRef(""),L=r.useMemo(()=>X(x),[x]),n=r.useCallback(()=>{var h;j("create"),i(null),o(null),l((h=d[0])!=null&&h.id?String(d[0].id):""),a(""),E(null),R(""),p(!0)},[d]),t=r.useCallback(()=>{var h;w.current+=1,(h=T.current)==null||h.abort(),N(!1),p(!1)},[]),g=r.useCallback(async()=>{var v;if(!f||y)return;const h=++w.current;(v=T.current)==null||v.abort();const B=new AbortController;T.current=B,N(!0),o(null);try{const I=await ie(f,{signal:B.signal});if(!F(h,w.current,"",""))return;o(I),I.created>0&&await s()}catch(I){if(!F(h,w.current,"",""))return;o({error:(I==null?void 0:I.message)||"上传失败"})}finally{F(h,w.current,"","")&&N(!1)}},[y,f,s]),k=r.useCallback(async()=>{var I;if(!ue(b,x,y))return;const h=b,B=++w.current;P.current=h,(I=T.current)==null||I.abort();const v=new AbortController;T.current=v,N(!0),E(null),R("");try{const O=await de(h,x,{signal:v.signal});if(!F(B,w.current,h,b))return;E({added:O.added}),a(""),await s()}catch(O){if(!F(B,w.current,h,b))return;R((O==null?void 0:O.message)||"追加失败")}finally{F(B,w.current,h,b)&&N(!1)}},[x,b,y,s]),S=r.useCallback(async()=>{await g()},[g]),C=r.useCallback(async()=>{P.current&&b!==P.current||await k()},[b,k]);return{showBatchModal:u,setShowBatchModal:p,batchTab:_,setBatchTab:j,batchFile:f,setBatchFile:i,batchResult:A,batchBusy:y,appendTargetId:b,setAppendTargetId:l,appendContent:x,setAppendContent:a,appendResult:m,appendError:M,appendPreview:L,openBatchModal:n,closeBatchModal:t,handleBatchCreate:g,handleBatchAppend:k,handleRetryBatchCreate:S,handleRetryBatchAppend:C}},q=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),D=(c,d)=>c instanceof Error?c.message:d,ye=({cards:c,loadCards:d})=>{const[s,u]=r.useState(!1),[p,_]=r.useState(!1),[j,f]=r.useState(null),[i,A]=r.useState({}),[o,y]=r.useState(q),[N,b]=r.useState(""),[l,x]=r.useState(""),a=r.useMemo(()=>c.filter(n=>n.type==="data"),[c]),m=r.useMemo(()=>he(c,N,l),[c,l,N]),E=r.useCallback(n=>{var t,g,k,S,C;f(n),A({id:n.id,name:n.name||"",type:n.type||"text",api_url:((t=n.api_config)==null?void 0:t.url)||"",api_method:((g=n.api_config)==null?void 0:g.method)||"GET",api_timeout:((k=n.api_config)==null?void 0:k.timeout)||10,api_headers:((S=n.api_config)==null?void 0:S.headers)||"",api_params:((C=n.api_config)==null?void 0:C.params)||"",text_content:n.text_content||"",data_content:n.data_content||"",image_url:n.image_url||"",delay_seconds:n.delay_seconds||0,description:n.description||"",enabled:n.enabled}),u(!0)},[]),M=r.useCallback(async()=>{var n,t,g,k,S,C,h,B;if(j){if(!((n=i.name)!=null&&n.trim())){alert("请输入卡密名称");return}if(!i.type){alert("请选择卡密类型");return}try{const v={name:i.name.trim(),type:i.type,description:(t=i.description)==null?void 0:t.trim(),delay_seconds:i.delay_seconds||0,enabled:i.enabled??!0};i.type==="api"?v.api_config={url:((g=i.api_url)==null?void 0:g.trim())||"",method:i.api_method||"GET",timeout:i.api_timeout||10,headers:((k=i.api_headers)==null?void 0:k.trim())||void 0,params:((S=i.api_params)==null?void 0:S.trim())||void 0}:i.type==="text"?v.text_content=((C=i.text_content)==null?void 0:C.trim())||"":i.type==="data"?v.data_content=((h=i.data_content)==null?void 0:h.trim())||"":i.type==="image"&&(v.image_url=((B=i.image_url)==null?void 0:B.trim())||""),await J(j.id,v),u(!1),await d()}catch(v){console.error("更新卡密失败:",v),alert(D(v,"更新失败,请重试"))}}},[i,d,j]),R=r.useCallback(async n=>{if(confirm("确认删除该卡密吗?"))try{await ce(n),await d()}catch(t){console.error("删除卡密失败:",t),alert(D(t,"删除失败,请重试"))}},[d]),w=r.useCallback(async()=>{if(!o.name.trim()){alert("请输入卡密名称");return}if(!o.content.trim()){alert(o.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const n={name:o.name.trim(),type:o.type,description:o.description.trim(),enabled:o.enabled,delay_seconds:o.delay_seconds};o.type==="text"&&(n.text_content=o.content.trim()),o.type==="data"&&(n.data_content=o.content.trim()), Line truncated
@@ -1 +1 @@
import{j as e,c as W0,r as a}from"./react-vendor-C_od1ZSF.js";import{ap as R0,aq as M0,ar as q0,as as G0,at as X0,h as Y0,j as T0}from"./index-CFJ5pUjO.js";import{f as i0,ak as K0,al as $0,M as L0,I as ee,R as te,ad as E0,k as se,am as ie,s as ae,an as ne,ao as re,ah as le}from"./icons-vendor-ThcsWkZG.js";const U0=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["Line truncated
import{j as e,c as W0,r as a}from"./react-vendor-C_od1ZSF.js";import{ap as R0,aq as M0,ar as q0,as as G0,at as X0,h as Y0,j as T0}from"./index-CsLZwESi.js";import{f as i0,ak as K0,al as $0,M as L0,I as ee,R as te,ad as E0,k as se,am as ie,s as ae,an as ne,ao as re,ah as le}from"./icons-vendor-ThcsWkZG.js";const U0=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["Line truncated
@@ -1 +1 @@
import{r as d,j as e}from"./react-vendor-C_od1ZSF.js";import{g as oe,a as ie,b as le,c as ce,d as H,e as de}from"./index-CFJ5pUjO.js";import{f as xe}from"./dateTime-DDi7rqpW.js";import{j as ne,k as me,l as J,D as ue,U as he,P as ge,m as Q,E as be,T as pe}from"./icons-vendor-ThcsWkZG.js";import{R as E,B as fe,X as Z,Y as ee,T as z,a as ye,C as V,A as je,b as ve,c as Ne,P as te,d as se,L as we}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";const _e=s=>{const r={};return s.forEach(a=>{r[a.item_id]=a.item_title||a.item_id}),r},ke=s=>{var r;return((r=s.daily_stats)==null?void 0:r.map(a=>({name:a.date.slice(5),amount:a.amount,orders:a.order_count,avgAmount:a.order_count>0?(a.amount/a.order_count).toFixed(2):0})))||[]},Ce=(s,r)=>(s.item_stats||[]).map(a=>{const n=r[a.item_id]||a.item_id;return{name:n.length>12?`${n.substring(0,12)}...`:n,sales:a.order_count}}).sort((a,n)=>n.sales-a.sales).slice(0,10),Se=(s,r,a)=>{const n=s.revenue_stats.total_orders||0;return(s.item_stats||[]).map(l=>{const o=r[l.item_id]||l.item_id;return{name:o.length>10?`${o.substring(0,10)}...`:o,value:l.order_count,percent:n>0?l.order_count/n*100:0}}).sort((l,o)=>o.value-l.value).slice(0,6).map((l,o)=>({...l,color:a[o%a.length]}))},De=(s,r,a)=>{const n=s.revenue_stats.total_amount||0;return(s.item_stats||[]).map(l=>{const o=r[l.item_id]||l.item_id;return{name:o.length>12?`${o.substring(0,12)}...`:o,value:l.total_amount,orderCount:l.order_count,percentage:n>0?l.total_amount/n*100:0}}).sort((l,o)=>o.value-l.value).slice(0,5).map((l,o)=>({...l,color:a[o%a.length],percentage:l.percentage.toFixed(1)}))},$e=(s,r)=>{if(!s||!r)return null;const a=s.revenue_stats.total_amount,n=r.revenue_stats.total_amount;if(n===0)return a>0?"+100%":"0%";const l=(a-n)/n*100;return`${l>=0?"+":""}${l.toFixed(1)}%`},Re=s=>({today:"今天",yesterday:"昨天","3days":"三天内","7days":"7天内","30days":"一个月内",custom:"自定义"})[s.range]||"所选范围",Le=s=>Math.max(...s.map(r=>r.sales),1),ae=(s,r,a)=>s===r&&!a.aborted,re=s=>s instanceof Error&&s.message==="请求已取消",q=(s,r)=>s instanceof Error?s.message:r,Ae=s=>{const{range:r,customStartDate:a,customEndDate:n,customRangeVersion:l}=s,[o,S]=d.useState(null),[w,M]=d.useState(null),[F,v]=d.useState({overview:"idle",range:"idle",error:""}),[c,O]=d.useState(0),D=d.useRef(0),P=d.useMemo(()=>({range:r,customStartDate:a,customEndDate:n}),[n,a,r]),$=d.useCallback(()=>O(x=>x+1),[]);d.useEffect(()=>{const x=new AbortController;return v(g=>({...g,overview:"loading",error:""})),Promise.all([oe({signal:x.signal}),ie(void 0,{signal:x.signal})]).then(([g,h])=>{x.signal.aborted||(S({stats:g,items:h,itemNames:_e(h)}),v(u=>({...u,overview:"success"})))}).catch(g=>{x.signal.aborted||re(g)||v(h=>({...h,overview:"error",error:q(g,"概览加载失败")}))}),(()=>x.abort())},[c]),d.useEffect(()=>{let x;try{x=le(r,new Date,a,n)}catch(b){v(k=>({...k,range:"error",error:q(b,"日期范围无效")}));return}const g=ce(x),h=++D.current,u=new AbortController;return v(b=>({...b,range:"loading",error:""})),Promise.all([H({start_date:x.startDate,end_date:x.endDate},{signal:u.signal}),H({start_date:g.startDate,end_date:g.endDate},{signal:u.signal}),de({start_date:x.startDate,end_date:x.endDate},{signal:u.signal})]).then(([b,k,L])=>{ae(D.current,h,u.signal)&&(M({analytics:b,previousAnalytics:k,validOrders:L,dateRange:x}),v(B=>({...B,range:"success"})))}).catch(b=>{!ae(D.current,h,u.signal)||re(b)||v(k=>({...k,range:"error",error:q(b,"经营数据加载失败")}))}),(()=>u.abort())},[l,r,c]);const f=d.useMemo(()=>o&&w?{...o,...w}:null,[o,w]),_=(o==null?void 0:o.itemNames)||{},m=(w==null?void 0:w.analytics)||null,K=d.useMemo(()=>m?ke(m):[],[m]),C=d.useMemo(()=>m?Ce(m,_):[],[m,_]),y=d.useMemo(()=>["rgb(var(--color-brand))","rgb(var(--color-brand-highlight))","rgb(var(--color-success-500))","rgb(var(--color-warning-500))","rgb(var(--color-accent-500))"],[]),N=d.useMemo(()=>m?Se(m,_,y):[],[m,y,_]),R=d.useMemo(()=>m?De(m,_,y):[],[m,y,_]),I=d.useMemo(()=>Le(C),[C]);return{data:f,status:F,chartData:K,productSalesData:C,sourceData:N,categoryData:R,maxProductSales:I,trendPercent:$e(m,(f==null?void 0:f.previousAnalytics)||null),selectedRangeLabel:Re(P),refresh:$}},i=(s,r)=>r===void 0?`rgb(var(--color-${s}))`:`rgb(var(--color-${s}) / ${r})`,Oe=({chartData:s,selectedRangeLabel:r,totalAmount:a})=>e.jsxs("div",{className:"ios-card p-8 rounded-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900",children:"营收趋势分析"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[r,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:s.length===0||a===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(ne,{className:"w-16 h-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无营收数据"}),e.jsx("p",{className:"text-sm mt-2",children:"所Line truncated
import{r as d,j as e}from"./react-vendor-C_od1ZSF.js";import{g as oe,a as ie,b as le,c as ce,d as H,e as de}from"./index-CsLZwESi.js";import{f as xe}from"./dateTime-DDi7rqpW.js";import{j as ne,k as me,l as J,D as ue,U as he,P as ge,m as Q,E as be,T as pe}from"./icons-vendor-ThcsWkZG.js";import{R as E,B as fe,X as Z,Y as ee,T as z,a as ye,C as V,A as je,b as ve,c as Ne,P as te,d as se,L as we}from"./charts-vendor-BxxJOyEX.js";import"./vendor-D-Edl3pr.js";const _e=s=>{const r={};return s.forEach(a=>{r[a.item_id]=a.item_title||a.item_id}),r},ke=s=>{var r;return((r=s.daily_stats)==null?void 0:r.map(a=>({name:a.date.slice(5),amount:a.amount,orders:a.order_count,avgAmount:a.order_count>0?(a.amount/a.order_count).toFixed(2):0})))||[]},Ce=(s,r)=>(s.item_stats||[]).map(a=>{const n=r[a.item_id]||a.item_id;return{name:n.length>12?`${n.substring(0,12)}...`:n,sales:a.order_count}}).sort((a,n)=>n.sales-a.sales).slice(0,10),Se=(s,r,a)=>{const n=s.revenue_stats.total_orders||0;return(s.item_stats||[]).map(l=>{const o=r[l.item_id]||l.item_id;return{name:o.length>10?`${o.substring(0,10)}...`:o,value:l.order_count,percent:n>0?l.order_count/n*100:0}}).sort((l,o)=>o.value-l.value).slice(0,6).map((l,o)=>({...l,color:a[o%a.length]}))},De=(s,r,a)=>{const n=s.revenue_stats.total_amount||0;return(s.item_stats||[]).map(l=>{const o=r[l.item_id]||l.item_id;return{name:o.length>12?`${o.substring(0,12)}...`:o,value:l.total_amount,orderCount:l.order_count,percentage:n>0?l.total_amount/n*100:0}}).sort((l,o)=>o.value-l.value).slice(0,5).map((l,o)=>({...l,color:a[o%a.length],percentage:l.percentage.toFixed(1)}))},$e=(s,r)=>{if(!s||!r)return null;const a=s.revenue_stats.total_amount,n=r.revenue_stats.total_amount;if(n===0)return a>0?"+100%":"0%";const l=(a-n)/n*100;return`${l>=0?"+":""}${l.toFixed(1)}%`},Re=s=>({today:"今天",yesterday:"昨天","3days":"三天内","7days":"7天内","30days":"一个月内",custom:"自定义"})[s.range]||"所选范围",Le=s=>Math.max(...s.map(r=>r.sales),1),ae=(s,r,a)=>s===r&&!a.aborted,re=s=>s instanceof Error&&s.message==="请求已取消",q=(s,r)=>s instanceof Error?s.message:r,Ae=s=>{const{range:r,customStartDate:a,customEndDate:n,customRangeVersion:l}=s,[o,S]=d.useState(null),[w,M]=d.useState(null),[F,v]=d.useState({overview:"idle",range:"idle",error:""}),[c,O]=d.useState(0),D=d.useRef(0),P=d.useMemo(()=>({range:r,customStartDate:a,customEndDate:n}),[n,a,r]),$=d.useCallback(()=>O(x=>x+1),[]);d.useEffect(()=>{const x=new AbortController;return v(g=>({...g,overview:"loading",error:""})),Promise.all([oe({signal:x.signal}),ie(void 0,{signal:x.signal})]).then(([g,h])=>{x.signal.aborted||(S({stats:g,items:h,itemNames:_e(h)}),v(u=>({...u,overview:"success"})))}).catch(g=>{x.signal.aborted||re(g)||v(h=>({...h,overview:"error",error:q(g,"概览加载失败")}))}),(()=>x.abort())},[c]),d.useEffect(()=>{let x;try{x=le(r,new Date,a,n)}catch(b){v(k=>({...k,range:"error",error:q(b,"日期范围无效")}));return}const g=ce(x),h=++D.current,u=new AbortController;return v(b=>({...b,range:"loading",error:""})),Promise.all([H({start_date:x.startDate,end_date:x.endDate},{signal:u.signal}),H({start_date:g.startDate,end_date:g.endDate},{signal:u.signal}),de({start_date:x.startDate,end_date:x.endDate},{signal:u.signal})]).then(([b,k,L])=>{ae(D.current,h,u.signal)&&(M({analytics:b,previousAnalytics:k,validOrders:L,dateRange:x}),v(B=>({...B,range:"success"})))}).catch(b=>{!ae(D.current,h,u.signal)||re(b)||v(k=>({...k,range:"error",error:q(b,"经营数据加载失败")}))}),(()=>u.abort())},[l,r,c]);const f=d.useMemo(()=>o&&w?{...o,...w}:null,[o,w]),_=(o==null?void 0:o.itemNames)||{},m=(w==null?void 0:w.analytics)||null,K=d.useMemo(()=>m?ke(m):[],[m]),C=d.useMemo(()=>m?Ce(m,_):[],[m,_]),y=d.useMemo(()=>["rgb(var(--color-brand))","rgb(var(--color-brand-highlight))","rgb(var(--color-success-500))","rgb(var(--color-warning-500))","rgb(var(--color-accent-500))"],[]),N=d.useMemo(()=>m?Se(m,_,y):[],[m,y,_]),R=d.useMemo(()=>m?De(m,_,y):[],[m,y,_]),I=d.useMemo(()=>Le(C),[C]);return{data:f,status:F,chartData:K,productSalesData:C,sourceData:N,categoryData:R,maxProductSales:I,trendPercent:$e(m,(f==null?void 0:f.previousAnalytics)||null),selectedRangeLabel:Re(P),refresh:$}},i=(s,r)=>r===void 0?`rgb(var(--color-${s}))`:`rgb(var(--color-${s}) / ${r})`,Oe=({chartData:s,selectedRangeLabel:r,totalAmount:a})=>e.jsxs("div",{className:"ios-card p-8 rounded-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900",children:"营收趋势分析"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[r,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:s.length===0||a===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(ne,{className:"w-16 h-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无营收数据"}),e.jsx("p",{className:"text-sm mt-2",children:"所Line truncated
@@ -1,2 +1,2 @@
import{r as l,j as e,b as ne}from"./react-vendor-C_od1ZSF.js";import{Q as Fe,R as W,S as nt,T as ct,U as dt,V as ot,W as xt,X as mt,a as _e,Y as ke,h as ht,Z as ut,_ as pt,$ as gt,a0 as bt,a1 as yt}from"./index-CFJ5pUjO.js";import{a3 as ft,i as Ce,R as me,N as Ie,a4 as he,a5 as ce,V as jt,F as Nt,B as vt,a6 as Se,a7 as wt,a8 as _t,A as kt,S as Ct,X as H,r as It,a9 as Be,I as Pe}from"./icons-vendor-ThcsWkZG.js";const Ae="ydisks-amap-js-api",St="c9b68d4ce9a2a97f22a4a439404488ca";let Q=null;const Bt=()=>St,Pt=()=>window.AMap?Promise.resolve(window.AMap):Q||(Q=new Promise((a,n)=>{const h=document.getElementById(Ae),o=h||document.createElement("script"),x=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(B)},g=()=>{window.AMap?(x(),a(window.AMap)):(x(),n(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},B=window.setTimeout(()=>{x(),n(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=g,o.id=Ae,o.async=!0,o.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(Bt())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,o.onerror=()=>{x(),n(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},h||document.head.appendChild(o)}).catch(a=>{throw Q=null,a}),Q),de=a=>Number.isFinite(a)&&a!==0,At=a=>{var x,g;const n=Number((x=a.location)==null?void 0:x.lng),h=Number((g=a.location)==null?void 0:g.lat),o={area:String(a.adname||"").trim(),city:String(a.cityname||"").trim(),division_id:String(a.adcode||"").trim(),longitude:n,latitude:h,poi_id:String(a.id||"").trim(),poi_name:String(a.name||"").trim(),province:String(a.pname||"").trim()};return!o.division_id||!o.province||!o.city||!o.poi_id||!o.poi_name||!de(n)||!de(h)||n<-180||n>180||h<-90||h>90?null:o},Lt=async(a,n)=>{if(!de(a)||!de(n)||a<-180||a>180||n<-90||n>90)throw new Error("经纬度无效");const h=await Pt();return new Promise((o,x)=>{new h.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[a,n],1e3,(B,u)=>{var k;if(B!=="complete"){if(B==="no_data"){o([]);return}x(new Error("高德地图附近地址查询失败,请稍后重试"));return}const D=(((k=u==null?void 0:u.poiList)==null?void 0:k.pois)||[]).map(At).filter(z=>z!==null);o(D)})})},Rt=a=>a.find(n=>n.status==="running"||n.status==="canceling"),ue=a=>a==="running"||a==="canceling",Ft=a=>!!(a!=null&&a.preview_id&&Number(a.valid||0)>0),Mt=a=>!!(a!=null&&a.id&&Number(a.retryable||0)>0&&!ue(a.status)),Et=(a,n)=>a===n,Le=a=>{switch(a){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return a||"-"}},Re=a=>{switch(a){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},$t=a=>{const[n,h]=l.useState(!1),[o,x]=l.useState("upload"),[g,B]=l.useState(null),[u,D]=l.useState(null),[k,z]=l.useState(""),[ee,Y]=l.useState(!1),[T,K]=l.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[f,R]=l.useState(null),[d,w]=l.useState(null),[C,F]=l.useState(null),[O,Z]=l.useState([]),[M,G]=l.useState(null),[te,b]=l.useState(!1),S=l.useRef(!1),J=l.useRef(0),j=l.useCallback(async()=>{x("upload"),R(null),w(null),B(null),D(null),z(""),K({catId:"",catName:"",channelCatId:"",tbCatId:""}),Z([]),G(null),h(!0),b(!0);try{const i=await Fe(20),m=Rt(i);if(m!=null&&m.id){const I=await W(m.id);F(I),w(I),x(["running","canceling"].includes(I.status)?"running":"done")}}catch(i){console.error("恢复最近批量铺货任务失败:",i)}finally{b(!1)}},[]),U=l.useCallback(async()=>{const i=k.trim();if(!a.selectedAccount){alert("请先选择默认发布账号");return}if(!i){alert("请输入类目关键词");return}Y(!0);try{const I=(await nt(a.selectedAccount,i)).category;K({catId:I.cat_id,catName:I.cat_name,channelCatId:I.channel_cat_id,tbCatId:I.tb_cat_id||""})}catch(m){console.error("获取推荐类目失败:",m),alert((m==null?void 0:m.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{Y(!1)}},[k,a.selectedAccount]),p=l.useCallback(async()=>{if(C!=null&&C.id){b(!0),h(!0);try{const i=await W(C.id);w(i),x(["running","canceling"].includes(i.status)?"running":"done")}catch(i){console.error("加载最近批量铺货结果失败:",i)}finally{b(!1)}}},[C==null?void 0:C.id]),P=l.useCallback(async()=>{if(!g){alert("请先上传商品表格");return}if(!a.selectedAccount){alert("请先选择默认发布账号");return}b(!0);try{const i=await ct({file:g,imagesZip:u,defaultCookieId:a.selectedAccount,fallbackCategoryLine truncated
import{r as l,j as e,b as ne}from"./react-vendor-C_od1ZSF.js";import{Q as Fe,R as W,S as nt,T as ct,U as dt,V as ot,W as xt,X as mt,a as _e,Y as ke,h as ht,Z as ut,_ as pt,$ as gt,a0 as bt,a1 as yt}from"./index-CsLZwESi.js";import{a3 as ft,i as Ce,R as me,N as Ie,a4 as he,a5 as ce,V as jt,F as Nt,B as vt,a6 as Se,a7 as wt,a8 as _t,A as kt,S as Ct,X as H,r as It,a9 as Be,I as Pe}from"./icons-vendor-ThcsWkZG.js";const Ae="ydisks-amap-js-api",St="c9b68d4ce9a2a97f22a4a439404488ca";let Q=null;const Bt=()=>St,Pt=()=>window.AMap?Promise.resolve(window.AMap):Q||(Q=new Promise((a,n)=>{const h=document.getElementById(Ae),o=h||document.createElement("script"),x=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(B)},g=()=>{window.AMap?(x(),a(window.AMap)):(x(),n(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},B=window.setTimeout(()=>{x(),n(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=g,o.id=Ae,o.async=!0,o.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(Bt())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,o.onerror=()=>{x(),n(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},h||document.head.appendChild(o)}).catch(a=>{throw Q=null,a}),Q),de=a=>Number.isFinite(a)&&a!==0,At=a=>{var x,g;const n=Number((x=a.location)==null?void 0:x.lng),h=Number((g=a.location)==null?void 0:g.lat),o={area:String(a.adname||"").trim(),city:String(a.cityname||"").trim(),division_id:String(a.adcode||"").trim(),longitude:n,latitude:h,poi_id:String(a.id||"").trim(),poi_name:String(a.name||"").trim(),province:String(a.pname||"").trim()};return!o.division_id||!o.province||!o.city||!o.poi_id||!o.poi_name||!de(n)||!de(h)||n<-180||n>180||h<-90||h>90?null:o},Lt=async(a,n)=>{if(!de(a)||!de(n)||a<-180||a>180||n<-90||n>90)throw new Error("经纬度无效");const h=await Pt();return new Promise((o,x)=>{new h.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[a,n],1e3,(B,u)=>{var k;if(B!=="complete"){if(B==="no_data"){o([]);return}x(new Error("高德地图附近地址查询失败,请稍后重试"));return}const D=(((k=u==null?void 0:u.poiList)==null?void 0:k.pois)||[]).map(At).filter(z=>z!==null);o(D)})})},Rt=a=>a.find(n=>n.status==="running"||n.status==="canceling"),ue=a=>a==="running"||a==="canceling",Ft=a=>!!(a!=null&&a.preview_id&&Number(a.valid||0)>0),Mt=a=>!!(a!=null&&a.id&&Number(a.retryable||0)>0&&!ue(a.status)),Et=(a,n)=>a===n,Le=a=>{switch(a){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return a||"-"}},Re=a=>{switch(a){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},$t=a=>{const[n,h]=l.useState(!1),[o,x]=l.useState("upload"),[g,B]=l.useState(null),[u,D]=l.useState(null),[k,z]=l.useState(""),[ee,Y]=l.useState(!1),[T,K]=l.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[f,R]=l.useState(null),[d,w]=l.useState(null),[C,F]=l.useState(null),[O,Z]=l.useState([]),[M,G]=l.useState(null),[te,b]=l.useState(!1),S=l.useRef(!1),J=l.useRef(0),j=l.useCallback(async()=>{x("upload"),R(null),w(null),B(null),D(null),z(""),K({catId:"",catName:"",channelCatId:"",tbCatId:""}),Z([]),G(null),h(!0),b(!0);try{const i=await Fe(20),m=Rt(i);if(m!=null&&m.id){const I=await W(m.id);F(I),w(I),x(["running","canceling"].includes(I.status)?"running":"done")}}catch(i){console.error("恢复最近批量铺货任务失败:",i)}finally{b(!1)}},[]),U=l.useCallback(async()=>{const i=k.trim();if(!a.selectedAccount){alert("请先选择默认发布账号");return}if(!i){alert("请输入类目关键词");return}Y(!0);try{const I=(await nt(a.selectedAccount,i)).category;K({catId:I.cat_id,catName:I.cat_name,channelCatId:I.channel_cat_id,tbCatId:I.tb_cat_id||""})}catch(m){console.error("获取推荐类目失败:",m),alert((m==null?void 0:m.message)||"没有匹配到类目,请换一个更具体的关键词")}finally{Y(!1)}},[k,a.selectedAccount]),p=l.useCallback(async()=>{if(C!=null&&C.id){b(!0),h(!0);try{const i=await W(C.id);w(i),x(["running","canceling"].includes(i.status)?"running":"done")}catch(i){console.error("加载最近批量铺货结果失败:",i)}finally{b(!1)}}},[C==null?void 0:C.id]),P=l.useCallback(async()=>{if(!g){alert("请先上传商品表格");return}if(!a.selectedAccount){alert("请先选择默认发布账号");return}b(!0);try{const i=await ct({file:g,imagesZip:u,defaultCookieId:a.selectedAccount,fallbackCategoryLine truncated
`),y=new Blob(["\uFEFF"+c],{type:"text/csv;charset=utf-8"}),q=URL.createObjectURL(y),L=document.createElement("a");L.href=q,L.download="批量铺货模板.csv",document.body.appendChild(L),L.click(),L.remove(),URL.revokeObjectURL(q)},st=()=>{P(t=>({...t,cookie_id:u||t.cookie_id})),w(!0)},at=()=>{_(t=>({...t,cookie_id:u||t.cookie_id})),F(!0)},je=async t=>{if(!(t?u:r.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");Z(!0),navigator.geolocation.getCurrentPosition(async c=>{try{const y=await Lt(c.coords.longitude,c.coords.latitude);if(!y.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");t?(ye(y),xe(y[0])):(G(y),b(y[0]))}catch(y){alert((y==null?void 0:y.message)||"获取发货地失败")}finally{Z(!1)}},c=>{Z(!1),alert(c.code===c.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")},{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})},lt=t=>o.filter(s=>s.cookie_id===t.cookie_id&&s.item_id===t.item_id).length>0?o.filter(s=>s.cookie_id===t.cookie_id&&s.item_id===t.item_id):o.filter(s=>s.cookie_id===t.cookie_id&&!s.item_id),Ne=l.useMemo(()=>new Map(g.map(t=>[t.id,t])),[g]),ve=l.useMemo(()=>k?n.filter(t=>t.cookie_id===k):n,[k,n]),X=t=>{const s=Ne.get(t),c=(s==null?void 0:s.remark)||(s==null?void 0:s.nickname);return c?`${c} · ${t.slice(0,6)}`:`账号 ${t.slice(0,8)}`},we=t=>{const s=Ne.get(t);return(s==null?void 0:s.remark)||(s==null?void 0:s.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(ft,{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:k,onChange:(t=>z(t.target.value)),children:[e.jsx("option",{value:"",children:"全部账号"}),g.map(t=>e.jsx("option",{value:t.id,children:X(t.id)},t.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(Ce,{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:u,onChange:(t=>D(t.target.value)),children:[e.jsx("option",{value:"",children:"请选择账号"}),g.map(t=>e.jsx("option",{value:t.id,children:X(t.id)},t.id))]})]})]}),e.jsxs("button",{onClick:We,disabled:ee||!u,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(me,{className:`w-4 h-4 ${ee?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:st,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(Ie,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:at,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(he,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:(()=>void ze()),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(ce,{className:"w-4 h-4"}),ie&&["running","canceling"].includes(ie.status)?"继续批量任务":"批量铺货"]}),ie&&!["running","canceling"].includes(ie.status)&&e.jsx("button",{onClick:(()=>void Te()),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:[ve.map(t=>{const s=lt(t),c=s.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex-col",children:[e.jsxs Line truncated
@@ -1 +1 @@
import{j as e,b as be,r as d}from"./react-vendor-C_od1ZSF.js";import{ai as ee,ah as se,aj as fe,x as G,a as W,f as I,y as ye,F as je,s as J,X as te,u as ae,v as le,r as Ne,R as _e,N as ve}from"./icons-vendor-ThcsWkZG.js";import{n as we,a3 as ke,al as Y,am as Ce,an as Se,ao as Te,a5 as Pe}from"./index-CFJ5pUjO.js";const H=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],Q=(s,t)=>{if(typeof s=="boolean")return s;if(typeof s=="string"){if(["true","1","yes","on"].includes(s.toLowerCase()))return!0;if(["false","0","no","off"].includes(s.toLowerCase()))return!1}return t},re=s=>{const t=Object.prototype.hasOwnProperty.call(s,"use_custom_smtp"),a=H.some(n=>String(s[n]??"").trim()!=="");return{...s,use_custom_smtp:t?Q(s.use_custom_smtp,!1):a}},ne=(s,t)=>{const a={...s,use_custom_smtp:!0};for(const n of H)String(a[n]??"").trim()===""&&t[n]!==void 0&&(a[n]=t[n]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=Q(a.smtp_use_tls,!0),a.smtp_use_ssl=Q(a.smtp_use_ssl,!1),a},oe=s=>{const t=re(s),a={to_email:String(t.to_email??"").trim(),use_custom_smtp:t.use_custom_smtp===!0};if(a.use_custom_smtp)for(const n of H)a[n]=t[n];return a},$={bark:{label:"Bark",icon:W,fields:[{key:"server_url",label:"Bark 服务器",placeholder:"https://api.day.app",required:!0},{key:"device_key",label:"Device Key",placeholder:"你的 Bark 设备 Key",required:!0},{key:"title",label:"标题(可选)",placeholder:"Ydisks闲鱼助手"},{key:"sound",label:"铃声(可选)",placeholder:"default"},{key:"group",label:"分组(可选)",placeholder:"xianyu"}],guide:{steps:["App Store 搜索并安装 Bark(免费)","打开 Bark App,首页会显示一条测试 URL,形如 https://api.day.app/<key>/这是测试推送内容","URL 路径里 <key> 那一段就是 Device Key,复制填入","服务器地址默认 https://api.day.app,自建服务端则填自建域名"],urlFormat:"https://api.day.app/<你的key>/测试内容",note:"不需要 secret,Device Key 本身就是唯一凭证。"}},dingtalk:{label:"钉钉机器人",icon:G,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",required:!0},{key:"secret",label:"加签密钥",placeholder:"SEC...",help:"安全设置勾选「加签」后生成,SEC 开头"}],guide:{steps:["钉钉进入一个群(可建单人群)→ 右上角 群设置","机器人 → 添加机器人 → 选择「自定义机器人」","安全设置勾选「加签」","完成页同时展示 Webhook 地址和 SEC 开头的 Secret,两个都复制","Webhook URL 填上面,Secret 填加签密钥"],urlFormat:"https://oapi.dingtalk.com/robot/send?access_token=XXX",note:"加签密钥可选,但强烈建议启用,否则机器人可能被滥用。"}},feishu:{label:"飞书机器人",icon:G,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",required:!0},{key:"secret",label:"签名校验密钥",placeholder:"sec-...",help:"安全设置选「签名校验」后生成"}],guide:{steps:["飞书进入目标群 → 右上角 更多 → 设置","群机器人 → 添加机器人 → 自定义机器人","安全设置选择「签名校验」,复制生成的秘钥","完成会给 Webhook 地址,复制","Webhook URL 填上面,秘钥填签名校验密钥"],urlFormat:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",note:"签名密钥可选,建议启用。频率限制:单机器人 100 次/分钟。"}},wechat:{label:"企业微信机器人",icon:G,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",required:!0}],guide:{steps:["企业微信进入一个内部群 → 右上角 … → 群设置","找到「群机器人」(新版可能叫「消息推送」)","添加 → 选择自定义机器人","完成给 Webhook 地址(含 ?key=),复制填入"],urlFormat:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX",note:"不需要 secret,URL 里的 key 就是唯一凭证,注意不要泄露。频率限制 20 条/分钟。"}},webhook:{label:"自定义 Webhook",icon:fe,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://your-server/notify",required:!0}],guide:{steps:["仅适用于自己有服务器的用户:在你自己的机器上起一个 HTTP 接口收 JSON","系统会 POST 这个 URL,Content-Type: application/json","请求体固定为右侧 JSON 格式,按需解析 message 字段"],urlFormat:'{"message":"告警正文","timestamp":"2026-07-05 12:00:00","source":"xianyu-auto-reply"}',note:"若用 Server酱 / PushPlus 等第三方推送服务,格式不兼容,需写中间脚本转发,或改用对应专用渠道。"}},telegram:{label:"Telegram",icon:se,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-10012Line truncated
import{j as e,b as be,r as d}from"./react-vendor-C_od1ZSF.js";import{ai as ee,ah as se,aj as fe,x as G,a as W,f as I,y as ye,F as je,s as J,X as te,u as ae,v as le,r as Ne,R as _e,N as ve}from"./icons-vendor-ThcsWkZG.js";import{n as we,a3 as ke,al as Y,am as Ce,an as Se,ao as Te,a5 as Pe}from"./index-CsLZwESi.js";const H=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],Q=(s,t)=>{if(typeof s=="boolean")return s;if(typeof s=="string"){if(["true","1","yes","on"].includes(s.toLowerCase()))return!0;if(["false","0","no","off"].includes(s.toLowerCase()))return!1}return t},re=s=>{const t=Object.prototype.hasOwnProperty.call(s,"use_custom_smtp"),a=H.some(n=>String(s[n]??"").trim()!=="");return{...s,use_custom_smtp:t?Q(s.use_custom_smtp,!1):a}},ne=(s,t)=>{const a={...s,use_custom_smtp:!0};for(const n of H)String(a[n]??"").trim()===""&&t[n]!==void 0&&(a[n]=t[n]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=Q(a.smtp_use_tls,!0),a.smtp_use_ssl=Q(a.smtp_use_ssl,!1),a},oe=s=>{const t=re(s),a={to_email:String(t.to_email??"").trim(),use_custom_smtp:t.use_custom_smtp===!0};if(a.use_custom_smtp)for(const n of H)a[n]=t[n];return a},$={bark:{label:"Bark",icon:W,fields:[{key:"server_url",label:"Bark 服务器",placeholder:"https://api.day.app",required:!0},{key:"device_key",label:"Device Key",placeholder:"你的 Bark 设备 Key",required:!0},{key:"title",label:"标题(可选)",placeholder:"Ydisks闲鱼助手"},{key:"sound",label:"铃声(可选)",placeholder:"default"},{key:"group",label:"分组(可选)",placeholder:"xianyu"}],guide:{steps:["App Store 搜索并安装 Bark(免费)","打开 Bark App,首页会显示一条测试 URL,形如 https://api.day.app/<key>/这是测试推送内容","URL 路径里 <key> 那一段就是 Device Key,复制填入","服务器地址默认 https://api.day.app,自建服务端则填自建域名"],urlFormat:"https://api.day.app/<你的key>/测试内容",note:"不需要 secret,Device Key 本身就是唯一凭证。"}},dingtalk:{label:"钉钉机器人",icon:G,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=...",required:!0},{key:"secret",label:"加签密钥",placeholder:"SEC...",help:"安全设置勾选「加签」后生成,SEC 开头"}],guide:{steps:["钉钉进入一个群(可建单人群)→ 右上角 群设置","机器人 → 添加机器人 → 选择「自定义机器人」","安全设置勾选「加签」","完成页同时展示 Webhook 地址和 SEC 开头的 Secret,两个都复制","Webhook URL 填上面,Secret 填加签密钥"],urlFormat:"https://oapi.dingtalk.com/robot/send?access_token=XXX",note:"加签密钥可选,但强烈建议启用,否则机器人可能被滥用。"}},feishu:{label:"飞书机器人",icon:G,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",required:!0},{key:"secret",label:"签名校验密钥",placeholder:"sec-...",help:"安全设置选「签名校验」后生成"}],guide:{steps:["飞书进入目标群 → 右上角 更多 → 设置","群机器人 → 添加机器人 → 自定义机器人","安全设置选择「签名校验」,复制生成的秘钥","完成会给 Webhook 地址,复制","Webhook URL 填上面,秘钥填签名校验密钥"],urlFormat:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",note:"签名密钥可选,建议启用。频率限制:单机器人 100 次/分钟。"}},wechat:{label:"企业微信机器人",icon:G,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",required:!0}],guide:{steps:["企业微信进入一个内部群 → 右上角 … → 群设置","找到「群机器人」(新版可能叫「消息推送」)","添加 → 选择自定义机器人","完成给 Webhook 地址(含 ?key=),复制填入"],urlFormat:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX",note:"不需要 secret,URL 里的 key 就是唯一凭证,注意不要泄露。频率限制 20 条/分钟。"}},webhook:{label:"自定义 Webhook",icon:fe,fields:[{key:"webhook_url",label:"Webhook URL",placeholder:"https://your-server/notify",required:!0}],guide:{steps:["仅适用于自己有服务器的用户:在你自己的机器上起一个 HTTP 接口收 JSON","系统会 POST 这个 URL,Content-Type: application/json","请求体固定为右侧 JSON 格式,按需解析 message 字段"],urlFormat:'{"message":"告警正文","timestamp":"2026-07-05 12:00:00","source":"xianyu-auto-reply"}',note:"若用 Server酱 / PushPlus 等第三方推送服务,格式不兼容,需写中间脚本转发,或改用对应专用渠道。"}},telegram:{label:"Telegram",icon:se,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-10012Line truncated
@@ -1 +1 @@
import{j as e,b as U,r as a}from"./react-vendor-C_od1ZSF.js";import{i as ee,I as te,X as H,J as ae,R as W,N as le,O as X,m as K,E as re,v as ne,V as ie,F as ce,d as de,c as oe,r as xe}from"./icons-vendor-ThcsWkZG.js";import{D as me,h as ue,a as he,E as ge,F as pe,G as be,H as ye,I as je,J as fe}from"./index-CFJ5pUjO.js";import{f as Y}from"./dateTime-DDi7rqpW.js";const ve=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],Ne=s=>{const r=typeof s=="object"&&s!==null?s:{},m=Array.isArray(r.results)?r.results:[];return{total:Number(r.total||0),success_count:Number(r.success_count||0),failed_count:Number(r.failed_count||0),results:m.map(we)}},we=s=>{const r=typeof s=="object"&&s!==null?s:{};return{order_id:String(r.order_id||"unknown"),success:r.success===!0,message:String(r.message||"")}},_e=s=>(s==null?void 0:s.results.filter(ke))||[],ke=s=>!s.success,Ce=(s,r)=>s!==null&&!r,Se=s=>{if(!s)return"请选择订单文件";const r=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(r)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},q=(s,r)=>s===r,Ie=(s,r)=>s instanceof Error&&s.message?s.message:r,Ee=({filter:s,onFilterChange:r,accountFilter:m,onAccountFilterChange:p,accounts:j,accountName:x,searchText:b,onSearchChange:N})=>{const E=n=>r(n.currentTarget.dataset.status||"all"),S=n=>p(n.target.value),f=n=>N(n.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:ve.map(n=>e.jsx("button",{"data-status":n.key,onClick:E,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===n.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:n.label},n.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(ee,{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:m,onChange:S,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:"全部账号"}),j.map(n=>e.jsx("option",{value:n.id,children:x(n.id)},n.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(te,{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:b,onChange:f,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Oe=s=>{const r=x=>{var b;s.setImportFile(((b=x.target.files)==null?void 0:b[0])||null)},m=()=>s.closeImportModal(),p=()=>void s.handleImportOrders(),j=()=>void s.handleRetryImport();return s.showImportModal?U.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:m,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:r,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:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),s.importFile&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:s.importFile.name})]})}),s.importError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-100 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:s.importError}),e.jsx("button",{type:"button",onClick:j,disabled:s.importing||!s.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),s.importResult&&s.importResult.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",s.importResult.success_count," Line truncated
import{j as e,b as U,r as a}from"./react-vendor-C_od1ZSF.js";import{i as ee,I as te,X as H,J as ae,R as W,N as le,O as X,m as K,E as re,v as ne,V as ie,F as ce,d as de,c as oe,r as xe}from"./icons-vendor-ThcsWkZG.js";import{D as me,h as ue,a as he,E as ge,F as pe,G as be,H as ye,I as je,J as fe}from"./index-CsLZwESi.js";import{f as Y}from"./dateTime-DDi7rqpW.js";const ve=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],Ne=s=>{const r=typeof s=="object"&&s!==null?s:{},m=Array.isArray(r.results)?r.results:[];return{total:Number(r.total||0),success_count:Number(r.success_count||0),failed_count:Number(r.failed_count||0),results:m.map(we)}},we=s=>{const r=typeof s=="object"&&s!==null?s:{};return{order_id:String(r.order_id||"unknown"),success:r.success===!0,message:String(r.message||"")}},_e=s=>(s==null?void 0:s.results.filter(ke))||[],ke=s=>!s.success,Ce=(s,r)=>s!==null&&!r,Se=s=>{if(!s)return"请选择订单文件";const r=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(r)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},q=(s,r)=>s===r,Ie=(s,r)=>s instanceof Error&&s.message?s.message:r,Ee=({filter:s,onFilterChange:r,accountFilter:m,onAccountFilterChange:p,accounts:j,accountName:x,searchText:b,onSearchChange:N})=>{const E=n=>r(n.currentTarget.dataset.status||"all"),S=n=>p(n.target.value),f=n=>N(n.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:ve.map(n=>e.jsx("button",{"data-status":n.key,onClick:E,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===n.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:n.label},n.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(ee,{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:m,onChange:S,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:"全部账号"}),j.map(n=>e.jsx("option",{value:n.id,children:x(n.id)},n.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(te,{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:b,onChange:f,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Oe=s=>{const r=x=>{var b;s.setImportFile(((b=x.target.files)==null?void 0:b[0])||null)},m=()=>s.closeImportModal(),p=()=>void s.handleImportOrders(),j=()=>void s.handleRetryImport();return s.showImportModal?U.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:m,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(H,{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:r,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:"支持 .xlsx、.csv、.tsv、.json 格式"})]}),s.importFile&&e.jsx("div",{className:"p-3 bg-blue-50 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-sm font-medium text-blue-900",children:s.importFile.name})]})}),s.importError&&e.jsxs("div",{className:"rounded-xl bg-red-50 border border-red-100 p-3 text-sm text-red-700 flex items-center justify-between gap-3",children:[e.jsx("span",{children:s.importError}),e.jsx("button",{type:"button",onClick:j,disabled:s.importing||!s.importFile,className:"font-bold whitespace-nowrap",children:"重试"})]}),s.importResult&&s.importResult.failed_count>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3 text-sm font-bold text-amber-800",children:["导入完成:成功 ",s.importResult.success_count," Line truncated
@@ -0,0 +1 @@
import{j as e,r,b as Ie}from"./react-vendor-C_od1ZSF.js";import{k as Ve,ae as tt,af as pt,m as bt,R as Le,N as Ue,Z as Ke,x as gt,w as We,I as yt,a1 as ft,X as Ne,V as De,F as we,d as jt,c as _t,a6 as vt,ag as Nt,r as Ze,ah as wt}from"./icons-vendor-ThcsWkZG.js";import{h as kt,K as st,a as at,a7 as Xe,a8 as Ct,a9 as St,aa as Rt,ab as Ye,ac as At,ad as Mt,ae as Pt,af as $t,ag as It,ah as Lt,ai as Dt,aj as Ft,ak as Tt,Y as zt}from"./index-CsLZwESi.js";const Fe=(s,c)=>s.allowed_resolutions.includes(c),Et=(s,c)=>({runs:s.runs.filter(d=>!c||d.cookie_id===c),pending_tasks:s.pending_tasks.filter(d=>!c||d.cookie_id===c)}),qt=s=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[s]||"自动化异常",Vt=({runs:s,pendingTasks:c,onResolveRun:d,onResolveDeferredTask:y})=>e.jsxs("section",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ve,{className:"w-5 h-5 text-red-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-red-900",children:"需要人工处理的自动化任务"}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:"请先在闲鱼聊天、订单或商品列表中核对真实结果,再选择继续或重试。"})]})]}),e.jsxs("div",{className:"space-y-3",children:[s.map(o=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",o.cookie_id," · 订单 ",o.order_id||"-"," · 已记录发送 ",o.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:qt(o.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:o.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[Fe(o,"continue")&&e.jsx("button",{onClick:(()=>d(o.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),Fe(o,"retry")&&e.jsx("button",{onClick:(()=>d(o.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),Fe(o,"cancel")&&e.jsx("button",{onClick:(()=>d(o.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${o.id}`)),c.map(o=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",o.cookie_id," · 延迟任务重试已达 ",o.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:o.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:(()=>y(o.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:(()=>y(o.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${o.id}`))]})]}),Te=()=>({submitting:!1,result:"idle"}),ze=s=>s.submitting?s:{submitting:!0,result:"idle"},Ee=(s,c)=>({submitting:!1,result:c?"success":"failure"}),Qe=s=>s+1,qe=(s,c,d,y)=>s===c&&d===y,Ot=s=>{const[c,d]=r.useState([]),[y,o]=r.useState({runs:[],pending_tasks:[]}),[U,F]=r.useState([]),[K,C]=r.useState({}),[se,T]=r.useState([]),[V,v]=r.useState([]),[O,P]=r.useState([]),[j,W]=r.useState(!1),z=r.useRef(0),ae=r.useRef(0),[Z,B]=r.useState(0),[le,X]=r.useState(0),[E,Y]=r.useState({}),G=r.useCallback(async()=>{const A=Promise.all([kt(),st(),at(),Xe()]),[b,f,$,Q]=await A;T(b),v(f),P($),C(Q),s.setSelectedAccountId(re=>{var L;return re||((L=b[0])==null?void 0:L.id)||""})},[s.setSelectedAccountId]),l=r.useCallback(async()=>{var Q;const A=Qe(z.current);z.current=A;const b=Ct().catch(re=>(console.warn("加载自动化异常列表失败,不阻断规则展示",re),null)),f=await St({cookieId:s.selectedAccountId||void 0,triggerType:s.automationTriggerFilter,enabled:s.automationStatusFilter==="all"?void 0:s.automationStatusFilter==="enabled",search:s.debouncedAutomationSearch,page:s.automationPage,pageSize:s.automationPageSize});if(!qe(A,z.current,s.selectedAccountId,s.selectedAccountId))return;d(f.data),B(f.total),X(f.total_pages),Y(f.trigger_counts||{}),f.page!==s.automationPage&&((Q=s.onAutomationPageChange)==null||Q.call(s,f.page));const $=await b;qe(A,z.current,s.selectedAccountId,s.selectedAccountId)&&$&&o($)},[s.automationPage,s.automationPageSize,s.automationStatusFilter,s.automationTriggerFilter,s.debouncedAutomationSearch,s.onAutomationPageChanLine truncated
@@ -1 +0,0 @@
import{j as e,r as i,b as ke}from"./react-vendor-C_od1ZSF.js";import{h as At,K as at,a as lt,a7 as We,a8 as It,a9 as Mt,aa as Pt,Y as $t,ab as Lt,ac as Ft,ad as Tt,ae as Ze,af as Dt,ag as zt,ah as Et,ai as qt,aj as Ot,ak as Bt}from"./index-CFJ5pUjO.js";import{k as $e,ae as rt,af as Vt,m as Gt,R as Ce,N as Xe,Z as Ye,x as Jt,w as Qe,I as Ut,a1 as Kt,X as ue,V as Se,F as he,d as Wt,c as Zt,a6 as Xt,ag as Yt,r as He,ah as Qt}from"./icons-vendor-ThcsWkZG.js";const Re=(a,o)=>a.allowed_resolutions.includes(o),Ht=(a,o)=>({runs:a.runs.filter(d=>!o||d.cookie_id===o),pending_tasks:a.pending_tasks.filter(d=>!o||d.cookie_id===o)}),es=a=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[a]||"自动化异常",ts=({runs:a,pendingTasks:o,onResolveRun:d,onResolveDeferredTask:y})=>e.jsxs("section",{className:"rounded-2xl border border-red-200 bg-red-50 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx($e,{className:"w-5 h-5 text-red-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-red-900",children:"需要人工处理的自动化任务"}),e.jsx("p",{className:"text-sm text-red-700 mt-1",children:"请先在闲鱼聊天、订单或商品列表中核对真实结果,再选择继续或重试。"})]})]}),e.jsxs("div",{className:"space-y-3",children:[a.map(n=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",n.cookie_id," · 订单 ",n.order_id||"-"," · 已记录发送 ",n.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:es(n.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:n.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[Re(n,"continue")&&e.jsx("button",{onClick:(()=>d(n.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),Re(n,"retry")&&e.jsx("button",{onClick:(()=>d(n.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),Re(n,"cancel")&&e.jsx("button",{onClick:(()=>d(n.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${n.id}`)),o.map(n=>e.jsxs("div",{className:"rounded-xl border border-red-100 bg-white p-4 flex flex-col lg:flex-row lg:items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold text-gray-900",children:["账号 ",n.cookie_id," · 延迟任务重试已达 ",n.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:n.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:(()=>y(n.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:(()=>y(n.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${n.id}`))]})]}),Ae=()=>({submitting:!1,result:"idle"}),Ie=a=>a.submitting?a:{submitting:!0,result:"idle"},Me=(a,o)=>({submitting:!1,result:o?"success":"failure"}),et=a=>a+1,Pe=(a,o,d,y)=>a===o&&d===y,ss=a=>{const[o,d]=i.useState([]),[y,n]=i.useState({runs:[],pending_tasks:[]}),[Z,L]=i.useState([]),[ae,le]=i.useState({}),[re,X]=i.useState([]),[ne,q]=i.useState([]),[ie,v]=i.useState([]),[f,O]=i.useState(!1),B=i.useRef(0),Y=i.useRef(0),[oe,de]=i.useState(0),[ce,ge]=i.useState(0),[I,ye]=i.useState({}),N=i.useCallback(async()=>{const k=Promise.all([At(),at(),lt(),We()]),[C,j,M,S]=await k;X(C),q(j),v(M),le(S),a.setSelectedAccountId(G=>{var Q;return G||((Q=C[0])==null?void 0:Q.id)||""})},[a.setSelectedAccountId]),w=i.useCallback(async()=>{var S;const k=et(B.current);B.current=k;const C=It().catch(G=>(console.warn("加载自动化异常列表失败,不阻断规则展示",G),null)),j=await Mt({cookieId:a.selectedAccountId||void 0,triggerType:a.automationTriggerFilter,enabled:a.automationStatusFilter==="all"?void 0:a.automationStatusFilter==="enabled",search:a.debouncedAutomationSearch,page:a.automationPage,pageSize:a.automationPageSize});if(!Pe(k,B.current,a.selectedAccountId,a.selectedAccountId))return;d(j.data),de(j.total),ge(j.total_pages),ye(j.trigger_counts||{}),j.page!==a.automationPage&&((S=a.onAutomationPageChange)==null||S.call(a,j.page));const M=await C;Pe(k,B.current,a.selectedAccountId,a.selectedAccountId)&&M&&n(M)},[a.automationPage,a.automationPageSize,a.automationStatusFilter,a.automationTriggerFilter,a.debouncedAutomationSearch,a.onAutomaLine truncated
@@ -1 +1 @@
import{r as a,j as e}from"./react-vendor-C_od1ZSF.js";import{a2 as ce,a3 as ie,a4 as de,a5 as xe,a6 as ue}from"./index-CFJ5pUjO.js";import{b as pe,R as se,aa as me,p as he,u as q,v as D,ab as ge,s as ye,h as te,ac as ae,ad as be,r as fe}from"./icons-vendor-ThcsWkZG.js";const le="https://dashscope.aliyuncs.com/compatible-mode/v1",we=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],je=new Set(["ai_api_key_configured","smtp_password_configured","qq_reply_secret_key_configured","captcha.remote_secret_key_configured","smtp_server","smtp_port","smtp_user","smtp_password","smtp_from","smtp_from_name","smtp_from_address","registration_enabled","show_default_login_info","login_captcha_enabled","item_sync_enabled","item_sync_interval","item_sync_max_pages","default_reply"]),ve=s=>Object.fromEntries(Object.entries(s).filter(([c,m])=>!je.has(c)&&m!==void 0&&m!==null)),Ne=s=>s.new_username.trim().length<3?"用户名至少需要 3 个字符":s.current_password?s.new_password&&s.new_password.length<8?"新密码至少需要 8 个字符":s.new_password!==s.confirm_password?"两次输入的新密码不一致":"":"请输入当前密码确认身份",g=(s,c,m)=>s===c&&!m.aborted,O=s=>s instanceof Error&&s.message==="请求已取消",K=(s,c)=>s instanceof Error?s.message:c,_e=(s="")=>({new_username:s,current_password:"",new_password:"",confirm_password:""}),T=(s,c)=>({type:s,text:c}),Se=()=>{const[s,c]=a.useState(null),[m,k]=a.useState(!1),[I,x]=a.useState(""),[N,E]=a.useState(!1),[P,_]=a.useState(""),[S,b]=a.useState([]),[f,A]=a.useState(!1),[M,i]=a.useState(""),[$,w]=a.useState(!1),[U,L]=a.useState(!1),[z,d]=a.useState(!1),[y,F]=a.useState(!1),[G,J]=a.useState(!1),[V,j]=a.useState(!1),[R,h]=a.useState(null),[t,X]=a.useState(()=>_e()),[re,W]=a.useState("idle"),Z=a.useRef(null),ee=a.useRef(null),u=a.useRef(0),Y=a.useRef(null);ee.current=s;const C=a.useCallback(()=>{var n;(n=Y.current)==null||n.abort();const r=new AbortController;return Y.current=r,u.current+=1,{controller:r,sequence:u.current}},[]),B=a.useCallback(async(r,n=!1,l)=>{const o=r||ee.current,p=(o==null?void 0:o.ai_api_url)||(o==null?void 0:o.ai_base_url)||le;A(!0),i("");try{const v=await ce(p,(o==null?void 0:o.ai_api_key)||"",{signal:l});if(l!=null&&l.aborted)return;b(v),w(n&&v.length>0),!(o!=null&&o.ai_model)&&v.length>0&&c(Q=>Q&&{...Q,ai_model:v[0]})}catch(v){if(l!=null&&l.aborted||O(v))return;b([]),w(!1),i(K(v,"读取模型失败"))}finally{l!=null&&l.aborted||A(!1)}},[]),H=a.useCallback(()=>{const{controller:r,sequence:n}=C();k(!0),W("loading"),x(""),Promise.all([ie({signal:r.signal}),de({signal:r.signal})]).then(([l,o])=>{g(u.current,n,r.signal)&&(c(l),o.username&&X(p=>({...p,new_username:o.username||""})),B(l,!1,r.signal),W("success"))}).catch(l=>{!g(u.current,n,r.signal)||O(l)||(c(null),x(K(l,"加载配置失败")),W("error"))}).finally(()=>{g(u.current,n,r.signal)&&k(!1)})},[C,B]);a.useEffect(()=>(H(),(()=>{var r;return(r=Y.current)==null?void 0:r.abort()})),[H]),a.useEffect(()=>{const r=n=>{var l;(l=Z.current)!=null&&l.contains(n.target)||w(!1)};return document.addEventListener("mousedown",r),(()=>document.removeEventListener("mousedown",r))},[]);const ne=a.useCallback(async()=>{if(!s||N)return;const{controller:r,sequence:n}=C();E(!0),_("");try{if(await xe(ve(s),{signal:r.signal}),!g(u.current,n,r.signal))return;window.alert("系统配置已保存")}catch(l){if(!g(u.current,n,r.signal)||O(l))return;_(K(l,"保存配置失败"))}finally{g(u.current,n,r.signal)&&E(!1)}},[C,N,s]),oe=a.useCallback(async r=>{r.preventDefault(),h(null);const n=Ne(t);if(n){h(T("error",n));return}const{controller:l,sequence:o}=C();j(!0);try{const p=await ue({current_password:t.current_password,new_username:t.new_username.trim(),new_password:t.new_password||void 0},{signal:l.signal});if(!g(u.current,o,l.signal))return;if(!p.success){h(T("error",p.message||"登录凭据更新失败"));return}h(T("success",p.message||"登录凭据已更新")),window.setTimeout(()=>window.location.reload(),1400)}catch(p){if(!g(u.current,o,l.signal)||O(p))return;h(T("error",K(p,"登录凭据更新失败")))}finally{g(u.current,o,l.signal)&&j(!1)}},[C,t]);return{settings:s,loading:m,loadError:I,saving:N,saveError:P,aiModels:S,modelsLoading:f,modelError:M,modelDropdownOpen:$,showApiKey:U,showCaptchaSecret:z,showCurrentPassword:y,showNewPassword:G,credentialsSaving:V,credentialsMessage:R,credentials:t,requestStatus:re,modelPickerRef:Z,loadSettings:H,loadAIModels:((r,n)=>void B(r,n)),handleSave:ne,handleCredentialsSave:oe,setSettings:c,setModelDropdownOpen:w,setShowApiKey:L,setShowCaptchaSecret:d,setShowCurrentPassword:F,setShowNewPassword:J,setCredentials:X,setCredentialsMessage:h}},Ae=()=>{const{settings:s,loading:c,loadError:m,saving:k,saveError:I,aiModels:x,modelsLoading:N,modelError:E,modelDropdownOpen:P,showApiKey:_,showCaptchaSecret:S,showCurrentPassword:b,showNewPassword:f,credentialsSaving:A,credentialsMessage:M,credentials:i,modelLine truncated
import{r as a,j as e}from"./react-vendor-C_od1ZSF.js";import{a2 as ce,a3 as ie,a4 as de,a5 as xe,a6 as ue}from"./index-CsLZwESi.js";import{b as pe,R as se,aa as me,p as he,u as q,v as D,ab as ge,s as ye,h as te,ac as ae,ad as be,r as fe}from"./icons-vendor-ThcsWkZG.js";const le="https://dashscope.aliyuncs.com/compatible-mode/v1",we=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],je=new Set(["ai_api_key_configured","smtp_password_configured","qq_reply_secret_key_configured","captcha.remote_secret_key_configured","smtp_server","smtp_port","smtp_user","smtp_password","smtp_from","smtp_from_name","smtp_from_address","registration_enabled","show_default_login_info","login_captcha_enabled","item_sync_enabled","item_sync_interval","item_sync_max_pages","default_reply"]),ve=s=>Object.fromEntries(Object.entries(s).filter(([c,m])=>!je.has(c)&&m!==void 0&&m!==null)),Ne=s=>s.new_username.trim().length<3?"用户名至少需要 3 个字符":s.current_password?s.new_password&&s.new_password.length<8?"新密码至少需要 8 个字符":s.new_password!==s.confirm_password?"两次输入的新密码不一致":"":"请输入当前密码确认身份",g=(s,c,m)=>s===c&&!m.aborted,O=s=>s instanceof Error&&s.message==="请求已取消",K=(s,c)=>s instanceof Error?s.message:c,_e=(s="")=>({new_username:s,current_password:"",new_password:"",confirm_password:""}),T=(s,c)=>({type:s,text:c}),Se=()=>{const[s,c]=a.useState(null),[m,k]=a.useState(!1),[I,x]=a.useState(""),[N,E]=a.useState(!1),[P,_]=a.useState(""),[S,b]=a.useState([]),[f,A]=a.useState(!1),[M,i]=a.useState(""),[$,w]=a.useState(!1),[U,L]=a.useState(!1),[z,d]=a.useState(!1),[y,F]=a.useState(!1),[G,J]=a.useState(!1),[V,j]=a.useState(!1),[R,h]=a.useState(null),[t,X]=a.useState(()=>_e()),[re,W]=a.useState("idle"),Z=a.useRef(null),ee=a.useRef(null),u=a.useRef(0),Y=a.useRef(null);ee.current=s;const C=a.useCallback(()=>{var n;(n=Y.current)==null||n.abort();const r=new AbortController;return Y.current=r,u.current+=1,{controller:r,sequence:u.current}},[]),B=a.useCallback(async(r,n=!1,l)=>{const o=r||ee.current,p=(o==null?void 0:o.ai_api_url)||(o==null?void 0:o.ai_base_url)||le;A(!0),i("");try{const v=await ce(p,(o==null?void 0:o.ai_api_key)||"",{signal:l});if(l!=null&&l.aborted)return;b(v),w(n&&v.length>0),!(o!=null&&o.ai_model)&&v.length>0&&c(Q=>Q&&{...Q,ai_model:v[0]})}catch(v){if(l!=null&&l.aborted||O(v))return;b([]),w(!1),i(K(v,"读取模型失败"))}finally{l!=null&&l.aborted||A(!1)}},[]),H=a.useCallback(()=>{const{controller:r,sequence:n}=C();k(!0),W("loading"),x(""),Promise.all([ie({signal:r.signal}),de({signal:r.signal})]).then(([l,o])=>{g(u.current,n,r.signal)&&(c(l),o.username&&X(p=>({...p,new_username:o.username||""})),B(l,!1,r.signal),W("success"))}).catch(l=>{!g(u.current,n,r.signal)||O(l)||(c(null),x(K(l,"加载配置失败")),W("error"))}).finally(()=>{g(u.current,n,r.signal)&&k(!1)})},[C,B]);a.useEffect(()=>(H(),(()=>{var r;return(r=Y.current)==null?void 0:r.abort()})),[H]),a.useEffect(()=>{const r=n=>{var l;(l=Z.current)!=null&&l.contains(n.target)||w(!1)};return document.addEventListener("mousedown",r),(()=>document.removeEventListener("mousedown",r))},[]);const ne=a.useCallback(async()=>{if(!s||N)return;const{controller:r,sequence:n}=C();E(!0),_("");try{if(await xe(ve(s),{signal:r.signal}),!g(u.current,n,r.signal))return;window.alert("系统配置已保存")}catch(l){if(!g(u.current,n,r.signal)||O(l))return;_(K(l,"保存配置失败"))}finally{g(u.current,n,r.signal)&&E(!1)}},[C,N,s]),oe=a.useCallback(async r=>{r.preventDefault(),h(null);const n=Ne(t);if(n){h(T("error",n));return}const{controller:l,sequence:o}=C();j(!0);try{const p=await ue({current_password:t.current_password,new_username:t.new_username.trim(),new_password:t.new_password||void 0},{signal:l.signal});if(!g(u.current,o,l.signal))return;if(!p.success){h(T("error",p.message||"登录凭据更新失败"));return}h(T("success",p.message||"登录凭据已更新")),window.setTimeout(()=>window.location.reload(),1400)}catch(p){if(!g(u.current,o,l.signal)||O(p))return;h(T("error",K(p,"登录凭据更新失败")))}finally{g(u.current,o,l.signal)&&j(!1)}},[C,t]);return{settings:s,loading:m,loadError:I,saving:N,saveError:P,aiModels:S,modelsLoading:f,modelError:M,modelDropdownOpen:$,showApiKey:U,showCaptchaSecret:z,showCurrentPassword:y,showNewPassword:G,credentialsSaving:V,credentialsMessage:R,credentials:t,requestStatus:re,modelPickerRef:Z,loadSettings:H,loadAIModels:((r,n)=>void B(r,n)),handleSave:ne,handleCredentialsSave:oe,setSettings:c,setModelDropdownOpen:w,setShowApiKey:L,setShowCaptchaSecret:d,setShowCurrentPassword:F,setShowNewPassword:J,setCredentials:X,setCredentialsMessage:h}},Ae=()=>{const{settings:s,loading:c,loadError:m,saving:k,saveError:I,aiModels:x,modelsLoading:N,modelError:E,modelDropdownOpen:P,showApiKey:_,showCaptchaSecret:S,showCurrentPassword:b,showNewPassword:f,credentialsSaving:A,credentialsMessage:M,credentials:i,modelLine truncated
@@ -1,2 +1,2 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-COpr9cLo.js","assets/react-vendor-C_od1ZSF.js","assets/dateTime-DDi7rqpW.js","assets/icons-vendor-ThcsWkZG.js","assets/charts-vendor-BxxJOyEX.js","assets/vendor-D-Edl3pr.js","assets/AccountList-Bqs514En.js","assets/OrderList-vw6Kdzf7.js","assets/CardList-CRgXJn6O.js","assets/ItemList-DE9qcEo5.js","assets/Settings-BjYjZFI9.js","assets/Rules-wDFwn1GF.js","assets/Notifications-BlIacKXE.js","assets/Chat-VbA-SOcX.js"])))=>i.map(i=>d[i]);
import{j as n,r as p,c as ee,d as xe}from"./react-vendor-C_od1ZSF.js";import{L as we,U as je,M as Le,C as Ne,B as Se,S as ke,Z as Ce,a as Ae,b as Ee,G as Z,c as $e,d as De,e as Ie,f as D,g as H,h as I,A as G,i as Oe}from"./icons-vendor-ThcsWkZG.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();const te="ydisks.sidebar.v1",Te=()=>{try{return window.localStorage.getItem(te)==="collapsed"}catch{return!1}},Pe=e=>{try{window.localStorage.setItem(te,e?"collapsed":"expanded")}catch{}},Re=({className:e="w-full h-full text-white"})=>n.jsx("svg",{className:e,viewBox:"0 0 256 256","aria-hidden":"true",children:n.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:n.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"})})}),R=({sizeClass:e="w-12 h-12",logoClassName:t="w-full h-full text-white"})=>n.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[n.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),n.jsxs("div",{className:`relative ${e} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[n.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[n.jsx("defs",{children:n.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[n.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),n.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),n.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 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z",fill:"url(#login-squircle-gradient)"})]}),n.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:n.jsx(Re,{className:t})})]})]}),ze="modulepreload",qe=function(e){returLine truncated
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-Ds-nEvf-.js","assets/react-vendor-C_od1ZSF.js","assets/dateTime-DDi7rqpW.js","assets/icons-vendor-ThcsWkZG.js","assets/charts-vendor-BxxJOyEX.js","assets/vendor-D-Edl3pr.js","assets/AccountList-HAZWMDQe.js","assets/OrderList-DpM_ZNlI.js","assets/CardList-DuMEp-gq.js","assets/ItemList-BfR3GASL.js","assets/Settings-D-qaPnxf.js","assets/Rules-BqImksVG.js","assets/Notifications-Cu3hjXgW.js","assets/Chat-B1v5dyJA.js"])))=>i.map(i=>d[i]);
import{j as n,r as p,c as ee,d as xe}from"./react-vendor-C_od1ZSF.js";import{L as we,U as je,M as Le,C as Ne,B as Se,S as ke,Z as Ce,a as Ae,b as Ee,G as Z,c as $e,d as De,e as Ie,f as D,g as H,h as I,A as G,i as Oe}from"./icons-vendor-ThcsWkZG.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();const te="ydisks.sidebar.v1",Te=()=>{try{return window.localStorage.getItem(te)==="collapsed"}catch{return!1}},Pe=e=>{try{window.localStorage.setItem(te,e?"collapsed":"expanded")}catch{}},Re=({className:e="w-full h-full text-white"})=>n.jsx("svg",{className:e,viewBox:"0 0 256 256","aria-hidden":"true",children:n.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:n.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"})})}),R=({sizeClass:e="w-12 h-12",logoClassName:t="w-full h-full text-white"})=>n.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[n.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),n.jsxs("div",{className:`relative ${e} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[n.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[n.jsx("defs",{children:n.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[n.jsx("stop",{offset:"0%",stopColor:"rgb(var(--color-brand))"}),n.jsx("stop",{offset:"100%",stopColor:"rgb(var(--color-brand-light))"})]})}),n.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 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z",fill:"url(#login-squircle-gradient)"})]}),n.jsx("div",{className:"relative z-10 flex items-center justify-center w-full h-full",children:n.jsx(Re,{className:t})})]})]}),ze="modulepreload",qe=function(e){returLine 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-CFJ5pUjO.js"></script>
<script type="module" crossorigin src="/static/assets/index-CsLZwESi.js"></script>
<link rel="modulepreload" crossorigin href="/static/assets/react-vendor-C_od1ZSF.js">
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-ThcsWkZG.js">
<link rel="stylesheet" crossorigin href="/static/assets/index-1VXvcBKv.css">