合并:接入拍下未付款自动改价规则
This commit is contained in:
commit
44f0b5c559
39 files changed
+1433
-161
No files matched your search
@@ -146,6 +146,7 @@ export const updateShippingRule = async (rule: Partial<ShippingRule>): Promise<O
|
||||
const triggerType = rule.trigger_type || 'order_paid';
|
||||
// triggerName 触发名称,用于当前 API 处理流程。
|
||||
const triggerName: Record<string, string> = {
|
||||
order_created: '拍下未付款自动改价',
|
||||
order_paid: '付款后自动发货',
|
||||
buyer_reviewed: '评价后发送赠品',
|
||||
review_missing_timeout: '超时未评价求评价',
|
||||
|
||||
@@ -158,9 +158,9 @@ export interface Item {
|
||||
}
|
||||
|
||||
/** 由当前 feature adapter 归一后的 AutomationTriggerType UI 模型;不直接暴露 HTTP DTO。 */
|
||||
export type AutomationTriggerType = 'order_paid' | 'buyer_reviewed' | 'review_missing_timeout';
|
||||
export type AutomationTriggerType = 'order_created' | 'order_paid' | 'buyer_reviewed' | 'review_missing_timeout';
|
||||
/** 由当前 feature adapter 归一后的 AutomationActionType UI 模型;不直接暴露 HTTP DTO。 */
|
||||
export type AutomationActionType = 'confirm_shipment' | 'send_card' | 'send_text';
|
||||
export type AutomationActionType = 'confirm_shipment' | 'send_card' | 'send_text' | 'adjust_price';
|
||||
|
||||
// Rules
|
||||
/** 由当前 feature adapter 归一后的 ShippingRule UI 模型;不直接暴露 HTTP DTO。 */
|
||||
|
||||
@@ -4,6 +4,7 @@ Bot,
|
||||
CheckCircle2,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
CircleDollarSign,
|
||||
Clock3,
|
||||
Edit,
|
||||
Layers3,
|
||||
@@ -25,7 +26,7 @@ import { useRulesData } from '../hooks';
|
||||
import { filterAutomationIssues } from '../issueState';
|
||||
import { useRuleActions } from '../ruleActions';
|
||||
import type { AutomationTriggerType,RulesProps,RulesTab } from '../types';
|
||||
import { accentClasses,accountLabel,actionSummary,buildReviewConfig,cardActionsForTrigger,statusPill,triggerMeta,triggerOrder } from '../utils';
|
||||
import { accentClasses,accountLabel,actionSummary,adjustPriceTarget,buildReviewConfig,cardActionsForTrigger,statusPill,triggerMeta,triggerOrder } from '../utils';
|
||||
|
||||
// Rules 是规则 feature 在旧页面目录下保留的兼容入口组件。
|
||||
const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHandled }) => {
|
||||
@@ -105,7 +106,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
|
||||
editingAutomationRule, setEditingAutomationRule,
|
||||
editingReplyRule, setEditingReplyRule, defaultForm, setDefaultForm, selectedRuleItem, isMultiSpecRule, currentTrigger,
|
||||
currentMeta, reviewConfig, displayVariants, openAutomationRule, openNewAutomationRule, handleTriggerChange,
|
||||
handleAutomationItemChange, updateVariant, appendDeliveryContent, handleSaveAutomationRule, handleDeleteAutomation,
|
||||
handleAutomationItemChange, updateVariant, updateAdjustPriceTarget, updateAdjustPriceNotifyText, appendDeliveryContent, handleSaveAutomationRule, handleDeleteAutomation,
|
||||
handleToggleAutomation, handleResolveRunIssue, handleResolveDeferredIssue, handleAddReplyRule, handleSaveReplyRule,
|
||||
handleDeleteReply, openDefaultReplyModal, handleSaveDefaultReply, handleDeleteDefaultReply, handleClearDefaultReplyRecords,
|
||||
} = ruleActions;
|
||||
@@ -722,7 +723,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{selectedRuleItem && currentTrigger !== 'review_missing_timeout' && (
|
||||
{selectedRuleItem && currentTrigger !== 'review_missing_timeout' && currentTrigger !== 'order_created' && (
|
||||
<div className="mt-4 rounded-2xl bg-gray-50 border border-gray-100 p-4">
|
||||
<div className="flex flex-wrap items-center gap-2 mb-2">
|
||||
<span className="px-3 py-1.5 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold">{selectedRuleItem.item_title || selectedRuleItem.item_id}</span>
|
||||
@@ -738,7 +739,43 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
|
||||
)}
|
||||
</section>
|
||||
|
||||
{currentTrigger !== 'review_missing_timeout' ? (
|
||||
{currentTrigger === 'order_created' ? (
|
||||
<section className="bg-white rounded-3xl border border-gray-100 p-5">
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<CircleDollarSign className="w-5 h-5 text-violet-600" />
|
||||
<h4 className="font-black text-gray-900">改价设置</h4>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-bold text-gray-700 mb-2">目标价格(元)</label>
|
||||
<input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
value={adjustPriceTarget(editingAutomationRule.actions)}
|
||||
onChange={/* 当前回调处理用户交互或异步状态变化。 */ event => updateAdjustPriceTarget(event.target.value)}
|
||||
placeholder="例如:9.9"
|
||||
className="w-full ios-input px-4 py-3 rounded-xl"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-2">买家拍下未付款后,系统会把该笔订单价格修改为此金额(0.01 - 1000000 元,最多两位小数)。</p>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-bold text-gray-700 mb-2">改价后提醒买家(可选)</label>
|
||||
<textarea
|
||||
value={editingAutomationRule.actions?.find(/* 当前回调处理集合中的单个元素。 */ action => action.action_type === 'send_text')?.message_template || ''}
|
||||
onChange={/* 当前回调处理用户交互或异步状态变化。 */ event => updateAdjustPriceNotifyText(event.target.value)}
|
||||
placeholder="例如:已为您改好价格,请尽快支付哦~"
|
||||
className="w-full ios-input px-4 py-3 rounded-xl h-24 resize-none"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-2">留空则只改价不发送消息。</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 rounded-2xl bg-violet-50 border border-violet-100 p-4">
|
||||
<p className="text-xs leading-5 text-violet-700">
|
||||
改价仅对买家尚未付款的订单生效;订单已付款、已关闭或平台限制改价时任务会记录失败原因。建议配合商品说明引导买家「先拍下再等改价」。
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
) : currentTrigger !== 'review_missing_timeout' ? (
|
||||
<section className="bg-white rounded-3xl border border-gray-100 p-5">
|
||||
<div className="flex items-start justify-between gap-4 mb-4">
|
||||
<div>
|
||||
|
||||
@@ -110,6 +110,44 @@ describe('useRuleActions', /* 当前回调验证规则页面动作协调器的
|
||||
hook.unmount();
|
||||
});
|
||||
|
||||
test('拍下改价规则校验目标价格并剔除空提醒动作', /* 当前回调验证拍下改价草稿与保存边界。 */ async () => {
|
||||
// hook 是规则动作 Hook 的真实 React 状态实例。
|
||||
const hook = renderHook(() => useRuleActionsHarness());
|
||||
act(/* 当前回调打开拍下改价规则弹窗。 */ () => hook.result.current.openNewAutomationRule('order_created'));
|
||||
expect(hook.result.current.editingAutomationRule?.variants).toEqual([]);
|
||||
|
||||
// 目标价格为空时保存被拒绝且不触达接口。
|
||||
await act(/* 当前回调执行空价格保存。 */ async () => hook.result.current.handleSaveAutomationRule());
|
||||
expect(updateShippingMock).not.toHaveBeenCalled();
|
||||
|
||||
act(/* 当前回调写入合法目标价格。 */ () => hook.result.current.updateAdjustPriceTarget('9.9'));
|
||||
act(/* 当前回调写入空白提醒文案。 */ () => hook.result.current.updateAdjustPriceNotifyText(' '));
|
||||
await act(/* 当前回调执行拍下改价保存。 */ async () => hook.result.current.handleSaveAutomationRule());
|
||||
expect(updateShippingMock).toHaveBeenCalledWith(expect.objectContaining({
|
||||
trigger_type: 'order_created',
|
||||
variants: [],
|
||||
actions: [expect.objectContaining({ action_type: 'adjust_price', config_json: '{"target_price":"9.9"}' })],
|
||||
}));
|
||||
hook.unmount();
|
||||
});
|
||||
|
||||
test('拍下改价规则保存带文案的可选提醒动作', /* 当前回调验证改价提醒文案的保存。 */ async () => {
|
||||
// hook 是规则动作 Hook 的真实 React 状态实例。
|
||||
const hook = renderHook(() => useRuleActionsHarness());
|
||||
act(/* 当前回调打开拍下改价规则弹窗。 */ () => hook.result.current.openNewAutomationRule('order_created'));
|
||||
act(/* 当前回调写入合法目标价格。 */ () => hook.result.current.updateAdjustPriceTarget('12'));
|
||||
act(/* 当前回调写入买家提醒文案。 */ () => hook.result.current.updateAdjustPriceNotifyText('已改价,请支付'));
|
||||
await act(/* 当前回调执行拍下改价保存。 */ async () => hook.result.current.handleSaveAutomationRule());
|
||||
expect(updateShippingMock).toHaveBeenCalledWith(expect.objectContaining({
|
||||
trigger_type: 'order_created',
|
||||
actions: [
|
||||
expect.objectContaining({ action_type: 'adjust_price', config_json: '{"target_price":"12"}' }),
|
||||
expect.objectContaining({ action_type: 'send_text', message_template: '已改价,请支付' }),
|
||||
],
|
||||
}));
|
||||
hook.unmount();
|
||||
});
|
||||
|
||||
test('关键词和默认回复动作分别读取、保存并刷新', /* 当前回调验证两个回复页签的动作边界。 */ async () => {
|
||||
// hook 是规则动作 Hook 的真实 React 状态实例。
|
||||
const hook = renderHook(() => useRuleActionsHarness());
|
||||
|
||||
@@ -16,7 +16,7 @@ updateShippingRule,
|
||||
} from './api';
|
||||
import { finishRuleSubmission,idleRuleSubmitState,startRuleSubmission,type RuleSubmitState } from './interactionState';
|
||||
import type { AutomationTriggerType,Card,DefaultReplyForm,Item,ReplyRule,RulesProps,RulesTab,ShippingRule,ShippingVariant } from './types';
|
||||
import { boolFlag,buildReviewConfig,cardActionsForTrigger,defaultRuleName,emptyVariant,parseJSONObject,shouldReplaceGeneratedName,triggerMeta } from './utils';
|
||||
import { adjustPriceTarget,boolFlag,buildAdjustPriceConfig,buildReviewConfig,cardActionsForTrigger,defaultRuleName,emptyVariant,isValidAdjustPrice,parseJSONObject,shouldReplaceGeneratedName,triggerMeta } from './utils';
|
||||
|
||||
// RuleActionsOptions 描述规则动作协调器依赖的页面数据、刷新函数和外部联动目标。
|
||||
export interface RuleActionsOptions {
|
||||
@@ -106,6 +106,10 @@ export interface RuleActionsState {
|
||||
handleAutomationItemChange: (itemID: string) => void;
|
||||
// updateVariant 更新指定发货规格的字段。
|
||||
updateVariant: (index: number, patch: Partial<ShippingVariant>) => void;
|
||||
// updateAdjustPriceTarget 更新拍下改价草稿的目标价格。
|
||||
updateAdjustPriceTarget: (targetPrice: string) => void;
|
||||
// updateAdjustPriceNotifyText 更新拍下改价草稿的可选买家提醒文案。
|
||||
updateAdjustPriceNotifyText: (text: string) => void;
|
||||
// appendDeliveryContent 追加一行发货规格。
|
||||
appendDeliveryContent: () => void;
|
||||
// handleSaveAutomationRule 保存当前自动化规则。
|
||||
@@ -198,7 +202,7 @@ export const useRuleActions = ({
|
||||
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()],
|
||||
variants: trigger === 'review_missing_timeout' || trigger === 'order_created' ? [] : [emptyVariant()],
|
||||
};
|
||||
}, [items, selectedAccountId]);
|
||||
|
||||
@@ -211,7 +215,7 @@ export const useRuleActions = ({
|
||||
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()]),
|
||||
variants: rule.variants?.length ? rule.variants.map(/* 当前回调复制发货规格。 */ variant => ({ ...variant })) : (trigger === 'review_missing_timeout' || trigger === 'order_created' ? [] : [emptyVariant()]),
|
||||
});
|
||||
setShowAutomationModal(true);
|
||||
}, []);
|
||||
@@ -288,7 +292,7 @@ export const useRuleActions = ({
|
||||
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 }]),
|
||||
variants: trigger === 'review_missing_timeout' || trigger === 'order_created' ? [] : (editingAutomationRule.variants?.length ? editingAutomationRule.variants : [{ ...emptyVariant(), card_id: currentCardID }]),
|
||||
});
|
||||
}, [editingAutomationRule, selectedRuleItem]);
|
||||
|
||||
@@ -313,6 +317,35 @@ export const useRuleActions = ({
|
||||
setEditingAutomationRule({ ...editingAutomationRule, variants: next, card_group_id: next[0]?.card_id || 0 });
|
||||
}, [displayVariants, editingAutomationRule]);
|
||||
|
||||
// updateAdjustPriceTarget 更新拍下改价草稿中的目标价格。
|
||||
const updateAdjustPriceTarget = useCallback(/* adjustPriceAction 更新改价目标价格。 */ (targetPrice: string) => {
|
||||
if (!editingAutomationRule) return;
|
||||
// baseActions 保存至少包含改价动作的当前动作列表。
|
||||
const baseActions = editingAutomationRule.actions?.some(/* 当前回调查找改价动作。 */ action => action.action_type === 'adjust_price')
|
||||
? editingAutomationRule.actions
|
||||
: cardActionsForTrigger('order_created');
|
||||
setEditingAutomationRule({
|
||||
...editingAutomationRule,
|
||||
actions: baseActions.map(/* 当前回调把新目标价格写入改价动作配置。 */ action =>
|
||||
action.action_type === 'adjust_price' ? { ...action, config_json: buildAdjustPriceConfig(targetPrice) } : action),
|
||||
});
|
||||
}, [editingAutomationRule]);
|
||||
|
||||
// updateAdjustPriceNotifyText 更新拍下改价草稿中的可选买家提醒文案。
|
||||
const updateAdjustPriceNotifyText = useCallback(/* adjustNotifyAction 更新改价提醒文案。 */ (text: string) => {
|
||||
if (!editingAutomationRule) return;
|
||||
// actions 保存当前动作列表副本。
|
||||
const actions = (editingAutomationRule.actions || []).slice();
|
||||
// textIndex 是可选提醒动作在列表中的位置。
|
||||
const textIndex = actions.findIndex(/* 当前回调查找提醒文案动作。 */ action => action.action_type === 'send_text');
|
||||
if (textIndex >= 0) {
|
||||
actions[textIndex] = { ...actions[textIndex], message_template: text };
|
||||
} else {
|
||||
actions.push({ action_type: 'send_text', message_template: text, enabled: true, sort_order: actions.length + 1 });
|
||||
}
|
||||
setEditingAutomationRule({ ...editingAutomationRule, actions });
|
||||
}, [editingAutomationRule]);
|
||||
|
||||
// appendDeliveryContent 在规格编辑器末尾追加一行。
|
||||
const appendDeliveryContent = useCallback(/* appendVariantAction 追加规则规格。 */ () => {
|
||||
if (!editingAutomationRule) return;
|
||||
@@ -332,7 +365,7 @@ export const useRuleActions = ({
|
||||
if (!editingAutomationRule.cookie_id) return alert('请选择账号');
|
||||
// variants 保存当前规格列表。
|
||||
const variants = editingAutomationRule.variants?.length ? editingAutomationRule.variants : [];
|
||||
if (trigger !== 'review_missing_timeout') {
|
||||
if (trigger !== 'review_missing_timeout' && trigger !== 'order_created') {
|
||||
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('多规格商品必须填写每一行的规格名称和规格值');
|
||||
}
|
||||
@@ -341,13 +374,19 @@ export const useRuleActions = ({
|
||||
const text = editingAutomationRule.actions?.find(/* 当前回调查找求评价文案动作。 */ action => action.action_type === 'send_text')?.message_template || '';
|
||||
if (!text.trim()) return alert('请填写求评价文案');
|
||||
}
|
||||
// saveActions 保存实际提交的动作列表;拍下改价规则会剔除未填写文案的可选提醒动作。
|
||||
let saveActions = editingAutomationRule.actions?.length ? editingAutomationRule.actions : cardActionsForTrigger(trigger, editingAutomationRule.card_group_id || 0);
|
||||
if (trigger === 'order_created') {
|
||||
if (!isValidAdjustPrice(adjustPriceTarget(saveActions))) return alert('请填写 0.01 到 1000000 元、最多两位小数的目标价格');
|
||||
saveActions = saveActions.filter(/* 当前回调剔除空文案的可选提醒动作。 */ action => action.action_type !== 'send_text' || Boolean(action.message_template?.trim()));
|
||||
}
|
||||
// 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 }));
|
||||
const saveVariants = trigger === 'review_missing_timeout' || trigger === 'order_created' ? [] : 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 });
|
||||
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: trigger === 'order_created' ? saveActions : (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('保存成功');
|
||||
@@ -451,7 +490,7 @@ export const useRuleActions = ({
|
||||
automationSubmitState, replySubmitState, defaultReplySubmitState, editingAutomationRule, setEditingAutomationRule,
|
||||
editingReplyRule, setEditingReplyRule, defaultForm, setDefaultForm, selectedRuleItem, isMultiSpecRule, currentTrigger,
|
||||
currentMeta, reviewConfig, displayVariants, buildAutomationDraft, openAutomationRule, openNewAutomationRule,
|
||||
handleTriggerChange, handleAutomationItemChange, updateVariant, appendDeliveryContent, handleSaveAutomationRule,
|
||||
handleTriggerChange, handleAutomationItemChange, updateVariant, updateAdjustPriceTarget, updateAdjustPriceNotifyText, appendDeliveryContent, handleSaveAutomationRule,
|
||||
handleDeleteAutomation, handleToggleAutomation, handleResolveRunIssue, handleResolveDeferredIssue, handleAddReplyRule,
|
||||
handleSaveReplyRule, handleDeleteReply, openDefaultReplyModal, handleSaveDefaultReply, handleDeleteDefaultReply,
|
||||
handleClearDefaultReplyRecords,
|
||||
|
||||
@@ -68,7 +68,7 @@ export interface TriggerMeta {
|
||||
// flow 是该触发类型的步骤摘要。
|
||||
flow: string[];
|
||||
// accent 是页面使用的主题色名称。
|
||||
accent: 'blue' | 'emerald' | 'amber';
|
||||
accent: 'blue' | 'emerald' | 'amber' | 'violet';
|
||||
// icon 是触发类型对应的图标组件。
|
||||
icon: ElementType;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,14 @@ import {
|
||||
accentClasses,
|
||||
accountLabel,
|
||||
actionSummary,
|
||||
adjustPriceTarget,
|
||||
boolFlag,
|
||||
buildAdjustPriceConfig,
|
||||
buildReviewConfig,
|
||||
cardActionsForTrigger,
|
||||
defaultRuleName,
|
||||
emptyVariant,
|
||||
isValidAdjustPrice,
|
||||
parseJSONObject,
|
||||
shouldReplaceGeneratedName,
|
||||
statusPill,
|
||||
@@ -49,10 +52,13 @@ describe('规则工具函数', /* 当前回调处理规则配置和展示状态
|
||||
expect(shouldReplaceGeneratedName('我自定义的规则')).toBe(false);
|
||||
});
|
||||
|
||||
test('创建三类触发器的默认动作链', /* 当前回调处理规则配置和展示状态。 */ () => {
|
||||
test('创建各类触发器的默认动作链', /* 当前回调处理规则配置和展示状态。 */ () => {
|
||||
expect(cardActionsForTrigger('review_missing_timeout')).toEqual([{
|
||||
action_type: 'send_text', message_template: '亲,商品使用满意的话,麻烦给个评价,谢谢~', enabled: true, sort_order: 1,
|
||||
}]);
|
||||
expect(cardActionsForTrigger('order_created')).toEqual([{
|
||||
action_type: 'adjust_price', config_json: '{"target_price":""}', enabled: true, sort_order: 1,
|
||||
}]);
|
||||
expect(cardActionsForTrigger('order_paid', 7)).toEqual([
|
||||
{ action_type: 'send_card', card_id: 7, delivery_count: 1, enabled: true, sort_order: 1 },
|
||||
{ action_type: 'confirm_shipment', enabled: true, sort_order: 2 },
|
||||
@@ -62,6 +68,23 @@ describe('规则工具函数', /* 当前回调处理规则配置和展示状态
|
||||
]);
|
||||
});
|
||||
|
||||
test('校验并读取拍下改价的目标价格', /* 当前回调处理规则配置和展示状态。 */ () => {
|
||||
expect(buildAdjustPriceConfig(' 9.9 ')).toBe('{"target_price":"9.9"}');
|
||||
expect(adjustPriceTarget([{ action_type: 'adjust_price', config_json: '{"target_price":"12.5"}', enabled: true }])).toBe('12.5');
|
||||
expect(adjustPriceTarget([{ action_type: 'send_text', message_template: 'x', enabled: true }])).toBe('');
|
||||
expect(adjustPriceTarget()).toBe('');
|
||||
expect(isValidAdjustPrice('9.9')).toBe(true);
|
||||
expect(isValidAdjustPrice('0.01')).toBe(true);
|
||||
expect(isValidAdjustPrice('1000000')).toBe(true);
|
||||
expect(isValidAdjustPrice('0')).toBe(false);
|
||||
expect(isValidAdjustPrice('')).toBe(false);
|
||||
expect(isValidAdjustPrice('1.234')).toBe(false);
|
||||
expect(isValidAdjustPrice('abc')).toBe(false);
|
||||
expect(isValidAdjustPrice('1000000.01')).toBe(false);
|
||||
expect(actionSummary(rule({ trigger_type: 'order_created', actions: [{ action_type: 'adjust_price', config_json: '{"target_price":"9.9"}', enabled: true }] }))).toBe('拍下后改价为 ¥9.9');
|
||||
expect(actionSummary(rule({ trigger_type: 'order_created', actions: [] }))).toBe('未配置目标价格');
|
||||
});
|
||||
|
||||
test('汇总动作、主题样式和布尔标志', /* 当前回调处理规则配置和展示状态。 */ () => {
|
||||
expect(actionSummary(rule({ trigger_type: 'review_missing_timeout', actions: [{ action_type: 'send_text', message_template: '请评价', enabled: true }] }))).toBe('请评价');
|
||||
expect(actionSummary(rule({ trigger_type: 'review_missing_timeout', actions: [] }))).toBe('发送求评价文案');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Clock3,Gift,PackageCheck } from 'lucide-react';
|
||||
import { CircleDollarSign,Clock3,Gift,PackageCheck } from 'lucide-react';
|
||||
import type {
|
||||
AccountDetail,
|
||||
AutomationAction,
|
||||
@@ -10,6 +10,14 @@ import type { TriggerMeta } from './types';
|
||||
|
||||
// triggerMeta 是自动化触发类型的统一展示元数据,供列表和编辑器复用。
|
||||
export const triggerMeta: Record<AutomationTriggerType, TriggerMeta> = {
|
||||
order_created: {
|
||||
label: '拍下未付款自动改价',
|
||||
shortLabel: '拍下改价',
|
||||
description: '买家拍下商品未付款时,把该笔待付款订单的价格自动修改为目标价格。',
|
||||
flow: ['拍下待付款卡片', '匹配商品规则', '修改订单价格', '可选提醒买家'],
|
||||
accent: 'violet',
|
||||
icon: CircleDollarSign,
|
||||
},
|
||||
order_paid: {
|
||||
label: '付款后自动发货',
|
||||
shortLabel: '自动发货',
|
||||
@@ -37,7 +45,7 @@ export const triggerMeta: Record<AutomationTriggerType, TriggerMeta> = {
|
||||
};
|
||||
|
||||
// triggerOrder 固定自动化类型在创建面板和筛选器中的排序。
|
||||
export const triggerOrder: AutomationTriggerType[] = ['order_paid', 'buyer_reviewed', 'review_missing_timeout'];
|
||||
export const triggerOrder: AutomationTriggerType[] = ['order_paid', 'order_created', 'buyer_reviewed', 'review_missing_timeout'];
|
||||
|
||||
// reviewRequestText 是超时未评价规则的默认提醒文案。
|
||||
export const reviewRequestText = '亲,商品使用满意的话,麻烦给个评价,谢谢~';
|
||||
@@ -95,8 +103,39 @@ export const shouldReplaceGeneratedName = (name?: string) => {
|
||||
);
|
||||
};
|
||||
|
||||
// buildAdjustPriceConfig 把目标价格文本序列化为改价动作配置 JSON。
|
||||
export const buildAdjustPriceConfig = (targetPrice: string) => JSON.stringify({ target_price: targetPrice.trim() });
|
||||
|
||||
// adjustPriceTarget 从动作列表读取改价动作的目标价格文本。
|
||||
export const adjustPriceTarget = (actions?: AutomationAction[]): string => {
|
||||
// action 是动作列表中的改价动作。
|
||||
const action = (actions || []).find(
|
||||
// 改价动作匹配器只查找订单改价类型。
|
||||
candidate => candidate.action_type === 'adjust_price',
|
||||
);
|
||||
return String(parseJSONObject(action?.config_json).target_price ?? '');
|
||||
};
|
||||
|
||||
// isValidAdjustPrice 校验目标价格是否为 0.01 到 1000000 元、最多两位小数的金额。
|
||||
export const isValidAdjustPrice = (raw: string): boolean => {
|
||||
// trimmed 是去掉首尾空白后的金额文本。
|
||||
const trimmed = raw.trim();
|
||||
if (!/^\d+(\.\d{1,2})?$/.test(trimmed)) return false;
|
||||
// cents 是金额折算出的整数分。
|
||||
const cents = Math.round(Number(trimmed) * 100);
|
||||
return cents >= 1 && cents <= 100000000;
|
||||
};
|
||||
|
||||
// cardActionsForTrigger 根据触发类型创建默认动作链。
|
||||
export const cardActionsForTrigger = (trigger: AutomationTriggerType, cardID = 0): AutomationAction[] => {
|
||||
if (trigger === 'order_created') {
|
||||
return [{
|
||||
action_type: 'adjust_price',
|
||||
config_json: buildAdjustPriceConfig(''),
|
||||
enabled: true,
|
||||
sort_order: 1,
|
||||
}];
|
||||
}
|
||||
if (trigger === 'review_missing_timeout') {
|
||||
return [{
|
||||
action_type: 'send_text',
|
||||
@@ -123,6 +162,11 @@ export const cardActionsForTrigger = (trigger: AutomationTriggerType, cardID = 0
|
||||
|
||||
// actionSummary 将规则动作转换成列表中的简短摘要。
|
||||
export const actionSummary = (rule: ShippingRule) => {
|
||||
if (rule.trigger_type === 'order_created') {
|
||||
// target 是规则配置的改价目标价格。
|
||||
const target = adjustPriceTarget(rule.actions);
|
||||
return target ? `拍下后改价为 ¥${target}` : '未配置目标价格';
|
||||
}
|
||||
if (rule.trigger_type === 'review_missing_timeout') {
|
||||
return rule.actions?.find(
|
||||
// 文案动作匹配器只查找发送文字动作。
|
||||
@@ -148,6 +192,7 @@ export const accentClasses = (accent: TriggerMeta['accent'], selected = false) =
|
||||
blue: selected ? 'border-blue-500 bg-blue-50 text-blue-700' : 'border-blue-100 bg-blue-50/60 text-blue-700 hover:border-blue-300',
|
||||
emerald: selected ? 'border-emerald-500 bg-emerald-50 text-emerald-700' : 'border-emerald-100 bg-emerald-50/60 text-emerald-700 hover:border-emerald-300',
|
||||
amber: selected ? 'border-amber-500 bg-amber-50 text-amber-700' : 'border-amber-100 bg-amber-50/60 text-amber-700 hover:border-amber-300',
|
||||
violet: selected ? 'border-violet-500 bg-violet-50 text-violet-700' : 'border-violet-100 bg-violet-50/60 text-violet-700 hover:border-violet-300',
|
||||
};
|
||||
return map[accent] || map.blue;
|
||||
};
|
||||
|
||||
@@ -89,6 +89,11 @@ func (f *fakeMtop) FetchUserProfile(context.Context, string) (*mtop.UserProfileR
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// AdjustOrderPriceContext 满足 MTOP 客户端接口,账号管理测试不关心订单改价。
|
||||
func (f *fakeMtop) AdjustOrderPriceContext(context.Context, string, string, int64) (bool, []string, string, error) {
|
||||
return true, nil, "", nil
|
||||
}
|
||||
|
||||
// ConsignContext 封装Consign上下文业务协调。
|
||||
func (f *fakeMtop) ConsignContext(context.Context, string, string) (bool, []string, string, error) {
|
||||
return false, nil, "", nil
|
||||
|
||||
@@ -55,6 +55,11 @@ func (f *orderRuntimeMTopFake) ConsignContext(ctx context.Context, cookies, orde
|
||||
return f.consign(ctx, cookies, orderID)
|
||||
}
|
||||
|
||||
// AdjustOrderPriceContext 满足基础 MTOP 客户端接口但不参与订单测试。
|
||||
func (f *orderRuntimeMTopFake) AdjustOrderPriceContext(context.Context, string, string, int64) (bool, []string, string, error) {
|
||||
return false, nil, "", errors.New("订单测试未预期改价请求")
|
||||
}
|
||||
|
||||
// FetchItemsPage 满足基础 MTOP 客户端接口但不参与订单测试。
|
||||
func (f *orderRuntimeMTopFake) FetchItemsPage(context.Context, string, int, int) (*mtop.ItemListResult, error) {
|
||||
return nil, errors.New("订单测试未预期商品分页请求")
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -14,6 +15,9 @@ var ErrRuleNotFound = errors.New("自动化规则不存在")
|
||||
// ErrRuleActive 表示规则仍有待处理运行,不能直接删除。
|
||||
var ErrRuleActive = errors.New("规则仍有待处理的自动化运行")
|
||||
|
||||
// TriggerOrderCreated 表示买家拍下未付款触发器。
|
||||
const TriggerOrderCreated = "order_created"
|
||||
|
||||
// TriggerOrderPaid 表示付款后触发器。
|
||||
const TriggerOrderPaid = "order_paid"
|
||||
|
||||
@@ -32,6 +36,9 @@ const ActionSendCard = "send_card"
|
||||
// ActionSendText 表示发送文本动作。
|
||||
const ActionSendText = "send_text"
|
||||
|
||||
// ActionAdjustPrice 表示把待付款订单价格修改为目标价格的动作。
|
||||
const ActionAdjustPrice = "adjust_price"
|
||||
|
||||
// ActionDraft 是 HTTP/应用边界使用的自动化动作输入。
|
||||
type ActionDraft struct {
|
||||
// ActionType 是动作类型。
|
||||
@@ -268,7 +275,7 @@ func (s *RuleService) Normalize(ctx context.Context, userID int64, draft RuleDra
|
||||
draft.ItemID = strings.TrimSpace(draft.ItemID)
|
||||
draft.Name = strings.TrimSpace(draft.Name)
|
||||
draft.TriggerType = strings.TrimSpace(draft.TriggerType)
|
||||
if draft.TriggerType != TriggerOrderPaid && draft.TriggerType != TriggerBuyerReviewed && draft.TriggerType != TriggerReviewMissingTimeout {
|
||||
if draft.TriggerType != TriggerOrderCreated && draft.TriggerType != TriggerOrderPaid && draft.TriggerType != TriggerBuyerReviewed && draft.TriggerType != TriggerReviewMissingTimeout {
|
||||
return RuleInput{}, errors.New("不支持的触发类型")
|
||||
}
|
||||
// owned 表示账号是否归当前用户所有;err 表示归属查询失败。
|
||||
@@ -303,16 +310,40 @@ func (s *RuleService) Normalize(ctx context.Context, userID int64, draft RuleDra
|
||||
if draft.Name == "" {
|
||||
draft.Name = defaultRuleName(draft.TriggerType, draft.ItemID)
|
||||
}
|
||||
// actions 保存规范化后的动作;三个布尔值记录启用动作类型,供规则完整性校验使用。
|
||||
actions := make([]ActionInput, 0, len(draft.Actions))
|
||||
// actions 是规范化后的动作列表;flags 汇总启用动作类型,供触发类型组合校验使用。
|
||||
actions, flags, actionsErr := s.normalizeDraftActions(ctx, userID, draft.Actions)
|
||||
if actionsErr != nil {
|
||||
return RuleInput{}, actionsErr
|
||||
}
|
||||
// combinationErr 表示触发类型与启用动作组合不满足业务约束。
|
||||
if combinationErr := validateTriggerActionCombination(draft.TriggerType, flags); combinationErr != nil {
|
||||
return RuleInput{}, combinationErr
|
||||
}
|
||||
return RuleInput{UserID: userID, CookieID: draft.CookieID, ItemID: draft.ItemID, Name: draft.Name,
|
||||
TriggerType: draft.TriggerType, Enabled: draft.Enabled, Priority: draft.Priority,
|
||||
ConfigJSON: draft.ConfigJSON, Actions: actions}, nil
|
||||
}
|
||||
|
||||
// ruleActionFlags 汇总规则草稿中各类启用动作的存在情况,供触发类型组合校验使用。
|
||||
type ruleActionFlags struct {
|
||||
// hasSendCard 表示是否存在启用的发卡动作。
|
||||
hasSendCard := false
|
||||
hasSendCard bool
|
||||
// hasSendText 表示是否存在启用的文本动作。
|
||||
hasSendText := false
|
||||
hasSendText bool
|
||||
// hasConfirmShipment 表示是否存在启用的确认发货动作。
|
||||
hasConfirmShipment := false
|
||||
hasConfirmShipment bool
|
||||
// hasAdjustPrice 表示是否存在启用的订单改价动作。
|
||||
hasAdjustPrice bool
|
||||
}
|
||||
|
||||
// normalizeDraftActions 逐个校验并规范化规则草稿中的动作,同时汇总启用动作类型标志。
|
||||
func (s *RuleService) normalizeDraftActions(ctx context.Context, userID int64, draftActions []ActionDraft) ([]ActionInput, ruleActionFlags, error) {
|
||||
// actions 保存规范化后的动作;flags 记录启用动作类型,供规则完整性校验使用。
|
||||
actions := make([]ActionInput, 0, len(draftActions))
|
||||
// flags 汇总当前草稿中启用的动作类型。
|
||||
var flags ruleActionFlags
|
||||
// index 是当前动作在草稿中的位置;draftAction 是待校验和规范化的动作。
|
||||
for index, draftAction := range draft.Actions {
|
||||
for index, draftAction := range draftActions {
|
||||
// enabled 表示当前动作是否参与运行;未提供时默认启用。
|
||||
enabled := true
|
||||
if draftAction.Enabled != nil {
|
||||
@@ -321,71 +352,102 @@ func (s *RuleService) Normalize(ctx context.Context, userID int64, draft RuleDra
|
||||
draftAction.ActionType = strings.TrimSpace(draftAction.ActionType)
|
||||
switch draftAction.ActionType {
|
||||
case ActionConfirmShipment:
|
||||
hasConfirmShipment = hasConfirmShipment || enabled
|
||||
flags.hasConfirmShipment = flags.hasConfirmShipment || enabled
|
||||
case ActionSendCard:
|
||||
if draftAction.CardID <= 0 {
|
||||
return RuleInput{}, errors.New("发送卡密动作必须选择卡密组")
|
||||
// cardErr 表示卡密选择缺失、读取失败或类型不支持。
|
||||
if cardErr := s.validateSendCardAction(ctx, userID, draftAction); cardErr != nil {
|
||||
return nil, flags, cardErr
|
||||
}
|
||||
// card 是归属校验通过的卡密摘要;cardErr 表示卡密读取或归属校验失败。
|
||||
card, cardErr := s.ownership.GetCard(ctx, userID, draftAction.CardID)
|
||||
if cardErr != nil {
|
||||
if !errors.Is(cardErr, ErrRuleNotFound) {
|
||||
return RuleInput{}, cardErr
|
||||
}
|
||||
return RuleInput{}, errors.New("卡密组不存在或不属于当前用户")
|
||||
}
|
||||
if card.Type == "api" {
|
||||
return RuleInput{}, errors.New("API 卡密暂不支持自动发货,请选择文本、批量数据或图片卡密")
|
||||
}
|
||||
hasSendCard = hasSendCard || enabled
|
||||
flags.hasSendCard = flags.hasSendCard || enabled
|
||||
case ActionSendText:
|
||||
if strings.TrimSpace(draftAction.MessageTemplate) == "" {
|
||||
return RuleInput{}, errors.New("发送文本动作必须填写文案")
|
||||
return nil, flags, errors.New("发送文本动作必须填写文案")
|
||||
}
|
||||
hasSendText = hasSendText || enabled
|
||||
flags.hasSendText = flags.hasSendText || enabled
|
||||
case ActionAdjustPrice:
|
||||
// priceErr 表示改价动作目标价格缺失或格式非法。
|
||||
if priceErr := validateAdjustPriceConfig(draftAction.ConfigJSON); priceErr != nil {
|
||||
return nil, flags, priceErr
|
||||
}
|
||||
flags.hasAdjustPrice = flags.hasAdjustPrice || enabled
|
||||
default:
|
||||
return RuleInput{}, errors.New("不支持的动作类型")
|
||||
return nil, flags, errors.New("不支持的动作类型")
|
||||
}
|
||||
if draftAction.DeliveryCount <= 0 {
|
||||
draftAction.DeliveryCount = 1
|
||||
}
|
||||
if draftAction.DelaySeconds < 0 || draftAction.DelaySeconds > 3600 {
|
||||
return RuleInput{}, errors.New("动作延时必须在 0 到 3600 秒之间")
|
||||
return nil, flags, errors.New("动作延时必须在 0 到 3600 秒之间")
|
||||
}
|
||||
if draftAction.ConfigJSON == "" {
|
||||
draftAction.ConfigJSON = "{}"
|
||||
}
|
||||
if !isJSONObject(draftAction.ConfigJSON) {
|
||||
return RuleInput{}, errors.New("动作配置必须是 JSON 对象")
|
||||
return nil, flags, errors.New("动作配置必须是 JSON 对象")
|
||||
}
|
||||
actions = append(actions, ActionInput{ActionType: draftAction.ActionType, CardID: draftAction.CardID,
|
||||
DeliveryCount: draftAction.DeliveryCount, MessageTemplate: draftAction.MessageTemplate,
|
||||
DelaySeconds: draftAction.DelaySeconds, ConfigJSON: draftAction.ConfigJSON, Enabled: enabled,
|
||||
SortOrder: firstRuleNonZero(draftAction.SortOrder, index+1)})
|
||||
}
|
||||
switch draft.TriggerType {
|
||||
return actions, flags, nil
|
||||
}
|
||||
|
||||
// validateSendCardAction 校验发卡动作的卡密选择、归属和类型限制。
|
||||
func (s *RuleService) validateSendCardAction(ctx context.Context, userID int64, draftAction ActionDraft) error {
|
||||
if draftAction.CardID <= 0 {
|
||||
return errors.New("发送卡密动作必须选择卡密组")
|
||||
}
|
||||
// card 是归属校验通过的卡密摘要;cardErr 表示卡密读取或归属校验失败。
|
||||
card, cardErr := s.ownership.GetCard(ctx, userID, draftAction.CardID)
|
||||
if cardErr != nil {
|
||||
if !errors.Is(cardErr, ErrRuleNotFound) {
|
||||
return cardErr
|
||||
}
|
||||
return errors.New("卡密组不存在或不属于当前用户")
|
||||
}
|
||||
if card.Type == "api" {
|
||||
return errors.New("API 卡密暂不支持自动发货,请选择文本、批量数据或图片卡密")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateTriggerActionCombination 校验触发类型允许的动作组合和必需动作。
|
||||
func validateTriggerActionCombination(triggerType string, flags ruleActionFlags) error {
|
||||
switch triggerType {
|
||||
case TriggerOrderCreated:
|
||||
if flags.hasConfirmShipment || flags.hasSendCard {
|
||||
return errors.New("拍下未付款规则只能包含改价和文本动作")
|
||||
}
|
||||
if !flags.hasAdjustPrice {
|
||||
return errors.New("拍下未付款规则至少需要一个已启用的改价动作")
|
||||
}
|
||||
case TriggerOrderPaid:
|
||||
if !hasSendCard {
|
||||
return RuleInput{}, errors.New("付款后自动发货至少需要一个已启用的发送卡密动作")
|
||||
if flags.hasAdjustPrice {
|
||||
return errors.New("改价动作只能用于拍下未付款规则")
|
||||
}
|
||||
if !flags.hasSendCard {
|
||||
return errors.New("付款后自动发货至少需要一个已启用的发送卡密动作")
|
||||
}
|
||||
case TriggerBuyerReviewed:
|
||||
if hasConfirmShipment {
|
||||
return RuleInput{}, errors.New("评价后规则不能包含确认发货动作")
|
||||
if flags.hasConfirmShipment {
|
||||
return errors.New("评价后规则不能包含确认发货动作")
|
||||
}
|
||||
if !hasSendCard && !hasSendText {
|
||||
return RuleInput{}, errors.New("评价后规则至少需要一个已启用的发送动作")
|
||||
if flags.hasAdjustPrice {
|
||||
return errors.New("改价动作只能用于拍下未付款规则")
|
||||
}
|
||||
if !flags.hasSendCard && !flags.hasSendText {
|
||||
return errors.New("评价后规则至少需要一个已启用的发送动作")
|
||||
}
|
||||
case TriggerReviewMissingTimeout:
|
||||
if hasConfirmShipment || hasSendCard {
|
||||
return RuleInput{}, errors.New("求评价规则只能发送文本")
|
||||
if flags.hasConfirmShipment || flags.hasSendCard || flags.hasAdjustPrice {
|
||||
return errors.New("求评价规则只能发送文本")
|
||||
}
|
||||
if !hasSendText {
|
||||
return RuleInput{}, errors.New("求评价规则至少需要一个已启用的文本动作")
|
||||
if !flags.hasSendText {
|
||||
return errors.New("求评价规则至少需要一个已启用的文本动作")
|
||||
}
|
||||
}
|
||||
return RuleInput{UserID: userID, CookieID: draft.CookieID, ItemID: draft.ItemID, Name: draft.Name,
|
||||
TriggerType: draft.TriggerType, Enabled: draft.Enabled, Priority: draft.Priority,
|
||||
ConfigJSON: draft.ConfigJSON, Actions: actions}, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create 创建已校验的自动化规则。
|
||||
@@ -412,6 +474,56 @@ func (s *RuleService) Delete(ctx context.Context, userID, ruleID int64) error {
|
||||
return s.repository.Delete(ctx, userID, ruleID)
|
||||
}
|
||||
|
||||
// validateAdjustPriceConfig 校验改价动作配置中的目标价格。
|
||||
// 金额使用十进制字符串校验:0.01 到 1000000 元、至多两位小数,禁止浮点解析。
|
||||
func validateAdjustPriceConfig(configJSON string) error {
|
||||
// cfg 保存改价动作的目标价格配置;target_price 以元为单位的字符串。
|
||||
var cfg struct {
|
||||
TargetPrice string `json:"target_price"`
|
||||
}
|
||||
if json.Unmarshal([]byte(configJSON), &cfg) != nil {
|
||||
return errors.New("改价动作配置必须是 JSON 对象")
|
||||
}
|
||||
// raw 是去空白后的目标价格文本。
|
||||
raw := strings.TrimSpace(cfg.TargetPrice)
|
||||
if raw == "" {
|
||||
return errors.New("改价动作必须填写目标价格")
|
||||
}
|
||||
// wholeText、fracText 分别是金额的整数部分与小数部分文本。
|
||||
wholeText, fracText := raw, ""
|
||||
if // dot 是小数点在金额文本中的位置。
|
||||
dot := strings.IndexByte(raw, '.'); dot >= 0 {
|
||||
wholeText, fracText = raw[:dot], raw[dot+1:]
|
||||
}
|
||||
if wholeText == "" || len(fracText) > 2 {
|
||||
return errors.New("目标价格必须是最多两位小数的金额")
|
||||
}
|
||||
// whole、wholeErr 分别是整数元部分的数值和解析错误。
|
||||
whole, wholeErr := strconv.ParseInt(wholeText, 10, 64)
|
||||
if wholeErr != nil || whole < 0 {
|
||||
return errors.New("目标价格必须是最多两位小数的金额")
|
||||
}
|
||||
// frac 是小数部分折算出的分值。
|
||||
frac := int64(0)
|
||||
if fracText != "" {
|
||||
// fracValue、fracErr 分别是小数部分的数值和解析错误。
|
||||
fracValue, fracErr := strconv.ParseInt(fracText, 10, 64)
|
||||
if fracErr != nil || fracValue < 0 {
|
||||
return errors.New("目标价格必须是最多两位小数的金额")
|
||||
}
|
||||
frac = fracValue
|
||||
if len(fracText) == 1 {
|
||||
frac *= 10
|
||||
}
|
||||
}
|
||||
// cents 是目标价格的整数分结果。
|
||||
cents := whole*100 + frac
|
||||
if cents <= 0 || cents > 100000000 {
|
||||
return errors.New("目标价格必须在 0.01 到 1000000 元之间")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// isJSONObject 判断配置是否为 JSON 对象。
|
||||
func isJSONObject(raw string) bool {
|
||||
// value 是 JSON 对象解析结果,仅用于确认配置顶层类型,不保存业务状态。
|
||||
@@ -422,7 +534,7 @@ func isJSONObject(raw string) bool {
|
||||
// defaultRuleName 根据触发类型和商品标识生成默认规则名称。
|
||||
func defaultRuleName(triggerType, itemID string) string {
|
||||
// name 是按触发类型选择的默认显示名称,必要时再附加商品标识。
|
||||
name := map[string]string{TriggerOrderPaid: "付款后自动发货", TriggerBuyerReviewed: "评价后发送赠品", TriggerReviewMissingTimeout: "超时未评价求评价"}[triggerType]
|
||||
name := map[string]string{TriggerOrderCreated: "拍下未付款自动改价", TriggerOrderPaid: "付款后自动发货", TriggerBuyerReviewed: "评价后发送赠品", TriggerReviewMissingTimeout: "超时未评价求评价"}[triggerType]
|
||||
if name == "" {
|
||||
name = "自动化规则"
|
||||
}
|
||||
|
||||
@@ -163,6 +163,60 @@ func TestRuleServiceRejectsInvalidAction(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRuleServiceNormalizeOrderCreatedAdjustPrice 验证拍下未付款改价规则的合法输入和默认名称。
|
||||
func TestRuleServiceNormalizeOrderCreatedAdjustPrice(t *testing.T) {
|
||||
// service 是绑定测试端口的规则应用服务。
|
||||
service := NewRuleService(&ruleRepositoryFake{}, &ruleOwnershipFake{})
|
||||
// input、err 分别是规范化结果和校验错误。
|
||||
input, err := service.Normalize(context.Background(), 42, RuleDraft{
|
||||
CookieID: "account-1", TriggerType: TriggerOrderCreated, Actions: []ActionDraft{
|
||||
{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"9.9"}`},
|
||||
{ActionType: ActionSendText, MessageTemplate: "已为您改价,请尽快支付"},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if input.TriggerType != TriggerOrderCreated || input.Name != "拍下未付款自动改价" || len(input.Actions) != 2 {
|
||||
t.Fatalf("拍下改价规则规范化错误: %+v", input)
|
||||
}
|
||||
}
|
||||
|
||||
// TestRuleServiceRejectsInvalidOrderCreatedRules 验证拍下未付款规则的动作组合和目标价格校验。
|
||||
func TestRuleServiceRejectsInvalidOrderCreatedRules(t *testing.T) {
|
||||
// cases 保存非法拍下改价规则输入和预期错误。
|
||||
cases := []struct {
|
||||
// name 是测试分支名称。
|
||||
name string
|
||||
// draft 是待校验规则。
|
||||
draft RuleDraft
|
||||
// want 是预期错误片段。
|
||||
want string
|
||||
}{
|
||||
{name: "missing adjust price", draft: RuleDraft{CookieID: "a", TriggerType: TriggerOrderCreated, Actions: []ActionDraft{{ActionType: ActionSendText, MessageTemplate: "x"}}}, want: "至少需要一个已启用的改价动作"},
|
||||
{name: "send card forbidden", draft: RuleDraft{CookieID: "a", TriggerType: TriggerOrderCreated, Actions: []ActionDraft{{ActionType: ActionSendCard, CardID: 1}, {ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"1"}`}}}, want: "只能包含改价和文本动作"},
|
||||
{name: "confirm shipment forbidden", draft: RuleDraft{CookieID: "a", TriggerType: TriggerOrderCreated, Actions: []ActionDraft{{ActionType: ActionConfirmShipment}, {ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"1"}`}}}, want: "只能包含改价和文本动作"},
|
||||
{name: "missing price", draft: RuleDraft{CookieID: "a", TriggerType: TriggerOrderCreated, Actions: []ActionDraft{{ActionType: ActionAdjustPrice, ConfigJSON: `{}`}}}, want: "必须填写目标价格"},
|
||||
{name: "bad price format", draft: RuleDraft{CookieID: "a", TriggerType: TriggerOrderCreated, Actions: []ActionDraft{{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"1.234"}`}}}, want: "最多两位小数"},
|
||||
{name: "zero price", draft: RuleDraft{CookieID: "a", TriggerType: TriggerOrderCreated, Actions: []ActionDraft{{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"0"}`}}}, want: "0.01 到 1000000"},
|
||||
{name: "too high price", draft: RuleDraft{CookieID: "a", TriggerType: TriggerOrderCreated, Actions: []ActionDraft{{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"1000000.01"}`}}}, want: "0.01 到 1000000"},
|
||||
{name: "adjust price on paid trigger", draft: RuleDraft{CookieID: "a", TriggerType: TriggerOrderPaid, Actions: []ActionDraft{{ActionType: ActionSendCard, CardID: 1}, {ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"1"}`}}}, want: "只能用于拍下未付款规则"},
|
||||
{name: "adjust price on review trigger", draft: RuleDraft{CookieID: "a", TriggerType: TriggerReviewMissingTimeout, Actions: []ActionDraft{{ActionType: ActionSendText, MessageTemplate: "x"}, {ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"1"}`}}}, want: "求评价规则只能发送文本"},
|
||||
}
|
||||
// testCase 是当前非法拍下改价规则分支及其预期错误的测试样例。
|
||||
for _, testCase := range cases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
// service 是当前分支使用的规则应用服务。
|
||||
service := NewRuleService(&ruleRepositoryFake{}, &ruleOwnershipFake{})
|
||||
// _, err 保存规则校验错误。
|
||||
_, err := service.Normalize(context.Background(), 42, testCase.draft)
|
||||
if err == nil || !containsRuleError(err, testCase.want) {
|
||||
t.Fatalf("错误=%v,期望包含=%q", err, testCase.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestRuleServiceNormalizesPageLimit 验证分页大小和偏移量被应用层归一化。
|
||||
func TestRuleServiceNormalizesPageLimit(t *testing.T) {
|
||||
// repository 保存分页调用条件。
|
||||
|
||||
@@ -37,7 +37,7 @@ type automationActionExecutor struct {
|
||||
cardLocks sync.Map
|
||||
}
|
||||
|
||||
// shipmentConsignSession 保存一次确认发货请求开始前固定的凭证视图和响应 Cookie 会话;Cookie 明文只在本次 MTOP 调用及条件写回期间存在,禁止记录到日志或任务快照。
|
||||
// shipmentConsignSession 保存一次交易类 MTOP 请求(确认发货、订单改价共用)开始前固定的凭证视图和响应 Cookie 会话;Cookie 明文只在本次 MTOP 调用及条件写回期间存在,禁止记录到日志或任务快照。
|
||||
type shipmentConsignSession struct {
|
||||
// requestContext 是携带完整 Cookie Jar 或扁平 Cookie 的 MTOP 请求上下文。
|
||||
requestContext context.Context
|
||||
@@ -49,7 +49,7 @@ type shipmentConsignSession struct {
|
||||
credentialFingerprint string
|
||||
}
|
||||
|
||||
// shipmentConsignResult 保存 Consign 的业务结果、响应 Cookie 和传输错误,供后续会话状态与订单事实分别收口。
|
||||
// shipmentConsignResult 保存交易类 MTOP 调用(Consign、订单改价共用)的业务结果、响应 Cookie 和传输错误,供后续会话状态与订单事实分别收口。
|
||||
type shipmentConsignResult struct {
|
||||
// succeeded 表示平台明确确认订单已发货。
|
||||
succeeded bool
|
||||
@@ -76,6 +76,8 @@ func (e *automationActionExecutor) executeAction(ctx context.Context, task Task,
|
||||
switch action.ActionType {
|
||||
case ActionConfirmShipment:
|
||||
return 0, e.confirmShipment(ctx, task)
|
||||
case ActionAdjustPrice:
|
||||
return e.adjustOrderPrice(ctx, task, action)
|
||||
case ActionSendCard:
|
||||
return e.sendCard(ctx, task, action)
|
||||
case ActionSendText:
|
||||
@@ -171,6 +173,135 @@ func (e *automationActionExecutor) confirmShipmentAttempt(ctx context.Context, t
|
||||
return nil
|
||||
}
|
||||
|
||||
// adjustOrderPrice 把买家已拍下未付款订单的价格修改为动作配置的目标价格。
|
||||
// 成功返回 1 作为外部结果数量,供运行统计与结果通知使用。
|
||||
func (e *automationActionExecutor) adjustOrderPrice(ctx context.Context, task Task, action db.AutomationAction) (int, error) {
|
||||
if task.OrderID == "" {
|
||||
return 0, fmt.Errorf("%w: 订单改价缺少订单ID", errActionNotPerformed)
|
||||
}
|
||||
// priceCents 是目标价格的整数分表示;parseErr 表示动作配置缺失或金额格式非法。
|
||||
priceCents, parseErr := adjustPriceCentsFromConfig(action.ConfigJSON)
|
||||
if parseErr != nil {
|
||||
return 0, fmt.Errorf("%w: %v", errActionNotPerformed, parseErr)
|
||||
}
|
||||
// attemptErr 表示改价请求或恢复流程的最终失败原因。
|
||||
if attemptErr := e.adjustOrderPriceAttempt(ctx, task, priceCents, true); attemptErr != nil {
|
||||
return 0, attemptErr
|
||||
}
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
// adjustOrderPriceAttempt 使用凭证快照调用订单改价,并以指纹条件写回响应 Cookie;Session 失效时最多执行一次凭证恢复后重试。
|
||||
func (e *automationActionExecutor) adjustOrderPriceAttempt(ctx context.Context, task Task, priceCents int64, allowCredentialRecovery bool) error {
|
||||
// session 固定本次 MTOP 请求的最小凭证视图,外部调用期间不持有账号凭证锁。
|
||||
session, err := e.openShipmentConsignSession(ctx, task.AccountID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// succeeded、returns、updatedCookie、callErr 分别是改价的业务成功标记、业务返回、扁平 Cookie 更新和调用错误。
|
||||
succeeded, returns, updatedCookie, callErr := e.mtop().AdjustOrderPriceContext(session.requestContext, session.cookieStr, task.OrderID, priceCents)
|
||||
// result 归并 MTOP 远端结果,Cookie 写回随后独立处理。
|
||||
result := shipmentConsignResult{succeeded: succeeded, returns: returns, updatedCookie: updatedCookie, callErr: callErr}
|
||||
// cookiePersistence 收集响应 Cookie 的条件写回结果,并在锁外同步在线运行时。
|
||||
cookiePersistence := e.persistShipmentConsignCookies(ctx, task.AccountID, session, result)
|
||||
// persistenceErrs 收集本地 Cookie 写回失败;改价结果本身不依赖本地事实写入。
|
||||
persistenceErrs := cookiePersistence.errors
|
||||
// sessionErr 将请求层错误和远端业务失败统一为凭证状态判断输入。
|
||||
sessionErr := result.callErr
|
||||
if sessionErr == nil && !result.succeeded {
|
||||
sessionErr = errors.New(strings.Join(result.returns, "; "))
|
||||
}
|
||||
if mtop.IsSessionExpiredErr(sessionErr) {
|
||||
if len(persistenceErrs) > 0 {
|
||||
return errors.Join(fmt.Errorf("订单改价 Session 已失效: %w", sessionErr), errors.Join(persistenceErrs...))
|
||||
}
|
||||
// recoverer 是当前生效的凭证恢复器快照,避免一次判断期间被替换两次。
|
||||
recoverer := e.recoverer()
|
||||
if allowCredentialRecovery && recoverer != nil && recoverer.RecoverExpiredCredential(ctx, task.AccountID) {
|
||||
e.logger.Info("订单改价凭证恢复成功,重新执行改价", "account", task.AccountID, "order_id", task.OrderID)
|
||||
return e.adjustOrderPriceAttempt(ctx, task, priceCents, false)
|
||||
}
|
||||
if !allowCredentialRecovery {
|
||||
return fmt.Errorf("%w: 订单改价在凭证恢复后仍返回 Session 失效: %v", errActionNotPerformed, sessionErr)
|
||||
}
|
||||
return fmt.Errorf("%w: 订单改价 Session 已失效且凭证恢复失败: %v", errActionNotPerformed, sessionErr)
|
||||
}
|
||||
if result.callErr != nil {
|
||||
if len(persistenceErrs) > 0 {
|
||||
result.callErr = errors.Join(result.callErr, errors.Join(persistenceErrs...))
|
||||
}
|
||||
return uncertainAction(result.callErr)
|
||||
}
|
||||
if !result.succeeded {
|
||||
// failure 是远端拒绝改价的业务错误,例如订单已付款或已关闭。
|
||||
failure := fmt.Errorf("订单改价失败: %s", strings.Join(result.returns, "; "))
|
||||
if len(persistenceErrs) > 0 {
|
||||
return errors.Join(failure, errors.Join(persistenceErrs...))
|
||||
}
|
||||
return failure
|
||||
}
|
||||
if len(persistenceErrs) > 0 {
|
||||
return uncertainAction(fmt.Errorf("闲鱼已完成订单改价,但响应凭证保存失败: %w", errors.Join(persistenceErrs...)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// adjustPriceCentsFromConfig 从动作配置解析目标价格并转换为整数分。
|
||||
// 金额使用十进制字符串解析,最多两位小数,禁止浮点运算引入误差。
|
||||
func adjustPriceCentsFromConfig(configJSON string) (int64, error) {
|
||||
// cfg 保存改价动作的目标价格配置;target_price 以元为单位的字符串。
|
||||
var cfg struct {
|
||||
TargetPrice string `json:"target_price"`
|
||||
}
|
||||
if // err 是动作配置 JSON 的解析错误。
|
||||
err := json.Unmarshal([]byte(configJSON), &cfg); err != nil {
|
||||
return 0, fmt.Errorf("解析改价动作配置: %w", err)
|
||||
}
|
||||
return parseYuanToCents(cfg.TargetPrice)
|
||||
}
|
||||
|
||||
// parseYuanToCents 把以元为单位的十进制金额文本转换为整数分。
|
||||
// 允许 0.01 到 1000000 元、至多两位小数;非法格式返回错误。
|
||||
func parseYuanToCents(raw string) (int64, error) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return 0, errors.New("改价动作缺少目标价格")
|
||||
}
|
||||
// wholeText、fracText 分别是金额的整数部分与小数部分文本。
|
||||
wholeText, fracText := raw, ""
|
||||
if // dot 是小数点在金额文本中的位置。
|
||||
dot := strings.IndexByte(raw, '.'); dot >= 0 {
|
||||
wholeText, fracText = raw[:dot], raw[dot+1:]
|
||||
}
|
||||
if wholeText == "" || len(fracText) > 2 {
|
||||
return 0, fmt.Errorf("目标价格格式非法: %q", raw)
|
||||
}
|
||||
// whole、wholeErr 分别是整数元部分的数值和解析错误。
|
||||
whole, wholeErr := strconv.ParseInt(wholeText, 10, 64)
|
||||
if wholeErr != nil || whole < 0 {
|
||||
return 0, fmt.Errorf("目标价格格式非法: %q", raw)
|
||||
}
|
||||
// frac 是小数部分折算出的分值。
|
||||
frac := int64(0)
|
||||
if fracText != "" {
|
||||
// fracValue、fracErr 分别是小数部分的数值和解析错误。
|
||||
fracValue, fracErr := strconv.ParseInt(fracText, 10, 64)
|
||||
if fracErr != nil || fracValue < 0 {
|
||||
return 0, fmt.Errorf("目标价格格式非法: %q", raw)
|
||||
}
|
||||
frac = fracValue
|
||||
if len(fracText) == 1 {
|
||||
frac *= 10
|
||||
}
|
||||
}
|
||||
// cents 是目标价格的整数分结果。
|
||||
cents := whole*100 + frac
|
||||
if cents <= 0 || cents > 100000000 {
|
||||
return 0, fmt.Errorf("目标价格必须在 0.01 到 1000000 元之间: %q", raw)
|
||||
}
|
||||
return cents, nil
|
||||
}
|
||||
|
||||
// openShipmentConsignSession 在账号凭证锁内读取最小运行时视图,再在锁外构造 MTOP 会话;返回的 Cookie 只供当前确认发货请求使用。
|
||||
func (e *automationActionExecutor) openShipmentConsignSession(ctx context.Context, accountID string) (shipmentConsignSession, error) {
|
||||
// unlock 释放账号凭证锁;锁仅保护运行时 Cookie 和 metadata 的读取。
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
package automation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"xianyu-go/internal/db"
|
||||
)
|
||||
|
||||
// TestAdjustOrderPriceActionSuccess 验证改价动作成功时返回一个外部结果并传递整数分价格。
|
||||
func TestAdjustOrderPriceActionSuccess(t *testing.T) {
|
||||
// store、cleanup 保存测试数据库及其清理函数。
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
// fake 保存返回业务成功的 MTOP 客户端。
|
||||
fake := &fakeMTop{adjustOk: true, adjustRet: []string{"SUCCESS::调用成功"}}
|
||||
// center 保存注入测试 MTOP 客户端的自动化中心。
|
||||
center := NewWithDependencies(store, nil, nil, CenterDependencies{MTop: fake})
|
||||
// sent、err 分别是动作报告的外部结果数量和执行错误。
|
||||
sent, err := center.executeAction(context.Background(), Task{AccountID: "cid", OrderID: "order-1"},
|
||||
db.AutomationAction{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"9.9"}`})
|
||||
if err != nil || sent != 1 {
|
||||
t.Fatalf("sent=%d err=%v", sent, err)
|
||||
}
|
||||
if fake.adjustCalls != 1 || fake.adjustOrderIn != "order-1" || fake.adjustCentsIn != 990 {
|
||||
t.Fatalf("改价入参错误: calls=%d order=%q cents=%d", fake.adjustCalls, fake.adjustOrderIn, fake.adjustCentsIn)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceActionMissingOrderID 验证缺少订单号时动作标记为明确未执行。
|
||||
func TestAdjustOrderPriceActionMissingOrderID(t *testing.T) {
|
||||
// store、cleanup 保存测试数据库及其清理函数。
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
// fake 保存不应被调用的 MTOP 客户端。
|
||||
fake := &fakeMTop{adjustOk: true}
|
||||
// center 保存注入测试 MTOP 客户端的自动化中心。
|
||||
center := NewWithDependencies(store, nil, nil, CenterDependencies{MTop: fake})
|
||||
// sent、err 分别是动作报告的外部结果数量和执行错误。
|
||||
sent, err := center.executeAction(context.Background(), Task{AccountID: "cid"},
|
||||
db.AutomationAction{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"9.9"}`})
|
||||
if sent != 0 || !errors.Is(err, errActionNotPerformed) {
|
||||
t.Fatalf("sent=%d err=%v", sent, err)
|
||||
}
|
||||
if fake.adjustCalls != 0 {
|
||||
t.Fatalf("缺少订单号不应触达外部改价: calls=%d", fake.adjustCalls)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceActionInvalidConfig 验证目标价格非法时动作标记为明确未执行且不触网。
|
||||
func TestAdjustOrderPriceActionInvalidConfig(t *testing.T) {
|
||||
// store、cleanup 保存测试数据库及其清理函数。
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
// fake 保存不应被调用的 MTOP 客户端。
|
||||
fake := &fakeMTop{adjustOk: true}
|
||||
// center 保存注入测试 MTOP 客户端的自动化中心。
|
||||
center := NewWithDependencies(store, nil, nil, CenterDependencies{MTop: fake})
|
||||
// configs 是应当被拒绝的非法目标价格配置样本。
|
||||
configs := []string{`{}`, `{"target_price":""}`, `{"target_price":"abc"}`, `{"target_price":"1.234"}`, `{"target_price":"0"}`, `{"target_price":"-1"}`}
|
||||
// config 是当前被验证的非法配置。
|
||||
for _, config := range configs {
|
||||
// sent、err 分别是动作报告的外部结果数量和执行错误。
|
||||
sent, err := center.executeAction(context.Background(), Task{AccountID: "cid", OrderID: "order-1"},
|
||||
db.AutomationAction{ActionType: ActionAdjustPrice, ConfigJSON: config})
|
||||
if sent != 0 || !errors.Is(err, errActionNotPerformed) {
|
||||
t.Fatalf("config=%s sent=%d err=%v", config, sent, err)
|
||||
}
|
||||
}
|
||||
if fake.adjustCalls != 0 {
|
||||
t.Fatalf("非法配置不应触达外部改价: calls=%d", fake.adjustCalls)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceActionBizFailure 验证平台业务拒绝时返回带业务返回文本的失败。
|
||||
func TestAdjustOrderPriceActionBizFailure(t *testing.T) {
|
||||
// store、cleanup 保存测试数据库及其清理函数。
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
// fake 保存返回业务失败的 MTOP 客户端。
|
||||
fake := &fakeMTop{adjustOk: false, adjustRet: []string{"FAIL_BIZ_ORDER_NOT_ALLOW_MODIFY::当前订单不允许修改价格"}}
|
||||
// center 保存注入测试 MTOP 客户端的自动化中心。
|
||||
center := NewWithDependencies(store, nil, nil, CenterDependencies{MTop: fake})
|
||||
// sent、err 分别是动作报告的外部结果数量和执行错误。
|
||||
sent, err := center.executeAction(context.Background(), Task{AccountID: "cid", OrderID: "order-1"},
|
||||
db.AutomationAction{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"9.9"}`})
|
||||
if sent != 0 || err == nil || !strings.Contains(err.Error(), "FAIL_BIZ_ORDER_NOT_ALLOW_MODIFY") {
|
||||
t.Fatalf("sent=%d err=%v", sent, err)
|
||||
}
|
||||
// uncertain 用于确认业务拒绝不会被误判为结果未知。
|
||||
var uncertain *uncertainActionError
|
||||
if errors.As(err, &uncertain) {
|
||||
t.Fatalf("业务拒绝不应标记为结果未知: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceActionTransportErrorIsUncertain 验证传输错误标记为结果未知,禁止自动重放。
|
||||
func TestAdjustOrderPriceActionTransportErrorIsUncertain(t *testing.T) {
|
||||
// store、cleanup 保存测试数据库及其清理函数。
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
// fake 保存返回传输错误的 MTOP 客户端。
|
||||
fake := &fakeMTop{adjustErr: errors.New("网络中断")}
|
||||
// center 保存注入测试 MTOP 客户端的自动化中心。
|
||||
center := NewWithDependencies(store, nil, nil, CenterDependencies{MTop: fake})
|
||||
// sent、err 分别是动作报告的外部结果数量和执行错误。
|
||||
sent, err := center.executeAction(context.Background(), Task{AccountID: "cid", OrderID: "order-1"},
|
||||
db.AutomationAction{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"9.9"}`})
|
||||
if sent != 0 || err == nil {
|
||||
t.Fatalf("sent=%d err=%v", sent, err)
|
||||
}
|
||||
// uncertain 用于确认传输错误被标记为结果未知。
|
||||
var uncertain *uncertainActionError
|
||||
if !errors.As(err, &uncertain) {
|
||||
t.Fatalf("传输错误应标记为结果未知: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceRecoversExpiredSessionOnce 验证 Session 明确失效时只恢复一次凭证,并使用新凭证重新提交改价。
|
||||
func TestAdjustOrderPriceRecoversExpiredSessionOnce(t *testing.T) {
|
||||
// store、cleanup 保存测试数据库及其清理函数。
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
// ctx 是本测试共用的上下文。
|
||||
ctx := context.Background()
|
||||
// fake 保存先返回会话失效、恢复后返回成功的 MTOP 结果序列。
|
||||
fake := &fakeMTop{adjustResults: []fakeAdjustPriceResult{
|
||||
{ret: []string{"FAIL_SYS_SESSION_EXPIRED::Session过期"}},
|
||||
{ok: true, ret: []string{"SUCCESS::调用成功"}},
|
||||
}}
|
||||
// recoverer 会把测试账号的 Cookie 更新为新的有效会话。
|
||||
recoverer := &fakeCredentialRecoverer{store: store}
|
||||
// center 保存注入 MTOP 客户端和凭证恢复器的自动化中心。
|
||||
center := NewWithDependencies(store, nil, nil, CenterDependencies{MTop: fake, OrderDetailFetcher: recoverer})
|
||||
// sent、err 分别保存改价产生的外部结果数和恢复后的执行错误。
|
||||
sent, err := center.executeAction(ctx, Task{AccountID: "cid", OrderID: "order-session"},
|
||||
db.AutomationAction{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"9.9"}`})
|
||||
if err != nil || sent != 1 {
|
||||
t.Fatalf("sent=%d err=%v", sent, err)
|
||||
}
|
||||
if recoverer.calls != 1 || fake.adjustCalls != 2 {
|
||||
t.Fatalf("recover calls=%d adjust calls=%d,期望 1/2", recoverer.calls, fake.adjustCalls)
|
||||
}
|
||||
if len(fake.adjustCookies) != 2 || !strings.Contains(fake.adjustCookies[1], "fresh_1") {
|
||||
t.Fatalf("恢复后的改价未使用新凭证: %v", fake.adjustCookies)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceDoesNotOverwriteConcurrentCookie 验证改价旧响应返回的 Cookie 不会覆盖外部调用期间并发写入的新凭证。
|
||||
func TestAdjustOrderPriceDoesNotOverwriteConcurrentCookie(t *testing.T) {
|
||||
// store、cleanup 保存测试数据库及其清理函数。
|
||||
store, cleanup := newAutomationTestStore(t)
|
||||
defer cleanup()
|
||||
// ctx 是本测试共用的上下文。
|
||||
ctx := context.Background()
|
||||
// initial 是外部请求开始时写入的旧 Cookie。
|
||||
initial := "sid=old"
|
||||
// err 保存写入初始凭证的错误。
|
||||
if err := store.Cookies.UpdateRenewalCookie(ctx, "cid", initial, `{"origin":"old"}`, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// started 在改价请求读取旧凭证后通知测试进入并发更新窗口。
|
||||
started := make(chan struct{})
|
||||
// release 控制暂停的改价请求何时返回旧响应。
|
||||
release := make(chan struct{})
|
||||
// fake 在调用中暂停,以便测试并发凭证更新;返回成功与过期 Cookie 响应。
|
||||
fake := &fakeMTop{adjustOk: true, adjustUpdated: "sid=stale-response", adjustStarted: started, adjustRelease: release}
|
||||
// center 保存注入改价替身的自动化中心。
|
||||
center := NewWithDependencies(store, nil, nil, CenterDependencies{MTop: fake})
|
||||
// latest 是并发写入后的新 Cookie,旧响应不允许覆盖它。
|
||||
latest := "sid=new-runtime"
|
||||
// result 异步接收改价的外部结果数和执行错误,令测试可在网络调用期间写入新凭证。
|
||||
result := make(chan struct {
|
||||
// sent 是改价产生的外部结果数量。
|
||||
sent int
|
||||
// err 是改价执行返回的错误。
|
||||
err error
|
||||
}, 1)
|
||||
go func() {
|
||||
// sent、runErr 分别保存异步改价产生的外部结果数和执行错误。
|
||||
sent, runErr := center.executeAction(ctx, Task{AccountID: "cid", OrderID: "credential-conflict"},
|
||||
db.AutomationAction{ActionType: ActionAdjustPrice, ConfigJSON: `{"target_price":"9.9"}`})
|
||||
result <- struct {
|
||||
sent int
|
||||
err error
|
||||
}{sent: sent, err: runErr}
|
||||
}()
|
||||
select {
|
||||
case <-started:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("订单改价外部调用未开始")
|
||||
}
|
||||
// err 保存并发更新操作错误;该写入发生在旧响应持久化之前,验证其不会被覆盖。
|
||||
if err := store.Cookies.UpdateRenewalCookie(ctx, "cid", latest, `{"origin":"new"}`, 2); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
close(release)
|
||||
// outcome 保存异步改价完成后的外部结果和错误。
|
||||
outcome := <-result
|
||||
if outcome.sent != 0 || outcome.err == nil || !strings.Contains(outcome.err.Error(), "并发更新冲突") {
|
||||
t.Fatalf("sent=%d err=%v", outcome.sent, outcome.err)
|
||||
}
|
||||
// detail、detailErr 分别保存最终凭证运行视图和读取错误。
|
||||
detail, detailErr := store.Cookies.GetDetails(ctx, "cid")
|
||||
if detailErr != nil {
|
||||
t.Fatal(detailErr)
|
||||
}
|
||||
if detail.Value != latest {
|
||||
t.Fatalf("Cookie 更新错误: got=%q want=%q", detail.Value, latest)
|
||||
}
|
||||
}
|
||||
|
||||
// TestParseYuanToCents 验证十进制金额文本到整数分的转换边界。
|
||||
func TestParseYuanToCents(t *testing.T) {
|
||||
// cases 是金额文本与期望整数分(-1 表示期望解析失败)的样本。
|
||||
cases := []struct {
|
||||
// raw 是输入的金额文本。
|
||||
raw string
|
||||
// cents 是期望的整数分结果;-1 表示期望返回错误。
|
||||
cents int64
|
||||
}{
|
||||
{"9.9", 990}, {"0.01", 1}, {"12.34", 1234}, {"12", 1200}, {" 5.20 ", 520},
|
||||
{"1000000", 100000000},
|
||||
{"", -1}, {"abc", -1}, {"1.234", -1}, {"0", -1}, {"-1", -1}, {".5", -1}, {"1000000.01", -1},
|
||||
}
|
||||
// c 是当前被验证的样本。
|
||||
for _, c := range cases {
|
||||
// got、err 分别是解析出的整数分和解析错误。
|
||||
got, err := parseYuanToCents(c.raw)
|
||||
if c.cents == -1 {
|
||||
if err == nil {
|
||||
t.Fatalf("raw=%q 应解析失败, got=%d", c.raw, got)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil || got != c.cents {
|
||||
t.Fatalf("raw=%q got=%d err=%v want %d", c.raw, got, err, c.cents)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,28 @@ type fakeMTop struct {
|
||||
consignStarted chan struct{}
|
||||
// consignRelease 控制测试外部 Consign 调用何时返回。
|
||||
consignRelease chan struct{}
|
||||
// adjustErr 是订单改价调用的预置传输错误。
|
||||
adjustErr error
|
||||
// adjustOk 是订单改价调用的预置业务成功标志。
|
||||
adjustOk bool
|
||||
// adjustRet 是订单改价调用的预置业务返回。
|
||||
adjustRet []string
|
||||
// adjustUpdated 是订单改价调用返回的扁平 Cookie 更新。
|
||||
adjustUpdated string
|
||||
// adjustCalls 统计订单改价被调用的次数。
|
||||
adjustCalls int
|
||||
// adjustCookies 按调用顺序记录订单改价使用的凭证,供续期重试断言。
|
||||
adjustCookies []string
|
||||
// adjustOrderIn 记录最后一次订单改价的订单号入参。
|
||||
adjustOrderIn string
|
||||
// adjustCentsIn 记录最后一次订单改价的整数分价格入参。
|
||||
adjustCentsIn int64
|
||||
// adjustResults 是按调用顺序消费的订单改价预置结果。
|
||||
adjustResults []fakeAdjustPriceResult
|
||||
// adjustStarted 通知测试订单改价外部调用已经开始。
|
||||
adjustStarted chan struct{}
|
||||
// adjustRelease 控制测试订单改价外部调用何时返回。
|
||||
adjustRelease chan struct{}
|
||||
}
|
||||
|
||||
// fakeConsignResult 用于本次流程后续判断的fakeConsign结果
|
||||
@@ -38,11 +60,44 @@ type fakeConsignResult struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// fakeAdjustPriceResult 是单次订单改价调用的预置业务结果、Cookie 更新与传输错误。
|
||||
type fakeAdjustPriceResult struct {
|
||||
// ok 是平台是否明确确认改价成功。
|
||||
ok bool
|
||||
// ret 是平台返回的业务结果码。
|
||||
ret []string
|
||||
// updated 是平台下发的扁平 Cookie 更新。
|
||||
updated string
|
||||
// err 是请求或响应解析阶段的传输错误。
|
||||
err error
|
||||
}
|
||||
|
||||
// FetchUserProfile 封装Fetch用户Profile业务协调。
|
||||
func (f *fakeMTop) FetchUserProfile(context.Context, string) (*mtop.UserProfileResult, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// AdjustOrderPriceContext 返回测试预置的订单改价结果并记录入参。
|
||||
func (f *fakeMTop) AdjustOrderPriceContext(_ context.Context, cookiesStr, orderID string, priceCents int64) (bool, []string, string, error) {
|
||||
if f.adjustStarted != nil {
|
||||
close(f.adjustStarted)
|
||||
}
|
||||
if f.adjustRelease != nil {
|
||||
<-f.adjustRelease
|
||||
}
|
||||
f.adjustCalls++
|
||||
f.adjustCookies = append(f.adjustCookies, cookiesStr)
|
||||
f.adjustOrderIn = orderID
|
||||
f.adjustCentsIn = priceCents
|
||||
if len(f.adjustResults) > 0 {
|
||||
// result 是当前调用消费的预置改价结果。
|
||||
result := f.adjustResults[0]
|
||||
f.adjustResults = f.adjustResults[1:]
|
||||
return result.ok, result.ret, result.updated, result.err
|
||||
}
|
||||
return f.adjustOk, f.adjustRet, f.adjustUpdated, f.adjustErr
|
||||
}
|
||||
|
||||
// ConsignContext 封装Consign上下文业务协调。
|
||||
func (f *fakeMTop) ConsignContext(_ context.Context, cookiesStr, orderID string) (bool, []string, string, error) {
|
||||
if f.consignStarted != nil {
|
||||
|
||||
@@ -23,6 +23,7 @@ func (n deliveryNotifier) notifyResult(ctx context.Context, task Task, runID int
|
||||
}
|
||||
// triggerName 是面向用户展示的自动化触发类型名称。
|
||||
triggerName := map[string]string{
|
||||
TriggerOrderCreated: "拍下改价",
|
||||
TriggerOrderPaid: "付款发货",
|
||||
TriggerBuyerReviewed: "评价赠品",
|
||||
TriggerReviewMissingTimeout: "求评价",
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
|
||||
// TriggerOrderPaid 用于本次流程后续判断的Trigger订单Paid
|
||||
const (
|
||||
TriggerOrderCreated = "order_created"
|
||||
TriggerOrderPaid = "order_paid"
|
||||
TriggerBuyerReviewed = "buyer_reviewed"
|
||||
TriggerReviewMissingTimeout = "review_missing_timeout"
|
||||
@@ -24,6 +25,8 @@ const (
|
||||
ActionConfirmShipment = "confirm_shipment"
|
||||
ActionSendCard = "send_card"
|
||||
ActionSendText = "send_text"
|
||||
// ActionAdjustPrice 表示把待付款订单价格修改为动作配置中的目标价格。
|
||||
ActionAdjustPrice = "adjust_price"
|
||||
)
|
||||
|
||||
// Task 是自动化中心的统一输入。它可以来自 WS 系统事件、计划任务或手动触发。
|
||||
@@ -90,6 +93,8 @@ func ExtractTaskFromWS(accountID, cookieStr string, raw map[string]any) *Task {
|
||||
switch {
|
||||
case isOrderPaidEvent(f):
|
||||
task.TriggerType = TriggerOrderPaid
|
||||
case isOrderCreatedEvent(f):
|
||||
task.TriggerType = TriggerOrderCreated
|
||||
case isBuyerReviewedEvent(f):
|
||||
task.TriggerType = TriggerBuyerReviewed
|
||||
default:
|
||||
@@ -212,6 +217,18 @@ func isOrderPaidEvent(f rawFields) bool {
|
||||
strings.Contains(f.redReminder, "等待卖家发货")
|
||||
}
|
||||
|
||||
// isOrderCreatedEvent 判定买家已拍下但尚未付款的交易卡片。
|
||||
// 闲鱼拍下样本:reminderContent=[我已拍下,待付款],或红色提醒“等待买家付款”。
|
||||
// 买家角色的同类卡片属于当前账号自己下单,不进入卖家自动化。
|
||||
func isOrderCreatedEvent(f rawFields) bool {
|
||||
if f.orderRole == "buyer" {
|
||||
return false
|
||||
}
|
||||
return strings.Contains(f.text, "我已拍下") ||
|
||||
strings.Contains(f.text, "已拍下,待付款") ||
|
||||
strings.Contains(f.redReminder, "等待买家付款")
|
||||
}
|
||||
|
||||
// isBuyerReviewedEvent 封装is买家ReviewedEvent业务协调。
|
||||
func isBuyerReviewedEvent(f rawFields) bool {
|
||||
// 闲鱼评价样本:
|
||||
|
||||
@@ -129,6 +129,50 @@ func TestExtractTaskFromWS_BuyerOrderPaidTaskNameIgnored(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestExtractTaskFromWS_OrderCreated 校验买家拍下未付款卡片解析为 order_created 事件。
|
||||
func TestExtractTaskFromWS_OrderCreated(t *testing.T) {
|
||||
// raw 是卖家收到的买家拍下待付款交易卡片样本。
|
||||
raw := mustMap(t, `{
|
||||
"1": {
|
||||
"2": "63107041124@goofish",
|
||||
"10": {
|
||||
"redReminder": "等待买家付款",
|
||||
"reminderContent": "[我已拍下,待付款]",
|
||||
"senderUserId": "2222315258815",
|
||||
"reminderUrl": "fleamarket://message_chat?itemId=1063177864132&peerUserId=2222315258815&sid=63107041124",
|
||||
"extJson": "{\"updateKey\":\"63107041124:3310145690545023994:10:BUYER_CREATE_ORDER:26\",\"contentType\":\"26\"}"
|
||||
},
|
||||
"6": {"3": {"5": "{\"dxCard\":{\"item\":{\"main\":{\"targetUrl\":\"fleamarket://order_detail?id=3310145690545023994&role=seller\"}}}}"}}
|
||||
}
|
||||
}`)
|
||||
// task 是解析出的自动化任务。
|
||||
task := ExtractTaskFromWS("acc1", "cookie", raw)
|
||||
if task == nil || task.TriggerType != TriggerOrderCreated || task.OrderID != "3310145690545023994" ||
|
||||
task.ChatID != "63107041124" || task.ItemID != "1063177864132" || task.BuyerID != "2222315258815" {
|
||||
t.Fatalf("task=%+v", task)
|
||||
}
|
||||
}
|
||||
|
||||
// TestExtractTaskFromWS_BuyerOrderCreatedIgnored 校验买家角色的拍下卡片不进入卖家自动化。
|
||||
func TestExtractTaskFromWS_BuyerOrderCreatedIgnored(t *testing.T) {
|
||||
// raw 是当前账号自己下单产生的买家角色拍下卡片样本。
|
||||
raw := mustMap(t, `{
|
||||
"1": {
|
||||
"2": "63107041124@goofish",
|
||||
"10": {
|
||||
"redReminder": "等待买家付款",
|
||||
"reminderContent": "[我已拍下,待付款]",
|
||||
"senderUserId": "2222315258815"
|
||||
},
|
||||
"6": {"3": {"5": "{\"dxCard\":{\"item\":{\"main\":{\"targetUrl\":\"fleamarket://order_detail?id=3310145690545023994&role=buyer\"}}}}"}}
|
||||
}
|
||||
}`)
|
||||
if // task 是不应产生的自动化任务。
|
||||
task := ExtractTaskFromWS("acc1", "cookie", raw); task != nil {
|
||||
t.Fatalf("买家拍下订单不应进入卖家自动化: %+v", task)
|
||||
}
|
||||
}
|
||||
|
||||
// mustMap 封装mustMap业务协调。
|
||||
func mustMap(t *testing.T, s string) map[string]any {
|
||||
t.Helper()
|
||||
|
||||
@@ -76,6 +76,11 @@ func (m *responseCookieRiskMTop) FetchUserProfile(context.Context, string) (*mto
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// AdjustOrderPriceContext 满足 MTOP 客户端接口,风控恢复测试不关心订单改价。
|
||||
func (m *responseCookieRiskMTop) AdjustOrderPriceContext(context.Context, string, string, int64) (bool, []string, string, error) {
|
||||
return true, nil, "", nil
|
||||
}
|
||||
|
||||
// ConsignContext 封装Consign上下文业务协调。
|
||||
func (m *responseCookieRiskMTop) ConsignContext(context.Context, string, string) (bool, []string, string, error) {
|
||||
return true, nil, "", nil
|
||||
|
||||
@@ -43,6 +43,11 @@ func (f *fakeRunMtop) ConsignContext(context.Context, string, string) (bool, []s
|
||||
return true, nil, "", nil
|
||||
}
|
||||
|
||||
// AdjustOrderPriceContext 满足 MTOP 客户端接口,引擎测试不关心订单改价。
|
||||
func (f *fakeRunMtop) AdjustOrderPriceContext(context.Context, string, string, int64) (bool, []string, string, error) {
|
||||
return true, nil, "", nil
|
||||
}
|
||||
|
||||
// FetchItemsPage 封装Fetch商品列表页码业务协调。
|
||||
func (f *fakeRunMtop) FetchItemsPage(context.Context, string, int, int) (*mtop.ItemListResult, error) {
|
||||
return nil, nil
|
||||
@@ -76,6 +81,11 @@ func (f *fakeFailTokenMtop) ConsignContext(context.Context, string, string) (boo
|
||||
return true, nil, "", nil
|
||||
}
|
||||
|
||||
// AdjustOrderPriceContext 满足 MTOP 客户端接口,token 失败测试不关心订单改价。
|
||||
func (f *fakeFailTokenMtop) AdjustOrderPriceContext(context.Context, string, string, int64) (bool, []string, string, error) {
|
||||
return true, nil, "", nil
|
||||
}
|
||||
|
||||
// FetchItemsPage 封装Fetch商品列表页码业务协调。
|
||||
func (f *fakeFailTokenMtop) FetchItemsPage(context.Context, string, int, int) (*mtop.ItemListResult, error) {
|
||||
return nil, nil
|
||||
|
||||
@@ -81,7 +81,7 @@ func (s *Server) listAutomationRules(w http.ResponseWriter, r *http.Request) {
|
||||
triggerType := strings.TrimSpace(query.Get("trigger_type"))
|
||||
if triggerType != "" {
|
||||
switch triggerType {
|
||||
case automationapp.TriggerOrderPaid, automationapp.TriggerBuyerReviewed, automationapp.TriggerReviewMissingTimeout:
|
||||
case automationapp.TriggerOrderCreated, automationapp.TriggerOrderPaid, automationapp.TriggerBuyerReviewed, automationapp.TriggerReviewMissingTimeout:
|
||||
default:
|
||||
writeErr(w, http.StatusBadRequest, "不支持的触发类型")
|
||||
return
|
||||
@@ -269,7 +269,7 @@ func automationRuleDraft(req automationRuleRequest) automationapp.RuleDraft {
|
||||
// defaultAutomationRuleName 保留旧测试和兼容调用所需的默认名称函数。
|
||||
func defaultAutomationRuleName(triggerType, itemID string) string {
|
||||
// name 保存按触发类型选择的默认规则名称,必要时附加商品标识。
|
||||
name := map[string]string{automationapp.TriggerOrderPaid: "付款后自动发货", automationapp.TriggerBuyerReviewed: "评价后发送赠品", automationapp.TriggerReviewMissingTimeout: "超时未评价求评价"}[triggerType]
|
||||
name := map[string]string{automationapp.TriggerOrderCreated: "拍下未付款自动改价", automationapp.TriggerOrderPaid: "付款后自动发货", automationapp.TriggerBuyerReviewed: "评价后发送赠品", automationapp.TriggerReviewMissingTimeout: "超时未评价求评价"}[triggerType]
|
||||
if name == "" {
|
||||
name = "自动化规则"
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
import{b as ie,j as e,a as l,c as Me}from"./react-vendor-l-BBvuKH.js";import{r as T,c as L}from"./index-CiBUw4Te.js";import{c as Ae,o as Pe}from"./contract-COFcZjyb.js";import{n as de,X as ce,f as Be,L as J,o as qe,p as Ge,q as Oe,r as Te,s as Le,U as Ee,t as ae,u as ze,k as we,Q as _e,v as Ie,R as We,w as Ve,x as Ke,y as Ne,K as He,z as Je,F as Xe,e as Ye,H as Ze}from"./icons-vendor-Bgrth_9N.js";import"./vendor-cRYyTeIw.js";const Fe=(t,s)=>{const r=t.avatar_url||"";if(!r)return"";try{const a=new URL(r,window.location.origin);return a.hostname.endsWith("alicdn.com")&&a.searchParams.set("_v",s),a.toString()}catch{return r}},es=async t=>{const s=await T(n=>L.GET("/api/v1/accounts/details",{signal:n}),t),r=Ae(s,["data","accounts","details"]),a=Date.now().toString();return r.map(n=>({id:n.id,cookie_configured:n.has_cookie===!0,enabled:n.enabled,auto_confirm:n.auto_confirm,remark:n.remark,pause_duration:n.pause_duration,paused_until:Number(n.paused_until||0),paused:n.paused===!0,username:n.username||"",login_password_configured:void 0,show_browser:n.show_browser===!0||n.show_browser===1||n.show_browser==="1"||n.show_browser==="true",nickname:n.nickname||n.remark||`账号 ${n.id.substring(0,6)}`,avatar_url:Fe(n,a),profile_error:n.profile_error||"",ai_enabled:!1,auto_rate_enabled:n.auto_rate_enabled,rate_content:n.rate_content||"不错的买家,交易愉快",auto_polish_enabled:n.auto_polish_enabled,polish_time:n.polish_time||"03:00",last_rate_scan_at:Number(n.last_rate_scan_at||0),last_polish_date:n.last_polish_date||"",last_polish_at:Number(n.last_polish_at||0)}))},ve=async(t,s)=>T(r=>L.GET("/api/v1/account-tasks/{cid}",{params:{path:{cid:t}},signal:r}),s),ke=async(t,s,r)=>T(a=>L.PUT("/api/v1/account-tasks/{cid}",{params:{path:{cid:t}},body:s,signal:a}),r),ss=async(t,s,r)=>T(a=>L.POST("/api/v1/account-tasks/{cid}/run",{params:{path:{cid:t}},body:{task_type:s},signal:a}),{timeoutMs:12e4,...r}),ts=async t=>await T(r=>L.GET("/api/v1/accounts/runtime-status",{signal:r}),t),as=async t=>T(s=>L.POST("/api/v1/qr-login/generate",{signal:s}),{...t,timeoutMs:(t==null?void 0:t.timeoutMs)??13e4}),rs=async(t,s)=>T(r=>L.GET("/api/v1/qr-login/check/{session_id}",{params:{path:{session_id:t}},signal:r}),{signal:s,timeoutMs:1e4}),ns=async(t,s)=>T(r=>L.POST("/api/v1/qr-login/complete-verification/{session_id}",{params:{path:{session_id:t}},body:{target_account_id:s||""},signal:r})),ls=async(t,s)=>T(r=>L.PUT("/api/v1/accounts/{cid}/status",{params:{path:{cid:t}},body:{enabled:s},signal:r})),os=async t=>T(s=>L.DELETE("/api/v1/accounts/{cid}",{params:{path:{cid:t}},signal:s})),is=async(t,s,r)=>T(a=>L.PUT("/api/v1/accounts/{cid}/pause-duration",{params:{path:{cid:t}},body:{pause_duration:s},signal:a}),r),cs=async(t,s,r)=>T(a=>L.PUT("/api/v1/accounts/{cid}/settings",{params:{path:{cid:t}},body:s,signal:a}),r),ds=async(t,s)=>T(r=>L.GET("/api/v1/accounts/{cid}/long-login",{params:{path:{cid:t}},signal:r}),s),us=async(t,s,r)=>T(a=>L.PUT("/api/v1/accounts/{cid}/long-login",{params:{path:{cid:t}},body:{enabled:s},signal:a}),r),xs=async(t,s)=>T(r=>L.POST("/api/v1/password-login",{body:t,signal:r}),s),ms=async(t,s)=>T(a=>L.GET("/api/v1/password-login/check/{session_id}",{params:{path:{session_id:t}},signal:a}),{signal:s,timeoutMs:1e4}),bs=async(t,s)=>T(r=>L.DELETE("/api/v1/password-login/cancel/{session_id}",{params:{path:{session_id:t}},signal:r}),s),hs=async t=>T(s=>L.POST("/api/v1/accounts/{cid}/refresh-profile",{params:{path:{cid:t}},signal:s})),gs=async t=>{const s=await T(r=>L.GET("/api/v1/settings/ai-reply",{signal:r}),t);return Pe(s,["settings","data","result"])||{}},ps=async(t,s)=>T(r=>L.GET("/api/v1/settings/ai-reply/{cookie_id}",{params:{path:{cookie_id:t}},signal:r}),s),fs=async(t,s,r)=>{const a={ai_enabled:s.ai_enabled??!1,max_discount_percent:s.max_discount_percent??10,max_discount_amount:s.max_discount_amount??100,max_bargain_rounds:s.max_bargain_rounds??3,custom_prompts:s.custom_prompts??""};return T(n=>L.PUT("/api/v1/settings/ai-reply/{cookie_id}",{params:{path:{cookie_id:t}},body:a,signal:n}),r)},ys=t=>{if(Array.isArray(t))return t.filter(Boolean);if(typeof t!="string"||!t.trim())return[];try{const s=JSON.parse(t);if(Array.isArray(s))return s.filter(Boolean)}catch{}return t.split(/[,\s;]+/).map(s=>s.trim()).filter(Boolean)},js=async t=>{const s=await T(a=>L.GET("/api/v1/notifications/channels",{signal:a}),t);return{success:!0,data:Ae(s,["data","channels","items"]).map(a=>{const n={},c=a.type==="ding_talk"?"dingtalk":a.type==="lark"?"feishu":a.type;return{id:String(a.id),name:a.name,type:c,config:n,event_types:ys(a.event_types),enabled:a.enabled}})}},ws=async(t,s)=>{const r=await T(n=>L.GET("/api/v1/notifications/accounts/{cid}/bindings",{params:{path:{cid:t}},signal:n}),s),a=Pe(r,["data","result"])||{};return Array.isArray(a.channel_ids)?a.channel_ids:[]},_s=({account:t,settings:s,saving:r,onChange:a,onClose:n,onSave:c})=>{const i=u=>a({...s,...u}),d=()=>i({ai_enabled:!s.ai_enabled}),b=u=>i({max_discount_percent:parseInt(Line truncated
|
||||
import{b as ie,j as e,a as l,c as Me}from"./react-vendor-l-BBvuKH.js";import{r as T,c as L}from"./index-DawJY7_a.js";import{c as Ae,o as Pe}from"./contract-COFcZjyb.js";import{n as de,X as ce,f as Be,L as J,o as qe,p as Ge,q as Oe,r as Te,s as Le,U as Ee,t as ae,u as ze,k as we,Q as _e,v as Ie,R as We,w as Ve,x as Ke,y as Ne,K as He,z as Je,F as Xe,e as Ye,H as Ze}from"./icons-vendor-CIGXYOCp.js";import"./vendor-cRYyTeIw.js";const Fe=(t,s)=>{const r=t.avatar_url||"";if(!r)return"";try{const a=new URL(r,window.location.origin);return a.hostname.endsWith("alicdn.com")&&a.searchParams.set("_v",s),a.toString()}catch{return r}},es=async t=>{const s=await T(n=>L.GET("/api/v1/accounts/details",{signal:n}),t),r=Ae(s,["data","accounts","details"]),a=Date.now().toString();return r.map(n=>({id:n.id,cookie_configured:n.has_cookie===!0,enabled:n.enabled,auto_confirm:n.auto_confirm,remark:n.remark,pause_duration:n.pause_duration,paused_until:Number(n.paused_until||0),paused:n.paused===!0,username:n.username||"",login_password_configured:void 0,show_browser:n.show_browser===!0||n.show_browser===1||n.show_browser==="1"||n.show_browser==="true",nickname:n.nickname||n.remark||`账号 ${n.id.substring(0,6)}`,avatar_url:Fe(n,a),profile_error:n.profile_error||"",ai_enabled:!1,auto_rate_enabled:n.auto_rate_enabled,rate_content:n.rate_content||"不错的买家,交易愉快",auto_polish_enabled:n.auto_polish_enabled,polish_time:n.polish_time||"03:00",last_rate_scan_at:Number(n.last_rate_scan_at||0),last_polish_date:n.last_polish_date||"",last_polish_at:Number(n.last_polish_at||0)}))},ve=async(t,s)=>T(r=>L.GET("/api/v1/account-tasks/{cid}",{params:{path:{cid:t}},signal:r}),s),ke=async(t,s,r)=>T(a=>L.PUT("/api/v1/account-tasks/{cid}",{params:{path:{cid:t}},body:s,signal:a}),r),ss=async(t,s,r)=>T(a=>L.POST("/api/v1/account-tasks/{cid}/run",{params:{path:{cid:t}},body:{task_type:s},signal:a}),{timeoutMs:12e4,...r}),ts=async t=>await T(r=>L.GET("/api/v1/accounts/runtime-status",{signal:r}),t),as=async t=>T(s=>L.POST("/api/v1/qr-login/generate",{signal:s}),{...t,timeoutMs:(t==null?void 0:t.timeoutMs)??13e4}),rs=async(t,s)=>T(r=>L.GET("/api/v1/qr-login/check/{session_id}",{params:{path:{session_id:t}},signal:r}),{signal:s,timeoutMs:1e4}),ns=async(t,s)=>T(r=>L.POST("/api/v1/qr-login/complete-verification/{session_id}",{params:{path:{session_id:t}},body:{target_account_id:s||""},signal:r})),ls=async(t,s)=>T(r=>L.PUT("/api/v1/accounts/{cid}/status",{params:{path:{cid:t}},body:{enabled:s},signal:r})),os=async t=>T(s=>L.DELETE("/api/v1/accounts/{cid}",{params:{path:{cid:t}},signal:s})),is=async(t,s,r)=>T(a=>L.PUT("/api/v1/accounts/{cid}/pause-duration",{params:{path:{cid:t}},body:{pause_duration:s},signal:a}),r),cs=async(t,s,r)=>T(a=>L.PUT("/api/v1/accounts/{cid}/settings",{params:{path:{cid:t}},body:s,signal:a}),r),ds=async(t,s)=>T(r=>L.GET("/api/v1/accounts/{cid}/long-login",{params:{path:{cid:t}},signal:r}),s),us=async(t,s,r)=>T(a=>L.PUT("/api/v1/accounts/{cid}/long-login",{params:{path:{cid:t}},body:{enabled:s},signal:a}),r),xs=async(t,s)=>T(r=>L.POST("/api/v1/password-login",{body:t,signal:r}),s),ms=async(t,s)=>T(a=>L.GET("/api/v1/password-login/check/{session_id}",{params:{path:{session_id:t}},signal:a}),{signal:s,timeoutMs:1e4}),bs=async(t,s)=>T(r=>L.DELETE("/api/v1/password-login/cancel/{session_id}",{params:{path:{session_id:t}},signal:r}),s),hs=async t=>T(s=>L.POST("/api/v1/accounts/{cid}/refresh-profile",{params:{path:{cid:t}},signal:s})),gs=async t=>{const s=await T(r=>L.GET("/api/v1/settings/ai-reply",{signal:r}),t);return Pe(s,["settings","data","result"])||{}},ps=async(t,s)=>T(r=>L.GET("/api/v1/settings/ai-reply/{cookie_id}",{params:{path:{cookie_id:t}},signal:r}),s),fs=async(t,s,r)=>{const a={ai_enabled:s.ai_enabled??!1,max_discount_percent:s.max_discount_percent??10,max_discount_amount:s.max_discount_amount??100,max_bargain_rounds:s.max_bargain_rounds??3,custom_prompts:s.custom_prompts??""};return T(n=>L.PUT("/api/v1/settings/ai-reply/{cookie_id}",{params:{path:{cookie_id:t}},body:a,signal:n}),r)},ys=t=>{if(Array.isArray(t))return t.filter(Boolean);if(typeof t!="string"||!t.trim())return[];try{const s=JSON.parse(t);if(Array.isArray(s))return s.filter(Boolean)}catch{}return t.split(/[,\s;]+/).map(s=>s.trim()).filter(Boolean)},js=async t=>{const s=await T(a=>L.GET("/api/v1/notifications/channels",{signal:a}),t);return{success:!0,data:Ae(s,["data","channels","items"]).map(a=>{const n={},c=a.type==="ding_talk"?"dingtalk":a.type==="lark"?"feishu":a.type;return{id:String(a.id),name:a.name,type:c,config:n,event_types:ys(a.event_types),enabled:a.enabled}})}},ws=async(t,s)=>{const r=await T(n=>L.GET("/api/v1/notifications/accounts/{cid}/bindings",{params:{path:{cid:t}},signal:n}),s),a=Pe(r,["data","result"])||{};return Array.isArray(a.channel_ids)?a.channel_ids:[]},_s=({account:t,settings:s,saving:r,onChange:a,onClose:n,onSave:c})=>{const i=u=>a({...s,...u}),d=()=>i({ai_enabled:!s.ai_enabled}),b=u=>i({max_discount_percent:parseInt(Line truncated
|
||||
|
||||
例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等`,className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:[e.jsxs("h4",{className:"font-bold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(Be,{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:n,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 c()),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(J,{className:"w-4 h-4 animate-spin"}):e.jsx(qe,{className:"w-4 h-4"}),r?"保存中...":"保存"]})]})})]})}),document.body)},Ce=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}),Z=(t,s,r)=>t===s&&!r.aborted,ye=(t,s)=>t instanceof Error?t.message:s,je=t=>t instanceof Error&&t.message==="请求已取消",Se=(t,s)=>!t&&s==="",Ns=({account:t,onSaved:s})=>{const[r,a]=l.useState(()=>Ce(t)),[n,c]=l.useState(!0),[i,d]=l.useState(!1),[b,m]=l.useState(""),[f,h]=l.useState(""),[u,A]=l.useState(null),[k,g]=l.useState(null),p=l.useRef(0),E=l.useRef(null);l.useEffect(()=>{var N;const S=++p.current;(N=E.current)==null||N.abort();const j=new AbortController;return E.current=j,a(Ce(t)),A(null),h(""),d(!1),m(""),g(null),c(!0),ve(t.id,{signal:j.signal}).then(R=>{Z(p.current,S,j.signal)&&a(R)}).catch(R=>{Z(p.current,S,j.signal)&&!je(R)&&h(ye(R,"加载任务设置失败"))}).finally(()=>{Z(p.current,S,j.signal)&&c(!1)}),(()=>j.abort())},[t.id]),l.useEffect(()=>(()=>{var S;return(S=E.current)==null?void 0:S.abort()}),[]);const B=l.useCallback(async()=>{var N;if(!Se(i,b))return;const S=++p.current;(N=E.current)==null||N.abort();const j=new AbortController;E.current=j,d(!0),h(""),g(null);try{const R=await ke(t.id,r,{signal:j.signal});if(!Z(p.current,S,j.signal))return;a(R),s(R)}catch(R){Z(p.current,S,j.signal)&&!je(R)&&(h(ye(R,"保存失败")),g(()=>B))}finally{Z(p.current,S,j.signal)&&d(!1)}},[t.id,r,s,b,i]),G=l.useCallback(async S=>{var R;if(!Se(i,b)||!t.enabled)return;const j=++p.current;(R=E.current)==null||R.abort();const N=new AbortController;E.current=N,m(S),h(""),A(null),g(null);try{await ke(t.id,r,{signal:N.signal});const w=await ss(t.id,S,{signal:N.signal}),P=await ve(t.id,{signal:N.signal});if(!Z(p.current,j,N.signal))return;A(w.summary),a(P),s(P)}catch(w){Z(p.current,j,N.signal)&&!je(w)&&(h(ye(w,"任务执行失败")),g(()=>(()=>G(S))))}finally{Z(p.current,j,N.signal)&&m("")}},[t.enabled,t.id,r,s,b,i]),D=l.useCallback(async()=>{k&&await k()},[k]);return{form:r,loading:n,saving:i,running:b,summary:u,error:f,retryAvailable:k!==null,setForm:a,save:B,run:G,retry:D}},Re=({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":""}`})}),vs=({account:t,onClose:s,onSaved:r})=>{const{form:a,loading:n,saving:c,running:i,error:d,summary:b,retryAvailable:m,setForm:f,save:h,run:u,retry:A}=Ns({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(ce,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"modal-body space-y-5",children:[n&&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"
Line truncated
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import{a as c,b as U,j as e}from"./react-vendor-l-BBvuKH.js";import{r as M,c as O,a as ee}from"./index-CiBUw4Te.js";import{c as te}from"./contract-COFcZjyb.js";import{X as V,W as ae,J as z,Y as se,L as q,N as J,C as X,_ as le,$ as Y,a0 as K,a1 as ne,I as re,a2 as oe,V as ce,y as ie,P as de,o as xe}from"./icons-vendor-Bgrth_9N.js";import"./vendor-cRYyTeIw.js";const pe=l=>{let n=l.api_config;if(typeof n=="string"&&n.trim())try{n=JSON.parse(n)}catch{n=void 0}return{...l,api_config:n||void 0}},Q=l=>({name:l.name,type:l.type,api_config:l.api_config?JSON.stringify(l.api_config):"",text_content:l.text_content,data_content:l.data_content,image_url:l.image_url,description:l.description,enabled:l.enabled,delay_seconds:l.delay_seconds,is_multi_spec:l.is_multi_spec,spec_name:l.spec_name,spec_value:l.spec_value}),me=async l=>{const n=await M(p=>O.GET("/api/v1/cards",{signal:p}),l);return te(n,["cards","data","items"]).map(pe)},he=async l=>M(n=>O.POST("/api/v1/cards",{body:Q(l),signal:n})),H=async(l,n)=>M(a=>O.PUT("/api/v1/cards/{card_id}",{params:{path:{card_id:String(l)}},body:Q(n),signal:a})),ue=async l=>M(n=>O.DELETE("/api/v1/cards/{card_id}",{params:{path:{card_id:String(l)}},signal:n})),be=async(l,n)=>{const a=new FormData;return a.append("file",l),M(p=>O.POST("/api/v1/cards/batch",{body:ee(a),signal:p}),n)},ge=async(l,n,a)=>M(p=>O.POST("/api/v1/cards/{card_id}/append-data",{params:{path:{card_id:String(l)}},body:{content:n},signal:p}),a),ye=(l,n,a)=>{const p=a.trim().toLocaleLowerCase();return l.filter(h=>(!n||h.type===n)&&(!p||h.name.toLocaleLowerCase().includes(p)))},Z=l=>l.split(`
|
||||
import{a as c,b as U,j as e}from"./react-vendor-l-BBvuKH.js";import{r as M,c as O,a as ee}from"./index-DawJY7_a.js";import{c as te}from"./contract-COFcZjyb.js";import{X as V,W as ae,J as z,Y as se,L as q,N as J,C as X,_ as le,$ as Y,a0 as K,a1 as ne,I as re,a2 as oe,V as ce,y as ie,P as de,o as xe}from"./icons-vendor-CIGXYOCp.js";import"./vendor-cRYyTeIw.js";const pe=l=>{let n=l.api_config;if(typeof n=="string"&&n.trim())try{n=JSON.parse(n)}catch{n=void 0}return{...l,api_config:n||void 0}},Q=l=>({name:l.name,type:l.type,api_config:l.api_config?JSON.stringify(l.api_config):"",text_content:l.text_content,data_content:l.data_content,image_url:l.image_url,description:l.description,enabled:l.enabled,delay_seconds:l.delay_seconds,is_multi_spec:l.is_multi_spec,spec_name:l.spec_name,spec_value:l.spec_value}),me=async l=>{const n=await M(p=>O.GET("/api/v1/cards",{signal:p}),l);return te(n,["cards","data","items"]).map(pe)},he=async l=>M(n=>O.POST("/api/v1/cards",{body:Q(l),signal:n})),H=async(l,n)=>M(a=>O.PUT("/api/v1/cards/{card_id}",{params:{path:{card_id:String(l)}},body:Q(n),signal:a})),ue=async l=>M(n=>O.DELETE("/api/v1/cards/{card_id}",{params:{path:{card_id:String(l)}},signal:n})),be=async(l,n)=>{const a=new FormData;return a.append("file",l),M(p=>O.POST("/api/v1/cards/batch",{body:ee(a),signal:p}),n)},ge=async(l,n,a)=>M(p=>O.POST("/api/v1/cards/{card_id}/append-data",{params:{path:{card_id:String(l)}},body:{content:n},signal:p}),a),ye=(l,n,a)=>{const p=a.trim().toLocaleLowerCase();return l.filter(h=>(!n||h.type===n)&&(!p||h.name.toLocaleLowerCase().includes(p)))},Z=l=>l.split(`
|
||||
`).map(n=>n.trim()).filter(Boolean),fe=(l,n,a)=>!!(l&&Z(n).length>0&&!a),F=(l,n,a,p)=>l===n&&a===p,W=()=>({name:"",type:"data",content:"",description:"",enabled:!0,delay_seconds:0,api_method:"GET",api_timeout:10,api_headers:"",api_params:""}),G=(l,n)=>l instanceof Error?l.message:n,je=({cards:l,loadCards:n})=>{const[a,p]=c.useState(!1),[h,_]=c.useState(!1),[f,j]=c.useState(null),[d,T]=c.useState({}),[i,y]=c.useState(W),[N,b]=c.useState(""),[r,x]=c.useState(""),s=c.useMemo(()=>l.filter(o=>o.type==="data"),[l]),u=c.useMemo(()=>ye(l,N,r),[l,r,N]),I=c.useCallback(o=>{var t,g,k,S,C;j(o),T({id:o.id,name:o.name||"",type:o.type||"text",api_url:((t=o.api_config)==null?void 0:t.url)||"",api_method:((g=o.api_config)==null?void 0:g.method)||"GET",api_timeout:((k=o.api_config)==null?void 0:k.timeout)||10,api_headers:((S=o.api_config)==null?void 0:S.headers)||"",api_params:((C=o.api_config)==null?void 0:C.params)||"",text_content:o.text_content||"",data_content:o.data_content||"",image_url:o.image_url||"",delay_seconds:o.delay_seconds||0,description:o.description||"",enabled:o.enabled}),p(!0)},[]),L=c.useCallback(async()=>{var o,t,g,k,S,C,m,A;if(f){if(!((o=d.name)!=null&&o.trim())){alert("请输入卡密名称");return}if(!d.type){alert("请选择卡密类型");return}try{const w={name:d.name.trim(),type:d.type,description:(t=d.description)==null?void 0:t.trim(),delay_seconds:d.delay_seconds||0,enabled:d.enabled??!0};d.type==="api"?w.api_config={url:((g=d.api_url)==null?void 0:g.trim())||"",method:d.api_method||"GET",timeout:d.api_timeout||10,headers:((k=d.api_headers)==null?void 0:k.trim())||void 0,params:((S=d.api_params)==null?void 0:S.trim())||void 0}:d.type==="text"?w.text_content=((C=d.text_content)==null?void 0:C.trim())||"":d.type==="data"?w.data_content=((m=d.data_content)==null?void 0:m.trim())||"":d.type==="image"&&(w.image_url=((A=d.image_url)==null?void 0:A.trim())||""),await H(f.id,w),p(!1),await n()}catch(w){console.error("更新卡密失败:",w),alert(G(w,"更新失败,请重试"))}}},[d,n,f]),P=c.useCallback(async o=>{if(confirm("确认删除该卡密吗?"))try{await ue(o),await n()}catch(t){console.error("删除卡密失败:",t),alert(G(t,"删除失败,请重试"))}},[n]),v=c.useCallback(async()=>{if(!i.name.trim()){alert("请输入卡密名称");return}if(!i.content.trim()){alert(i.type==="api"?"请输入 API 地址":"请输入卡密内容");return}try{const o={name:i.name.trim(),type:i.type,description:i.description.trim(),enabled:i.enabled,delay_seconds:i.delay_seconds};i.type==="text"&&(o.text_content=i.content.trim()),i.type==="data"&&(o.data_content=i.content.trim()),i.type==="image"&&(o.image_url=i.content.trim()),i.type==="api"&&(o.api_config={url:i.content.trim(),method:i.api_method,timeout:i.api_timeout,headers:i.api_headers.trim()||void 0,params:i.api_params.trim()||void 0}),await he(o),_(!1),y(W()),await n()}catch(o){console.error("添加卡密失败:",o),alert(G(o,"添加失败,请重试"))}},[i,n]),B=c.useCallback(async o=>{try{await H(o.id,{...o,enabled:!o.enabled}),await n()}catch(t){console.error("切换状态失败:",t)}},[n]),R=c.useCallback(async o=>{try{await navigator.clipboard.writeText(String(o)),alert(`已复制卡密组ID:${o}`)}catch{prompt("复制卡密组ID",String(o))}},[]),D=c.useCallback(()=>{const g=[["名称","类型","内容","描述","启用","延迟秒","多规格","规格名","规格值"],...[["VIP月卡","data",`VIP-MONTH-001
|
||||
VIP-MONTH-002
|
||||
VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(m=>m.map(A=>`"${String(A).replace(/"/g,'""')}"`).join(",")).join(`
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{j as e,c as x0,a as i}from"./react-vendor-l-BBvuKH.js";import{L as re}from"./vendor-cRYyTeIw.js";import{g as M0,p as le,b as F0,m as P0,s as ce,d as oe,e as pe,f as me,h as z0}from"./index-CiBUw4Te.js";import{L as X,ak as ge,al as de,M as B0,I as xe,R as ue,ad as U0,k as he,am as _e,t as J0,an as be,ao as fe,ah as Q0,X as je}from"./icons-vendor-Bgrth_9N.js";const Z0=[["尊嘟假嘟","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_
Line truncated
|
||||
import{j as e,c as x0,a as i}from"./react-vendor-l-BBvuKH.js";import{L as re}from"./vendor-cRYyTeIw.js";import{g as M0,p as le,b as F0,m as P0,s as ce,d as oe,e as pe,f as me,h as z0}from"./index-DawJY7_a.js";import{L as X,al as ge,am as de,M as B0,I as xe,R as ue,ad as U0,k as he,an as _e,t as J0,ao as be,ap as fe,ai as Q0,X as je}from"./icons-vendor-CIGXYOCp.js";const Z0=[["尊嘟假嘟","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_
Line truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{j as e,a as c}from"./react-vendor-l-BBvuKH.js";import{f as ge}from"./dateTime-DDi7rqpW.js";import{j as xe,k as he,l as se,D as pe,c as be,P as fe,m as ae,E as ye,T as je}from"./icons-vendor-Bgrth_9N.js";import{R as q,B as ve,X as re,Y as ne,T as W,a as Ne,C as X,A as we,b as _e,c as ke,P as le,d as oe,L as De}from"./charts-vendor-DlHaeEQJ.js";import{r as M,c as K}from"./index-CiBUw4Te.js";import{c as ue,o as Se}from"./contract-COFcZjyb.js";import"./vendor-cRYyTeIw.js";const F=t=>{const a=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${a}-${s}-${l}`},J=(t,a)=>{const s=new Date(t);return s.setHours(12,0,0,0),s.setDate(s.getDate()+a),s},H=(t,a)=>({startDate:F(J(t,-(a-1))),endDate:F(t)}),me=(t,a=new Date,s="",l="")=>{if(t==="custom"&&s&&l){if(s>l)throw new Error("开始日期不能晚于结束日期");return{startDate:s,endDate:l}}return t==="yesterday"?H(J(a,-1),1):H(a,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},Ce=t=>{const a=new Date(`${t.startDate}T12:00:00`),s=new Date(`${t.endDate}T12:00:00`),l=Math.round((s.getTime()-a.getTime())/864e5)+1,n=J(a,-1);return H(n,l)},i=(t,a)=>a===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${a})`,$e=({chartData:t,selectedRangeLabel:a,totalAmount:s})=>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:[a,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:t.length===0||s===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(xe,{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:"所选时间范围内暂无订单记录"})]}):t.length<=2?e.jsx(q,{width:"100%",height:"100%",children:e.jsxs(ve,{data:t,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(re,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:i("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(ne,{axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:(l=>`¥${l}`)}),e.jsx(W,{contentStyle:{backgroundColor:i("white"),borderRadius:"8px",border:`1px solid ${i("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:i("neutral-500"),fontWeight:500},itemStyle:{color:i("brand"),fontWeight:600},cursor:{fill:i("brand",.08)},formatter:(l=>[`¥${Number(l).toFixed(2)}`,"营收"])}),e.jsx(Ne,{dataKey:"amount",fill:i("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:t.map((l,n)=>e.jsx(X,{fill:i("brand"),stroke:"none",strokeWidth:0},`cell-${n}`))})]})}):e.jsx(q,{width:"100%",height:"100%",children:e.jsxs(we,{data:t,margin:{top:10,right:10,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorAmount",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:i("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:i("brand"),stopOpacity:0})]})}),e.jsx(re,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(ne,{axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx(_e,{vertical:!1,stroke:i("neutral-100"),strokeDasharray:"3 3"}),e.jsx(W,{contentStyle:{backgroundColor:i("white"),borderRadius:"8px",border:`1px solid ${i("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:i("neutral-500"),fontWeight:500},itemStyle:{color:i("brand"),fontWeight:600},cursor:{stroke:i("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(ke,{type:"monotone",dataKey:"amount",stroke:i("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:i("white"),stroke:i("brand"),strokeWidth:2}})]})})})]}),ie=t=>{const a=String(t||"");return a==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(a)?a:"unknown"},Re=async t=>M(a=>K.GET("/api/v1/analytics/dashboard",{signal:a}),t),Le=async(t,a)=>{const s=await M(n=>K.GET("/api/v1/items",{params:{query:{cookie_id:t}},signal:n}),a);return ue(s,["items","data","results"]).map(n=>({...n,id:n.id||`${n.cookie_id}-${n.item_id}`,is_multi_spec:n.is_multi_spec===!0||n.is_multi_spec===1,multi_quantity_delivery:n.multi_quantity_delivery===!0||n.multi_quantity_delivery===1}))},ce=async(t=7,a)=>{let s;if(typeof t=="number"){const l=new Date,n=new Date;n.setDate(n.getDate()-t),s={start_date:F(n),end_date:F(l)}}else s=t;return M(l=>K.GET("/api/v1/analytics/orders",{params:{query:{...s,timezone_offset_minutes:-new Date().getTimezoneOffset()}},signal:l}),a)},Te=async(t,a)=>{const s=await M(u=>K.GET("/api/v1/analytics/orders/valid",{params:{query:{...t,timezone_oLine truncated
|
||||
import{j as e,a as c}from"./react-vendor-l-BBvuKH.js";import{f as ge}from"./dateTime-DDi7rqpW.js";import{j as xe,k as he,l as se,D as pe,c as be,P as fe,m as ae,E as ye,T as je}from"./icons-vendor-CIGXYOCp.js";import{R as q,B as ve,X as re,Y as ne,T as W,a as Ne,C as X,A as we,b as _e,c as ke,P as le,d as oe,L as De}from"./charts-vendor-DlHaeEQJ.js";import{r as M,c as K}from"./index-DawJY7_a.js";import{c as ue,o as Se}from"./contract-COFcZjyb.js";import"./vendor-cRYyTeIw.js";const F=t=>{const a=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${a}-${s}-${l}`},J=(t,a)=>{const s=new Date(t);return s.setHours(12,0,0,0),s.setDate(s.getDate()+a),s},H=(t,a)=>({startDate:F(J(t,-(a-1))),endDate:F(t)}),me=(t,a=new Date,s="",l="")=>{if(t==="custom"&&s&&l){if(s>l)throw new Error("开始日期不能晚于结束日期");return{startDate:s,endDate:l}}return t==="yesterday"?H(J(a,-1),1):H(a,t==="3days"?3:t==="30days"?30:t==="today"?1:7)},Ce=t=>{const a=new Date(`${t.startDate}T12:00:00`),s=new Date(`${t.endDate}T12:00:00`),l=Math.round((s.getTime()-a.getTime())/864e5)+1,n=J(a,-1);return H(n,l)},i=(t,a)=>a===void 0?`rgb(var(--color-${t}))`:`rgb(var(--color-${t}) / ${a})`,$e=({chartData:t,selectedRangeLabel:a,totalAmount:s})=>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:[a,"的销售额走势"]})]}),e.jsx("div",{className:"dashboard-revenue-chart h-[350px] w-full",children:t.length===0||s===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(xe,{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:"所选时间范围内暂无订单记录"})]}):t.length<=2?e.jsx(q,{width:"100%",height:"100%",children:e.jsxs(ve,{data:t,margin:{top:30,right:20,left:0,bottom:30},barCategoryGap:"45%",children:[e.jsx(re,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:i("neutral-700"),fontSize:14,fontWeight:600},dy:10}),e.jsx(ne,{axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500},tickFormatter:(l=>`¥${l}`)}),e.jsx(W,{contentStyle:{backgroundColor:i("white"),borderRadius:"8px",border:`1px solid ${i("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:i("neutral-500"),fontWeight:500},itemStyle:{color:i("brand"),fontWeight:600},cursor:{fill:i("brand",.08)},formatter:(l=>[`¥${Number(l).toFixed(2)}`,"营收"])}),e.jsx(Ne,{dataKey:"amount",fill:i("brand"),maxBarSize:72,radius:[12,12,0,0],activeBar:!1,stroke:"none",strokeWidth:0,children:t.map((l,n)=>e.jsx(X,{fill:i("brand"),stroke:"none",strokeWidth:0},`cell-${n}`))})]})}):e.jsx(q,{width:"100%",height:"100%",children:e.jsxs(we,{data:t,margin:{top:10,right:10,left:-20,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorAmount",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:i("brand"),stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:i("brand"),stopOpacity:0})]})}),e.jsx(re,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500},dy:15}),e.jsx(ne,{axisLine:!1,tickLine:!1,tick:{fill:i("neutral-400"),fontSize:13,fontWeight:500}}),e.jsx(_e,{vertical:!1,stroke:i("neutral-100"),strokeDasharray:"3 3"}),e.jsx(W,{contentStyle:{backgroundColor:i("white"),borderRadius:"8px",border:`1px solid ${i("neutral-200")}`,boxShadow:"var(--shadow-xl)",padding:"12px 16px"},labelStyle:{color:i("neutral-500"),fontWeight:500},itemStyle:{color:i("brand"),fontWeight:600},cursor:{stroke:i("brand"),strokeWidth:2,strokeDasharray:"4 4"}}),e.jsx(ke,{type:"monotone",dataKey:"amount",stroke:i("brand"),strokeWidth:4,fillOpacity:1,fill:"url(#colorAmount)",activeDot:{r:8,fill:i("white"),stroke:i("brand"),strokeWidth:2}})]})})})]}),ie=t=>{const a=String(t||"");return a==="paid"?"pending_ship":["processing","pending_ship","shipped","completed","cancelled","refunding"].includes(a)?a:"unknown"},Re=async t=>M(a=>K.GET("/api/v1/analytics/dashboard",{signal:a}),t),Le=async(t,a)=>{const s=await M(n=>K.GET("/api/v1/items",{params:{query:{cookie_id:t}},signal:n}),a);return ue(s,["items","data","results"]).map(n=>({...n,id:n.id||`${n.cookie_id}-${n.item_id}`,is_multi_spec:n.is_multi_spec===!0||n.is_multi_spec===1,multi_quantity_delivery:n.multi_quantity_delivery===!0||n.multi_quantity_delivery===1}))},ce=async(t=7,a)=>{let s;if(typeof t=="number"){const l=new Date,n=new Date;n.setDate(n.getDate()-t),s={start_date:F(n),end_date:F(l)}}else s=t;return M(l=>K.GET("/api/v1/analytics/orders",{params:{query:{...s,timezone_offset_minutes:-new Date().getTimezoneOffset()}},signal:l}),a)},Te=async(t,a)=>{const s=await M(u=>K.GET("/api/v1/analytics/orders/valid",{params:{query:{...t,timezone_oLine truncated
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
import{j as e,a as r,b as we}from"./react-vendor-l-BBvuKH.js";import{r as q,c as B,A as bt}from"./index-CiBUw4Te.js";import{c as Qe}from"./contract-COFcZjyb.js";import{a3 as gt,U as $e,R as Se,N as De,a4 as Pe,a5 as _e,V as yt,y as ft,B as jt,a6 as Oe,a7 as vt,a8 as Nt,A as wt,d as _t,X as ye,o as kt,a9 as Ue,I as ze}from"./icons-vendor-Bgrth_9N.js";import"./vendor-cRYyTeIw.js";const Ke="ydisks-amap-js-api",Ct="c9b68d4ce9a2a97f22a4a439404488ca";let fe=null;const It=()=>Ct,St=()=>window.AMap?Promise.resolve(window.AMap):fe||(fe=new Promise((s,a)=>{const n=document.getElementById(Ke),d=n||document.createElement("script"),u=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(G)},f=()=>{window.AMap?(u(),s(window.AMap)):(u(),a(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},G=window.setTimeout(()=>{u(),a(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=f,d.id=Ke,d.async=!0,d.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(It())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,d.onerror=()=>{u(),a(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},n||document.head.appendChild(d)}).catch(s=>{throw fe=null,s}),fe),ke=s=>Number.isFinite(s)&&s!==0,Pt=s=>{var u,f;const a=Number((u=s.location)==null?void 0:u.lng),n=Number((f=s.location)==null?void 0:f.lat),d={area:String(s.adname||"").trim(),city:String(s.cityname||"").trim(),division_id:String(s.adcode||"").trim(),longitude:a,latitude:n,poi_id:String(s.id||"").trim(),poi_name:String(s.name||"").trim(),province:String(s.pname||"").trim()};return!d.division_id||!d.province||!d.city||!d.poi_id||!d.poi_name||!ke(a)||!ke(n)||a<-180||a>180||n<-90||n>90?null:d},qt=async(s,a,n={})=>{if(!ke(s)||!ke(a)||s<-180||s>180||a<-90||a>90)throw new Error("经纬度无效");const d=await St();return new Promise((u,f)=>{var $,M;let G=!1;const k=Math.max(1,n.timeoutMs??1e4),R=F=>{var p;G||(G=!0,globalThis.clearTimeout(W),(p=n.signal)==null||p.removeEventListener("abort",I),F())},I=()=>R(()=>f(new DOMException("aborted","AbortError"))),W=globalThis.setTimeout(()=>R(()=>f(new Error("高德地图附近地址查询超时,请稍后重试"))),k);if(($=n.signal)!=null&&$.aborted){I();return}(M=n.signal)==null||M.addEventListener("abort",I,{once:!0}),new d.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[s,a],1e3,(F,p)=>{var x;if(G)return;if(F!=="complete"){if(F==="no_data"){R(()=>u([]));return}R(()=>f(new Error("高德地图附近地址查询失败,请稍后重试")));return}const E=(((x=p==null?void 0:p.poiList)==null?void 0:x.pois)||[]).map(Pt).filter(j=>j!==null);R(()=>u(E))})})},Bt=async s=>q(a=>B.GET("/api/v1/accounts/details",{signal:a}),s),Je=async s=>q(a=>B.GET("/api/v1/automation-rules",{signal:a}),s),Et=(s,a,n)=>qt(s,a,n),qe=(s,a)=>{if(s instanceof bt)switch(s.code){case"stock_permission_missing":return"发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。";case"conflict":case"item_conflict":return"商品状态已发生变化,请刷新后重试。";case"external_result_unknown":case"manual_review_required":return"平台结果暂时无法确认,请先人工核对闲鱼状态,再决定是否重试。";case"retryable":case"temporarily_unavailable":return"平台暂时不可用,请稍后重试。";default:return s.message||a}if(s instanceof Error)return s.message;const n=typeof s=="object"&&s!==null&&"message"in s?s.message:void 0;return typeof n=="string"?n:a},Be=s=>s===!0||s===1||s==="1",Ze=async(s,a)=>{const n=await q(u=>B.GET("/api/v1/items",{params:{query:{cookie_id:s}},signal:u}),a);return Qe(n,["items","data","results"]).map(u=>({...u,id:u.id||`${u.cookie_id}-${u.item_id}`,is_multi_spec:Be(u.is_multi_spec),is_multi_qty_ship:Be(u.is_multi_qty_ship??u.multi_quantity_delivery),multi_quantity_delivery:Be(u.multi_quantity_delivery??u.is_multi_qty_ship)}))},Lt=async s=>q(a=>B.POST("/api/v1/items/get-all-from-account",{body:{cookie_id:s},signal:a})),At=async(s,a)=>q(n=>B.DELETE("/api/v1/items/{cookie_id}/{item_id}",{params:{path:{cookie_id:s,item_id:a}},signal:n})),Rt=async(s,a)=>q(n=>B.POST("/api/v1/items/{cookie_id}",{params:{path:{cookie_id:s}},body:a,signal:n})),Mt=async s=>{const a=new FormData;a.set("cookie_id",s.cookie_id),a.set("title",s.title),a.set("description",s.description),a.set("price",s.price),a.set("original_price",s.original_price||""),a.set("quantity",String(s.quantity)),a.set("postage_mode",s.postage_mode),a.set("postage",s.postage||""),s.location&&a.set("location",JSON.stringify(s.location));for(const n of s.images)a.append("images",n);return q(n=>B.POST("/api/v1/items/publish",{body:a,signal:n}))},Ft=async(s,a,n)=>q(d=>B.POST("/api/v1/items/publish-categories/recommend",{body:{cookie_id:s,keyword:a},signal:d}),n),Gt=async(s,a)=>{const n=new FormData;return n.set("file",s.file),s.imagesZip&&n.set("images_ziLine truncated
|
||||
import{j as e,a as r,b as we}from"./react-vendor-l-BBvuKH.js";import{r as q,c as B,A as bt}from"./index-DawJY7_a.js";import{c as Qe}from"./contract-COFcZjyb.js";import{a3 as gt,U as $e,R as Se,N as De,a4 as Pe,a5 as _e,V as yt,y as ft,B as jt,a6 as Oe,a7 as vt,a8 as Nt,A as wt,d as _t,X as ye,o as kt,a9 as Ue,I as ze}from"./icons-vendor-CIGXYOCp.js";import"./vendor-cRYyTeIw.js";const Ke="ydisks-amap-js-api",Ct="c9b68d4ce9a2a97f22a4a439404488ca";let fe=null;const It=()=>Ct,St=()=>window.AMap?Promise.resolve(window.AMap):fe||(fe=new Promise((s,a)=>{const n=document.getElementById(Ke),d=n||document.createElement("script"),u=()=>{window.__ydisksAmapLoaded=void 0,window.clearTimeout(G)},f=()=>{window.AMap?(u(),s(window.AMap)):(u(),a(new Error("高德地图 API 加载完成但未找到 AMap 对象")))},G=window.setTimeout(()=>{u(),a(new Error("高德地图 API 加载超时,请检查网络或 VITE_AMAP_JS_KEY 配置"))},15e3);window.__ydisksAmapLoaded=f,d.id=Ke,d.async=!0,d.src=`https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(It())}&plugin=AMap.PlaceSearch&callback=__ydisksAmapLoaded`,d.onerror=()=>{u(),a(new Error("高德地图 API 加载失败,请检查网络或 VITE_AMAP_JS_KEY 配置"))},n||document.head.appendChild(d)}).catch(s=>{throw fe=null,s}),fe),ke=s=>Number.isFinite(s)&&s!==0,Pt=s=>{var u,f;const a=Number((u=s.location)==null?void 0:u.lng),n=Number((f=s.location)==null?void 0:f.lat),d={area:String(s.adname||"").trim(),city:String(s.cityname||"").trim(),division_id:String(s.adcode||"").trim(),longitude:a,latitude:n,poi_id:String(s.id||"").trim(),poi_name:String(s.name||"").trim(),province:String(s.pname||"").trim()};return!d.division_id||!d.province||!d.city||!d.poi_id||!d.poi_name||!ke(a)||!ke(n)||a<-180||a>180||n<-90||n>90?null:d},qt=async(s,a,n={})=>{if(!ke(s)||!ke(a)||s<-180||s>180||a<-90||a>90)throw new Error("经纬度无效");const d=await St();return new Promise((u,f)=>{var $,M;let G=!1;const k=Math.max(1,n.timeoutMs??1e4),R=F=>{var p;G||(G=!0,globalThis.clearTimeout(W),(p=n.signal)==null||p.removeEventListener("abort",I),F())},I=()=>R(()=>f(new DOMException("aborted","AbortError"))),W=globalThis.setTimeout(()=>R(()=>f(new Error("高德地图附近地址查询超时,请稍后重试"))),k);if(($=n.signal)!=null&&$.aborted){I();return}(M=n.signal)==null||M.addEventListener("abort",I,{once:!0}),new d.PlaceSearch({extensions:"all",pageSize:10}).searchNearBy("",[s,a],1e3,(F,p)=>{var x;if(G)return;if(F!=="complete"){if(F==="no_data"){R(()=>u([]));return}R(()=>f(new Error("高德地图附近地址查询失败,请稍后重试")));return}const E=(((x=p==null?void 0:p.poiList)==null?void 0:x.pois)||[]).map(Pt).filter(j=>j!==null);R(()=>u(E))})})},Bt=async s=>q(a=>B.GET("/api/v1/accounts/details",{signal:a}),s),Je=async s=>q(a=>B.GET("/api/v1/automation-rules",{signal:a}),s),Et=(s,a,n)=>qt(s,a,n),qe=(s,a)=>{if(s instanceof bt)switch(s.code){case"stock_permission_missing":return"发布失败:该账号没有库存发布权限,无法按库存数量发布商品。请换账号或先在闲鱼确认库存能力。";case"conflict":case"item_conflict":return"商品状态已发生变化,请刷新后重试。";case"external_result_unknown":case"manual_review_required":return"平台结果暂时无法确认,请先人工核对闲鱼状态,再决定是否重试。";case"retryable":case"temporarily_unavailable":return"平台暂时不可用,请稍后重试。";default:return s.message||a}if(s instanceof Error)return s.message;const n=typeof s=="object"&&s!==null&&"message"in s?s.message:void 0;return typeof n=="string"?n:a},Be=s=>s===!0||s===1||s==="1",Ze=async(s,a)=>{const n=await q(u=>B.GET("/api/v1/items",{params:{query:{cookie_id:s}},signal:u}),a);return Qe(n,["items","data","results"]).map(u=>({...u,id:u.id||`${u.cookie_id}-${u.item_id}`,is_multi_spec:Be(u.is_multi_spec),is_multi_qty_ship:Be(u.is_multi_qty_ship??u.multi_quantity_delivery),multi_quantity_delivery:Be(u.multi_quantity_delivery??u.is_multi_qty_ship)}))},Lt=async s=>q(a=>B.POST("/api/v1/items/get-all-from-account",{body:{cookie_id:s},signal:a})),At=async(s,a)=>q(n=>B.DELETE("/api/v1/items/{cookie_id}/{item_id}",{params:{path:{cookie_id:s,item_id:a}},signal:n})),Rt=async(s,a)=>q(n=>B.POST("/api/v1/items/{cookie_id}",{params:{path:{cookie_id:s}},body:a,signal:n})),Mt=async s=>{const a=new FormData;a.set("cookie_id",s.cookie_id),a.set("title",s.title),a.set("description",s.description),a.set("price",s.price),a.set("original_price",s.original_price||""),a.set("quantity",String(s.quantity)),a.set("postage_mode",s.postage_mode),a.set("postage",s.postage||""),s.location&&a.set("location",JSON.stringify(s.location));for(const n of s.images)a.append("images",n);return q(n=>B.POST("/api/v1/items/publish",{body:a,signal:n}))},Ft=async(s,a,n)=>q(d=>B.POST("/api/v1/items/publish-categories/recommend",{body:{cookie_id:s,keyword:a},signal:d}),n),Gt=async(s,a)=>{const n=new FormData;return n.set("file",s.file),s.imagesZip&&n.set("images_ziLine truncated
|
||||
`),ee=new Blob(["\uFEFF"+A],{type:"text/csv;charset=utf-8"}),T=URL.createObjectURL(ee),P=document.createElement("a");P.href=T,P.download="批量铺货模板.csv",document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(T)},[]),i=r.useCallback(()=>{y(o=>({...o,cookie_id:s||o.cookie_id})),p(!0)},[s]),h=r.useCallback(()=>{v(o=>({...o,cookie_id:s||o.cookie_id})),x(!0)},[s]),L=r.useCallback(async o=>{if(!(o?s:g.cookie_id))return alert("请先选择发布账号");if(!navigator.geolocation)return alert("当前浏览器不支持定位");O();const A=new AbortController;Q.current=A;const ee=++K.current;S(!0);try{const T=await new Promise((ue,he)=>{const Ce=te=>ue(te),ie=te=>he(te);navigator.geolocation.getCurrentPosition(Ce,ie,{enableHighAccuracy:!0,timeout:15e3,maximumAge:6e4})});if(A.signal.aborted||ee!==K.current)return;const P=await Et(T.coords.longitude,T.coords.latitude,{signal:A.signal});if(A.signal.aborted||ee!==K.current)return;if(!P.length)throw new Error("当前位置附近没有可用的高德发货地,请稍后重试");o?(G(P),k(P[0])):(H(P),z(P[0]))}catch(T){if(A.signal.aborted||ee!==K.current)return;if(typeof T=="object"&&T!==null&&"code"in T){const P=T;alert(P.code===P.PERMISSION_DENIED?"定位权限被拒绝,请在浏览器设置中允许定位":"无法获取当前位置,请稍后重试")}else alert(qe(T,"获取发货地失败"))}finally{ee===K.current&&(Q.current=null,S(!1))}},[O,g.cookie_id,s,k,G]);return{selectedAccount:s,setSelectedAccount:a,loading:R,publishing:W,showEditModal:$,setShowEditModal:M,showAddModal:F,setShowAddModal:p,showPublishModal:E,setShowPublishModal:x,locationLoading:j,publishLocations:Y,setPublishLocations:H,publishLocation:X,setPublishLocation:z,selectedItem:D,editForm:C,setEditForm:le,addForm:b,setAddForm:y,publishForm:g,setPublishForm:v,publishImagePreviews:m,handleSync:ae,handleEdit:de,handleSaveEdit:ne,handleDelete:xe,handleAddItem:me,handlePublishItem:ve,downloadPublishTemplate:l,openAddModal:i,openPublishModal:h,locateForPublish:L}},Yt=s=>{const a=String(s||"").trim();return a?/^[¥¥]/.test(a)?a:`¥${a}`:"-"},ss=({onConfigureDelivery:s})=>{const[a,n]=r.useState([]),[d,u]=r.useState([]),[f,G]=r.useState([]),[k,R]=r.useState(""),[I,W]=r.useState(""),U=r.useRef(0),$=r.useRef(0),M=r.useCallback(async()=>{const t=++U.current,c=await Ze();t===U.current&&n(c)},[]),F=r.useCallback(async()=>{const t=++$.current,c=await Je();t===$.current&&u(c)},[]),p=Vt({selectedAccount:k,loadItems:M,loadShippingRules:F}),{showBatchModal:E,batchLoading:x,batchPhase:j,batchFile:S,setBatchFile:Y,batchImagesZip:H,setBatchImagesZip:X,batchCategoryKeyword:z,setBatchCategoryKeyword:D,batchCategoryLoading:Z,batchFallbackCategory:C,setBatchFallbackCategory:le,batchPreview:b,batchDetail:y,recentBatch:g,setRecentBatch:v,batchLocations:m,batchLocation:re,batchPublishIntervalSeconds:Q,setBatchPublishIntervalSeconds:K,setBatchLocations:O,setBatchLocation:ae,openBatchModal:de,handleRecommendBatchCategory:ne,openRecentBatchResult:xe,handlePreviewBatch:me,handleStartBatch:ve,handleCancelBatch:l,abandonBatchPreview:i,closeBatchModal:h,handleRetryBatchFailed:L}=p,o=Wt({selectedAccount:k,setSelectedAccount:R,setItems:n,loadItems:M,loadShippingRules:F,onConfigureDelivery:s,setBatchLocations:O,setBatchLocation:ae}),{loading:N,publishing:A,showEditModal:ee,setShowEditModal:T,showAddModal:P,setShowAddModal:ue,showPublishModal:he,setShowPublishModal:Ce,locationLoading:ie,publishLocations:te,setPublishLocations:tt,publishLocation:st,setPublishLocation:Ee,selectedItem:Le,editForm:se,setEditForm:Ne,addForm:J,setAddForm:pe,publishForm:w,setPublishForm:V,publishImagePreviews:Ae,handleSync:at,handleEdit:lt,handleSaveEdit:rt,handleDelete:nt,handleAddItem:it,handlePublishItem:ct,downloadPublishTemplate:ot,openAddModal:dt,openPublishModal:xt,locateForPublish:Re}=o;r.useEffect(()=>{const t=new AbortController,c=++U.current,_=++$.current;let ge=!0;return Promise.all([Bt({signal:t.signal}),Ze(void 0,{signal:t.signal}),Je({signal:t.signal}),et(20,{signal:t.signal})]).then(([ce,ut,ht,Te])=>{if(!ge||t.signal.aborted||c!==U.current||_!==$.current)return;G(ce),n(ut),u(ht);const pt=Te.find(Ie=>["running","canceling"].includes(Ie.status))||Te.find(Ie=>Ie.status!=="preview");v(pt||null)}).catch(ce=>{t.signal.aborted||console.error("加载商品配置失败:",ce)}),(()=>{ge=!1,t.abort()})},[]);const mt=t=>d.filter(c=>c.cookie_id===t.cookie_id&&c.item_id===t.item_id).length>0?d.filter(c=>c.cookie_id===t.cookie_id&&c.item_id===t.item_id):d.filter(c=>c.cookie_id===t.cookie_id&&!c.item_id),Me=r.useMemo(()=>new Map(f.map(t=>[t.id,t])),[f]),Fe=r.useMemo(()=>I?a.filter(t=>t.cookie_id===I):a,[I,a]),be=t=>{const c=Me.get(t),_=(c==null?void 0:c.remark)||(c==null?void 0:c.nickname);return _?`${_} · ${t.slice(0,6)}`:`账号 ${t.slice(0,8)}`},Ge=t=>{const c=Me.get(t);return(c==null?void 0:c.remark)||(c==null?void 0:c.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{
Line truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{j as e,b as _e,a as d}from"./react-vendor-l-BBvuKH.js";import{ai as te,ah as ae,aj as je,u as Q,e as I,L as z,w as Ne,y as ve,t as V,X as ne,z as re,F as le,o as we,R as ke,N as Se}from"./icons-vendor-Bgrth_9N.js";import{r as R,c as B}from"./index-CiBUw4Te.js";import"./vendor-cRYyTeIw.js";const Y=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],H=(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},oe=s=>{const t=Object.prototype.hasOwnProperty.call(s,"use_custom_smtp"),a=Y.some(r=>String(s[r]??"").trim()!=="");return{...s,use_custom_smtp:t?H(s.use_custom_smtp,!1):a}},ie=(s,t)=>{const a={...s,use_custom_smtp:!0};for(const r of Y)String(a[r]??"").trim()===""&&t[r]!==void 0&&(a[r]=t[r]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=H(a.smtp_use_tls,!0),a.smtp_use_ssl=H(a.smtp_use_ssl,!1),a},ce=s=>{const t=oe(s),a={to_email:String(t.to_email??"").trim(),use_custom_smtp:t.use_custom_smtp===!0};if(a.use_custom_smtp)for(const r of Y)a[r]=t[r];return a},F={bark:{label:"Bark",icon:I,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:Q,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:Q,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:Q,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:je,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:ae,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-1001234567890 或你的Line truncated
|
||||
import{j as e,b as _e,a as d}from"./react-vendor-l-BBvuKH.js";import{aj as te,ai as ae,ak as je,u as Q,e as I,L as z,w as Ne,y as ve,t as V,X as ne,z as re,F as le,o as ke,R as we,N as Se}from"./icons-vendor-CIGXYOCp.js";import{r as R,c as B}from"./index-DawJY7_a.js";import"./vendor-cRYyTeIw.js";const Y=["smtp_server","smtp_port","smtp_user","smtp_password","smtp_from_name","smtp_from_address","smtp_use_tls","smtp_use_ssl"],H=(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},oe=s=>{const t=Object.prototype.hasOwnProperty.call(s,"use_custom_smtp"),a=Y.some(r=>String(s[r]??"").trim()!=="");return{...s,use_custom_smtp:t?H(s.use_custom_smtp,!1):a}},ie=(s,t)=>{const a={...s,use_custom_smtp:!0};for(const r of Y)String(a[r]??"").trim()===""&&t[r]!==void 0&&(a[r]=t[r]);return a.smtp_port||(a.smtp_port=587),a.smtp_from_address||(a.smtp_from_address=a.smtp_user||""),a.smtp_use_tls=H(a.smtp_use_tls,!0),a.smtp_use_ssl=H(a.smtp_use_ssl,!1),a},ce=s=>{const t=oe(s),a={to_email:String(t.to_email??"").trim(),use_custom_smtp:t.use_custom_smtp===!0};if(a.use_custom_smtp)for(const r of Y)a[r]=t[r];return a},F={bark:{label:"Bark",icon:I,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:Q,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:Q,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:Q,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:je,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:ae,fields:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"-1001234567890 或你的Line truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{j as e,b as H,a as r}from"./react-vendor-l-BBvuKH.js";import{f as ee}from"./dateTime-DDi7rqpW.js";import{U as ne,I as ie,X as K,J as oe,R as Y,N as ce,O as se,m as te,E as de,F as xe,V as me,y as ue,h as he,g as pe,o as ge}from"./icons-vendor-Bgrth_9N.js";import{r as M,c as I}from"./index-CiBUw4Te.js";import{o as be,c as ye}from"./contract-COFcZjyb.js";import"./vendor-cRYyTeIw.js";const fe=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],je=s=>{const t=typeof s=="object"&&s!==null?s:{},a=Array.isArray(t.results)?t.results:[];return{total:Number(t.total||0),success_count:Number(t.success_count||0),failed_count:Number(t.failed_count||0),results:a.map(ve)}},ve=s=>{const t=typeof s=="object"&&s!==null?s:{};return{order_id:String(t.order_id||"unknown"),success:t.success===!0,message:String(t.message||"")}},Ne=s=>(s==null?void 0:s.results.filter(we))||[],we=s=>!s.success,_e=(s,t)=>s!==null&&!t,ke=s=>{if(!s)return"请选择订单文件";const t=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(t)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},z=(s,t)=>s===t,Ce=(s,t)=>s instanceof Error&&s.message?s.message:t,Se=({filter:s,onFilterChange:t,accountFilter:a,onAccountFilterChange:u,accounts:p,accountName:x,searchText:g,onSearchChange:N})=>{const j=i=>t(i.currentTarget.dataset.status||"all"),h=i=>u(i.target.value),v=i=>N(i.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:fe.map(i=>e.jsx("button",{"data-status":i.key,onClick:j,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===i.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:i.label},i.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(ne,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:a,onChange:h,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:"全部账号"}),p.map(i=>e.jsx("option",{value:i.id,children:x(i.id)},i.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(ie,{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:g,onChange:v,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Ee=s=>{const t=x=>{var g;s.setImportFile(((g=x.target.files)==null?void 0:g[0])||null)},a=()=>s.closeImportModal(),u=()=>void s.handleImportOrders(),p=()=>void s.handleRetryImport();return s.showImportModal?H.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:a,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(K,{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:t,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(oe,{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:p,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.imporLine truncated
|
||||
import{j as e,b as H,a as r}from"./react-vendor-l-BBvuKH.js";import{f as ee}from"./dateTime-DDi7rqpW.js";import{U as ne,I as ie,X as K,J as oe,R as Y,N as ce,O as se,m as te,E as de,F as xe,V as me,y as ue,h as he,g as pe,o as ge}from"./icons-vendor-CIGXYOCp.js";import{r as M,c as I}from"./index-DawJY7_a.js";import{o as be,c as ye}from"./contract-COFcZjyb.js";import"./vendor-cRYyTeIw.js";const fe=[{key:"all",label:"全部"},{key:"processing",label:"处理中"},{key:"shipped",label:"已发货"},{key:"pending_ship",label:"待发货"},{key:"completed",label:"已完成"},{key:"cancelled",label:"已取消"},{key:"refunding",label:"退款中"}],je=s=>{const t=typeof s=="object"&&s!==null?s:{},a=Array.isArray(t.results)?t.results:[];return{total:Number(t.total||0),success_count:Number(t.success_count||0),failed_count:Number(t.failed_count||0),results:a.map(ve)}},ve=s=>{const t=typeof s=="object"&&s!==null?s:{};return{order_id:String(t.order_id||"unknown"),success:t.success===!0,message:String(t.message||"")}},Ne=s=>(s==null?void 0:s.results.filter(we))||[],we=s=>!s.success,_e=(s,t)=>s!==null&&!t,ke=s=>{if(!s)return"请选择订单文件";const t=s.name.toLowerCase().split(".").pop()||"";return["xlsx","csv","tsv","json"].includes(t)?"":"仅支持 .xlsx、.csv、.tsv、.json 格式"},z=(s,t)=>s===t,Ce=(s,t)=>s instanceof Error&&s.message?s.message:t,Se=({filter:s,onFilterChange:t,accountFilter:a,onAccountFilterChange:u,accounts:p,accountName:x,searchText:g,onSearchChange:N})=>{const j=i=>t(i.currentTarget.dataset.status||"all"),h=i=>u(i.target.value),v=i=>N(i.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:fe.map(i=>e.jsx("button",{"data-status":i.key,onClick:j,className:`px-5 py-2 rounded-lg text-sm font-bold transition-all whitespace-nowrap ${s===i.key?"bg-white text-black shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:i.label},i.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(ne,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{"aria-label":"按账号筛选订单",value:a,onChange:h,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:"全部账号"}),p.map(i=>e.jsx("option",{value:i.id,children:x(i.id)},i.id))]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(ie,{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:g,onChange:v,className:"ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"})]})]})]})},Ee=s=>{const t=x=>{var g;s.setImportFile(((g=x.target.files)==null?void 0:g[0])||null)},a=()=>s.closeImportModal(),u=()=>void s.handleImportOrders(),p=()=>void s.handleRetryImport();return s.showImportModal?H.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsx("div",{className:"modal-header",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"插入订单"}),e.jsx("button",{onClick:a,className:"p-2 bg-gray-100 rounded-full hover:bg-gray-200 transition-colors",children:e.jsx(K,{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:t,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(oe,{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:p,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.imporLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{j as e,a as d,b as Oe}from"./react-vendor-l-BBvuKH.js";import{k as We,ae as ut,af as St,m as Rt,ag as pt,R as Ge,N as rt,Z as lt,u as At,n as nt,I as Pt,a1 as Tt,X as Ae,V as qe,y as Pe,h as Mt,g as $t,a6 as Et,ah as Lt,o as it,ai as It}from"./icons-vendor-CIGXYOCp.js";import{r as N,c as w}from"./index-DawJY7_a.js";import{o as $e,c as Ze}from"./contract-COFcZjyb.js";import"./vendor-cRYyTeIw.js";const Ve=(t,s)=>t.allowed_resolutions.includes(s),Dt=(t,s)=>({runs:t.runs.filter(l=>!s||l.cookie_id===s),pending_tasks:t.pending_tasks.filter(l=>!s||l.cookie_id===s)}),Ft=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",zt=({runs:t,pendingTasks:s,onResolveRun:l,onResolveDeferredTask:u})=>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(We,{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:[t.map(r=>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:["账号 ",r.cookie_id," · 订单 ",r.order_id||"-"," · 已记录发送 ",r.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:Ft(r.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:r.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[Ve(r,"continue")&&e.jsx("button",{onClick:(()=>l(r.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),Ve(r,"retry")&&e.jsx("button",{onClick:(()=>l(r.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),Ve(r,"cancel")&&e.jsx("button",{onClick:(()=>l(r.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${r.id}`)),s.map(r=>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:["账号 ",r.cookie_id," · 延迟任务重试已达 ",r.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:r.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:(()=>u(r.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:(()=>u(r.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${r.id}`))]})]}),Ot=async t=>N(s=>w.GET("/api/v1/accounts/details",{signal:s}),t),gt=async t=>N(s=>w.GET("/api/v1/cards",{signal:s}),t),bt=async(t,s)=>N(l=>w.GET("/api/v1/items",{params:{query:{cookie_id:t}},signal:l}),s),ht=t=>t.map(s=>{var l,u;return{id:String(s.id),name:s.name||"",trigger_type:s.trigger_type||"order_paid",item_keyword:s.item_title||s.item_id||"",cookie_id:s.cookie_id||"",item_id:s.item_id||"",item_title:s.item_title||"",card_group_id:Number(((l=(s.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:l.card_id)||0),card_group_name:((u=(s.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:u.card_name)||"",priority:s.priority||100,enabled:s.enabled||!1,config_json:s.config_json||"{}",actions:(s.actions||[]).map(r=>({id:r.id?String(r.id):void 0,action_type:r.action_type,card_id:Number(r.card_id||0),card_name:r.card_name||"",delivery_count:Number(r.delivery_count||1),message_template:r.message_template||"",delay_seconds:Number(r.delay_seconds||0),config_json:r.config_json||"{}",enabled:r.enabled!==!1,sort_order:Number(r.sort_order||0)})),variants:(s.actions||[]).filter(r=>r.action_type==="send_card").map(r=>{let h={};try{h=JSON.parse(r.config_json||"{}")}catch{}return{id:r.id?String(r.id):void 0,spec_name:h.spec_name||"",spec_value:h.spec_value||"",card_id:Number(r.card_id||0),card_name:r.card_name||"",delivery_count:Number(r.delivery_count||1),enabled:r.enabled!==!1,delay_override:h.delay_override===!0,delay_seconds:Number(r.delay_seconds||0),config_json:r.config_json||"{}"}})}}),Gt=async()=>{const t=await N(l=>w.GET("/api/v1/automation-rules",{signal:l})),s=Ze(Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{j as e,a as o,b as De}from"./react-vendor-l-BBvuKH.js";import{k as Be,ae as lt,af as ft,m as jt,R as Ie,N as Xe,Z as Qe,u as vt,n as Ye,I as Nt,a1 as wt,X as ke,V as Fe,y as Ce,h as kt,g as Ct,a6 as St,ag as Rt,o as He,ah as At}from"./icons-vendor-Bgrth_9N.js";import{r as v,c as N}from"./index-CiBUw4Te.js";import{o as Ae,c as Ue}from"./contract-COFcZjyb.js";import"./vendor-cRYyTeIw.js";const ze=(t,s)=>t.allowed_resolutions.includes(s),Mt=(t,s)=>({runs:t.runs.filter(l=>!s||l.cookie_id===s),pending_tasks:t.pending_tasks.filter(l=>!s||l.cookie_id===s)}),Tt=t=>({external_result_unknown:"外部动作结果未知",invalid_snapshot:"历史数据无法恢复",rule_unavailable:"规则不可用",partial_failure:"部分动作失败",execution_failed:"动作执行失败"})[t]||"自动化异常",Pt=({runs:t,pendingTasks:s,onResolveRun:l,onResolveDeferredTask:x})=>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(Be,{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:[t.map(r=>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:["账号 ",r.cookie_id," · 订单 ",r.order_id||"-"," · 已记录发送 ",r.sent_count," 条"]}),e.jsx("div",{className:"text-xs font-bold text-red-800 mt-1",children:Tt(r.issue_kind)}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:r.error_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[ze(r,"continue")&&e.jsx("button",{onClick:(()=>l(r.id,"continue")),className:"px-3 py-2 rounded-lg bg-emerald-100 text-emerald-800 text-xs font-bold",children:"已执行,继续下一步"}),ze(r,"retry")&&e.jsx("button",{onClick:(()=>l(r.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"未执行,安全重试"}),ze(r,"cancel")&&e.jsx("button",{onClick:(()=>l(r.id,"cancel")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"终止"})]})]},`run-${r.id}`)),s.map(r=>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:["账号 ",r.cookie_id," · 延迟任务重试已达 ",r.attempt_count," 次"]}),e.jsx("div",{className:"text-xs text-red-700 mt-1 break-words",children:r.error_message})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx("button",{onClick:(()=>x(r.id,"retry")),className:"px-3 py-2 rounded-lg bg-amber-100 text-amber-800 text-xs font-bold",children:"重新入队"}),e.jsx("button",{onClick:(()=>x(r.id,"dismiss")),className:"px-3 py-2 rounded-lg bg-gray-100 text-gray-700 text-xs font-bold",children:"忽略"})]})]},`task-${r.id}`))]})]}),Et=async t=>v(s=>N.GET("/api/v1/accounts/details",{signal:s}),t),nt=async t=>v(s=>N.GET("/api/v1/cards",{signal:s}),t),it=async(t,s)=>v(l=>N.GET("/api/v1/items",{params:{query:{cookie_id:t}},signal:l}),s),ot=t=>t.map(s=>{var l,x;return{id:String(s.id),name:s.name||"",trigger_type:s.trigger_type||"order_paid",item_keyword:s.item_title||s.item_id||"",cookie_id:s.cookie_id||"",item_id:s.item_id||"",item_title:s.item_title||"",card_group_id:Number(((l=(s.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:l.card_id)||0),card_group_name:((x=(s.actions||[]).find(r=>r.action_type==="send_card"))==null?void 0:x.card_name)||"",priority:s.priority||100,enabled:s.enabled||!1,config_json:s.config_json||"{}",actions:(s.actions||[]).map(r=>({id:r.id?String(r.id):void 0,action_type:r.action_type,card_id:Number(r.card_id||0),card_name:r.card_name||"",delivery_count:Number(r.delivery_count||1),message_template:r.message_template||"",delay_seconds:Number(r.delay_seconds||0),config_json:r.config_json||"{}",enabled:r.enabled!==!1,sort_order:Number(r.sort_order||0)})),variants:(s.actions||[]).filter(r=>r.action_type==="send_card").map(r=>{let y={};try{y=JSON.parse(r.config_json||"{}")}catch{}return{id:r.id?String(r.id):void 0,spec_name:y.spec_name||"",spec_value:y.spec_value||"",card_id:Number(r.card_id||0),card_name:r.card_name||"",delivery_count:Number(r.delivery_count||1),enabled:r.enabled!==!1,delay_override:y.delay_override===!0,delay_seconds:Number(r.delay_seconds||0),config_json:r.config_json||"{}"}})}}),$t=async()=>{const t=await v(l=>N.GET("/api/v1/automation-rules",{signal:l})),s=Ue(t,["data"Line truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{a as r,j as e}from"./react-vendor-l-BBvuKH.js";import{r as M,c as q}from"./index-CiBUw4Te.js";import{f as xe,R as ae,aa as ue,r as pe,z as T,F as D,ab as me,t as he,S as re,ac as le,ad as ge,o as ye}from"./icons-vendor-Bgrth_9N.js";import"./vendor-cRYyTeIw.js";const ne="https://dashscope.aliyuncs.com/compatible-mode/v1",fe=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],be=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"]),oe=new Set(["ai_api_key","smtp_password","qq_reply_secret_key","captcha.remote_secret_key"]),we=s=>{if("values"in s||"secrets"in s)return s;const a={},n={};for(const[d,x]of Object.entries(s))if(x!=null){if(oe.has(d)){n[d]=x===""?{action:"clear"}:{action:"replace",value:String(x)};continue}(typeof x=="string"||typeof x=="number"||typeof x=="boolean")&&(a[d]=x)}return Object.keys(n).length>0?{values:a,secrets:n}:a},je=s=>{const a={...s};for(const n of oe){const d=`${n}_configured`;d in a&&(a[d]=a[d]===!0||a[d]==="true")}if("renewal_log_retention_days"in a){const n=Number(a.renewal_log_retention_days);a.renewal_log_retention_days=Number.isFinite(n)?n:10}return a},ve=async(s,a)=>M(n=>q.PUT("/api/v1/session/credentials",{body:s,signal:n}),a),_e=async s=>{const a=await M(n=>q.GET("/api/v1/settings/system",{signal:n}),s);return je(a)},Ne=async(s,a)=>M(n=>q.PUT("/api/v1/settings/system",{body:we(s),signal:n}),a),Se=async(s,a="",n)=>{const d=await M(x=>q.POST("/api/v1/settings/ai-models",{body:{base_url:s,api_key:a},signal:x}),n);return Array.isArray(d.models)?d.models:[]},ke=async s=>M(a=>q.GET("/api/v1/session",{signal:a}),s),Ce=s=>Object.fromEntries(Object.entries(s).filter(([a,n])=>!be.has(a)&&n!==void 0&&n!==null)),Ee=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?"两次输入的新密码不一致":"":"请输入当前密码确认身份",f=(s,a,n)=>s===a&&!n.aborted,K=s=>s instanceof Error&&s.message==="请求已取消",U=(s,a)=>s instanceof Error?s.message:a,Ae=(s="")=>({new_username:s,current_password:"",new_password:"",confirm_password:""}),$=(s,a)=>({type:s,text:a}),Ie=()=>{const[s,a]=r.useState(null),[n,d]=r.useState(!1),[x,m]=r.useState(""),[S,A]=r.useState(!1),[R,k]=r.useState(""),[C,w]=r.useState([]),[j,I]=r.useState(!1),[P,u]=r.useState(""),[z,v]=r.useState(!1),[G,L]=r.useState(!1),[F,p]=r.useState(!1),[b,V]=r.useState(!1),[Y,J]=r.useState(!1),[W,_]=r.useState(!1),[O,y]=r.useState(null),[t,ee]=r.useState(()=>Ae()),[ce,B]=r.useState("idle"),se=r.useRef(null),te=r.useRef(null),h=r.useRef(0),H=r.useRef(null);te.current=s;const E=r.useCallback(()=>{var c;(c=H.current)==null||c.abort();const o=new AbortController;return H.current=o,h.current+=1,{controller:o,sequence:h.current}},[]),Q=r.useCallback(async(o,c=!1,l)=>{const i=o||te.current,g=(i==null?void 0:i.ai_api_url)||(i==null?void 0:i.ai_base_url)||ne;I(!0),u("");try{const N=await Se(g,(i==null?void 0:i.ai_api_key)||"",{signal:l});if(l!=null&&l.aborted)return;w(N),v(c&&N.length>0),!(i!=null&&i.ai_model)&&N.length>0&&a(Z=>Z&&{...Z,ai_model:N[0]})}catch(N){if(l!=null&&l.aborted||K(N))return;w([]),v(!1),u(U(N,"读取模型失败"))}finally{l!=null&&l.aborted||I(!1)}},[]),X=r.useCallback(()=>{const{controller:o,sequence:c}=E();d(!0),B("loading"),m(""),Promise.all([_e({signal:o.signal}),ke({signal:o.signal})]).then(([l,i])=>{f(h.current,c,o.signal)&&(a(l),i.username&&ee(g=>({...g,new_username:i.username||""})),Q(l,!1,o.signal),B("success"))}).catch(l=>{!f(h.current,c,o.signal)||K(l)||(a(null),m(U(l,"加载配置失败")),B("error"))}).finally(()=>{f(h.current,c,o.signal)&&d(!1)})},[E,Q]);r.useEffect(()=>(X(),(()=>{var o;return(o=H.current)==null?void 0:o.abort()})),[X]),r.useEffect(()=>{const o=c=>{var l;(l=se.current)!=null&&l.contains(c.target)||v(!1)};return document.addEventListener("mousedown",o),(()=>document.removeEventListener("mousedown",o))},[]);const ie=r.useCallback(async()=>{if(!s||S)return;const{controller:o,sequence:c}=E();A(!0),k("");try{if(await Ne(Ce(s),{signal:o.signal}),!f(h.current,c,o.signal))return;window.alert("系统配置已保存")}catch(l){if(!f(h.current,c,o.signal)||K(l))return;k(U(l,"保存配置失败"))}finally{f(h.current,c,o.signal)&&A(!1)}},[E,S,s]),de=r.useCallback(async o=>{o.preventDefault(),y(null);const c=Ee(t);if(c){y($("error",c));return}const{controller:l,sequence:i}=E();_(!0);try{const g=await ve({current_password:t.current_password,new_username:t.new_username.trim(),new_password:t.new_password||void 0},{signal:l.signal});if(!f(h.currentLine truncated
|
||||
import{a as r,j as e}from"./react-vendor-l-BBvuKH.js";import{r as M,c as q}from"./index-DawJY7_a.js";import{f as xe,R as ae,aa as ue,r as pe,z as T,F as D,ab as me,t as he,S as re,ac as le,ad as ge,o as ye}from"./icons-vendor-CIGXYOCp.js";import"./vendor-cRYyTeIw.js";const ne="https://dashscope.aliyuncs.com/compatible-mode/v1",fe=[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}],be=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"]),oe=new Set(["ai_api_key","smtp_password","qq_reply_secret_key","captcha.remote_secret_key"]),we=s=>{if("values"in s||"secrets"in s)return s;const a={},n={};for(const[d,x]of Object.entries(s))if(x!=null){if(oe.has(d)){n[d]=x===""?{action:"clear"}:{action:"replace",value:String(x)};continue}(typeof x=="string"||typeof x=="number"||typeof x=="boolean")&&(a[d]=x)}return Object.keys(n).length>0?{values:a,secrets:n}:a},je=s=>{const a={...s};for(const n of oe){const d=`${n}_configured`;d in a&&(a[d]=a[d]===!0||a[d]==="true")}if("renewal_log_retention_days"in a){const n=Number(a.renewal_log_retention_days);a.renewal_log_retention_days=Number.isFinite(n)?n:10}return a},ve=async(s,a)=>M(n=>q.PUT("/api/v1/session/credentials",{body:s,signal:n}),a),_e=async s=>{const a=await M(n=>q.GET("/api/v1/settings/system",{signal:n}),s);return je(a)},Ne=async(s,a)=>M(n=>q.PUT("/api/v1/settings/system",{body:we(s),signal:n}),a),Se=async(s,a="",n)=>{const d=await M(x=>q.POST("/api/v1/settings/ai-models",{body:{base_url:s,api_key:a},signal:x}),n);return Array.isArray(d.models)?d.models:[]},ke=async s=>M(a=>q.GET("/api/v1/session",{signal:a}),s),Ce=s=>Object.fromEntries(Object.entries(s).filter(([a,n])=>!be.has(a)&&n!==void 0&&n!==null)),Ee=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?"两次输入的新密码不一致":"":"请输入当前密码确认身份",f=(s,a,n)=>s===a&&!n.aborted,K=s=>s instanceof Error&&s.message==="请求已取消",U=(s,a)=>s instanceof Error?s.message:a,Ae=(s="")=>({new_username:s,current_password:"",new_password:"",confirm_password:""}),$=(s,a)=>({type:s,text:a}),Ie=()=>{const[s,a]=r.useState(null),[n,d]=r.useState(!1),[x,m]=r.useState(""),[S,A]=r.useState(!1),[R,k]=r.useState(""),[C,w]=r.useState([]),[j,I]=r.useState(!1),[P,u]=r.useState(""),[z,v]=r.useState(!1),[G,L]=r.useState(!1),[F,p]=r.useState(!1),[b,V]=r.useState(!1),[Y,J]=r.useState(!1),[W,_]=r.useState(!1),[O,y]=r.useState(null),[t,ee]=r.useState(()=>Ae()),[ce,B]=r.useState("idle"),se=r.useRef(null),te=r.useRef(null),h=r.useRef(0),H=r.useRef(null);te.current=s;const E=r.useCallback(()=>{var c;(c=H.current)==null||c.abort();const o=new AbortController;return H.current=o,h.current+=1,{controller:o,sequence:h.current}},[]),Q=r.useCallback(async(o,c=!1,l)=>{const i=o||te.current,g=(i==null?void 0:i.ai_api_url)||(i==null?void 0:i.ai_base_url)||ne;I(!0),u("");try{const N=await Se(g,(i==null?void 0:i.ai_api_key)||"",{signal:l});if(l!=null&&l.aborted)return;w(N),v(c&&N.length>0),!(i!=null&&i.ai_model)&&N.length>0&&a(Z=>Z&&{...Z,ai_model:N[0]})}catch(N){if(l!=null&&l.aborted||K(N))return;w([]),v(!1),u(U(N,"读取模型失败"))}finally{l!=null&&l.aborted||I(!1)}},[]),X=r.useCallback(()=>{const{controller:o,sequence:c}=E();d(!0),B("loading"),m(""),Promise.all([_e({signal:o.signal}),ke({signal:o.signal})]).then(([l,i])=>{f(h.current,c,o.signal)&&(a(l),i.username&&ee(g=>({...g,new_username:i.username||""})),Q(l,!1,o.signal),B("success"))}).catch(l=>{!f(h.current,c,o.signal)||K(l)||(a(null),m(U(l,"加载配置失败")),B("error"))}).finally(()=>{f(h.current,c,o.signal)&&d(!1)})},[E,Q]);r.useEffect(()=>(X(),(()=>{var o;return(o=H.current)==null?void 0:o.abort()})),[X]),r.useEffect(()=>{const o=c=>{var l;(l=se.current)!=null&&l.contains(c.target)||v(!1)};return document.addEventListener("mousedown",o),(()=>document.removeEventListener("mousedown",o))},[]);const ie=r.useCallback(async()=>{if(!s||S)return;const{controller:o,sequence:c}=E();A(!0),k("");try{if(await Ne(Ce(s),{signal:o.signal}),!f(h.current,c,o.signal))return;window.alert("系统配置已保存")}catch(l){if(!f(h.current,c,o.signal)||K(l))return;k(U(l,"保存配置失败"))}finally{f(h.current,c,o.signal)&&A(!1)}},[E,S,s]),de=r.useCallback(async o=>{o.preventDefault(),y(null);const c=Ee(t);if(c){y($("error",c));return}const{controller:l,sequence:i}=E();_(!0);try{const g=await ve({current_password:t.current_password,new_username:t.new_username.trim(),new_password:t.new_password||void 0},{signal:l.signal});if(!f(h.currentLine truncated
|
||||
+84
-79
@@ -23,394 +23,399 @@ import{a as h}from"./react-vendor-l-BBvuKH.js";/**
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const g=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],O1=e("activity",g);/**
|
||||
*/const g=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Z1=e("activity",g);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Z1=e("arrow-right",u);/**
|
||||
*/const u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],K1=e("arrow-right",u);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const $=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],K1=e("bell",$);/**
|
||||
*/const $=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],G1=e("bell",$);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const N=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],G1=e("bot",N);/**
|
||||
*/const N=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Q1=e("bot",N);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const f=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Q1=e("box",f);/**
|
||||
*/const f=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],J1=e("box",f);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const w=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],J1=e("calendar-clock",w);/**
|
||||
*/const w=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],X1=e("calendar-clock",w);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const z=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],X1=e("check-check",z);/**
|
||||
*/const z=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],Y1=e("check-check",z);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const b=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Y1=e("check",b);/**
|
||||
*/const b=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],e2=e("check",b);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const q=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],e2=e("chevron-down",q);/**
|
||||
*/const q=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],a2=e("chevron-down",q);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const C=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],a2=e("chevron-left",C);/**
|
||||
*/const C=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],t2=e("chevron-left",C);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const j=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],t2=e("chevron-right",j);/**
|
||||
*/const j=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],c2=e("chevron-right",j);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],c2=e("circle-alert",A);/**
|
||||
*/const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],o2=e("circle-alert",A);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const H=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],o2=e("circle-check",H);/**
|
||||
*/const H=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],y2=e("circle-check",H);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const V=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],y2=e("circle-dashed",V);/**
|
||||
*/const V=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],h2=e("circle-dashed",V);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const L=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],h2=e("clock-3",L);/**
|
||||
*/const L=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]],s2=e("circle-dollar-sign",L);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const P=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],s2=e("clock",P);/**
|
||||
*/const S=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],d2=e("clock-3",S);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const S=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],d2=e("cloud-upload",S);/**
|
||||
*/const P=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],n2=e("clock",P);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const U=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],n2=e("code",U);/**
|
||||
*/const U=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],k2=e("cloud-upload",U);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const E=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],k2=e("copy",E);/**
|
||||
*/const D=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],i2=e("code",D);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const B=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],i2=e("credit-card",B);/**
|
||||
*/const E=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],p2=e("copy",E);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const D=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],p2=e("database",D);/**
|
||||
*/const B=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],r2=e("credit-card",B);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const R=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],r2=e("dollar-sign",R);/**
|
||||
*/const R=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],l2=e("database",R);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const T=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],l2=e("external-link",T);/**
|
||||
*/const T=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],M2=e("dollar-sign",T);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const W=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],M2=e("eye-off",W);/**
|
||||
*/const W=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],_2=e("external-link",W);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const F=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_2=e("eye",F);/**
|
||||
*/const F=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],x2=e("eye-off",F);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const I=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],x2=e("file-down",I);/**
|
||||
*/const I=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],v2=e("eye",I);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const O=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],v2=e("file-text",O);/**
|
||||
*/const O=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],m2=e("file-down",O);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const Z=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],m2=e("funnel",Z);/**
|
||||
*/const Z=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],g2=e("file-text",Z);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const K=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],g2=e("gift",K);/**
|
||||
*/const K=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],u2=e("funnel",K);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const G=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],u2=e("git-commit-horizontal",G);/**
|
||||
*/const G=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],$2=e("gift",G);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const Q=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],$2=e("image-plus",Q);/**
|
||||
*/const Q=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],N2=e("git-commit-horizontal",Q);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const J=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],N2=e("image",J);/**
|
||||
*/const J=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],f2=e("image-plus",J);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const X=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],f2=e("key",X);/**
|
||||
*/const X=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],w2=e("image",X);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const Y=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],w2=e("layers",Y);/**
|
||||
*/const Y=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],z2=e("key",Y);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const e1=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],z2=e("layout-dashboard",e1);/**
|
||||
*/const e1=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],b2=e("layers",e1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const a1=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],b2=e("link-2",a1);/**
|
||||
*/const a1=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],q2=e("layout-dashboard",a1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const t1=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],q2=e("list-plus",t1);/**
|
||||
*/const t1=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],C2=e("link-2",t1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const c1=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],C2=e("loader-circle",c1);/**
|
||||
*/const c1=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],j2=e("list-plus",c1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const o1=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],j2=e("locate-fixed",o1);/**
|
||||
*/const o1=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],A2=e("loader-circle",o1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const y1=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],A2=e("lock-keyhole",y1);/**
|
||||
*/const y1=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],H2=e("locate-fixed",y1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const h1=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],H2=e("lock",h1);/**
|
||||
*/const h1=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],V2=e("lock-keyhole",h1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const s1=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],V2=e("log-out",s1);/**
|
||||
*/const s1=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],L2=e("lock",s1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const d1=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],L2=e("mail",d1);/**
|
||||
*/const d1=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],S2=e("log-out",d1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const n1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]],P2=e("message-circle-more",n1);/**
|
||||
*/const n1=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],P2=e("mail",n1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const k1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],S2=e("message-circle",k1);/**
|
||||
*/const k1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]],U2=e("message-circle-more",k1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const i1=[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]],U2=e("message-square-quote",i1);/**
|
||||
*/const i1=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],D2=e("message-circle",i1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const p1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],E2=e("package-check",p1);/**
|
||||
*/const p1=[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]],E2=e("message-square-quote",p1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const r1=[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],B2=e("package-plus",r1);/**
|
||||
*/const r1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],B2=e("package-check",r1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const l1=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],D2=e("package",l1);/**
|
||||
*/const l1=[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],R2=e("package-plus",l1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const M1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],R2=e("pen",M1);/**
|
||||
*/const M1=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],T2=e("package",M1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const _1=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],T2=e("play",_1);/**
|
||||
*/const _1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],W2=e("pen",_1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const x1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],W2=e("plus",x1);/**
|
||||
*/const x1=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],F2=e("play",x1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const v1=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],F2=e("power",v1);/**
|
||||
*/const v1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],I2=e("plus",v1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const m1=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],I2=e("qr-code",m1);/**
|
||||
*/const m1=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],O2=e("power",m1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const g1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],O2=e("refresh-cw",g1);/**
|
||||
*/const g1=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Z2=e("qr-code",g1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const u1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Z2=e("save",u1);/**
|
||||
*/const u1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],K2=e("refresh-cw",u1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const $1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],K2=e("search",$1);/**
|
||||
*/const $1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],G2=e("save",$1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const N1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],G2=e("send",N1);/**
|
||||
*/const N1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Q2=e("search",N1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const f1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Q2=e("settings",f1);/**
|
||||
*/const f1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],J2=e("send",f1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const w1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],J2=e("shield-check",w1);/**
|
||||
*/const w1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],X2=e("settings",w1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const z1=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],X2=e("shopping-bag",z1);/**
|
||||
*/const z1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Y2=e("shield-check",z1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const b1=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],Y2=e("shopping-cart",b1);/**
|
||||
*/const b1=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],e0=e("shopping-bag",b1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const q1=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],e0=e("sliders-horizontal",q1);/**
|
||||
*/const q1=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],a0=e("shopping-cart",q1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const C1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],a0=e("smile",C1);/**
|
||||
*/const C1=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],t0=e("sliders-horizontal",C1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const j1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],t0=e("sparkles",j1);/**
|
||||
*/const j1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],c0=e("smile",j1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const A1=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],c0=e("square-pen",A1);/**
|
||||
*/const A1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],o0=e("sparkles",A1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const H1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],o0=e("trash-2",H1);/**
|
||||
*/const H1=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],y0=e("square-pen",H1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const V1=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],y0=e("trending-up",V1);/**
|
||||
*/const V1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],h0=e("trash-2",V1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const L1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],h0=e("triangle-alert",L1);/**
|
||||
*/const L1=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],s0=e("trending-up",L1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const P1=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]],s0=e("truck",P1);/**
|
||||
*/const S1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],d0=e("triangle-alert",S1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const S1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],d0=e("upload",S1);/**
|
||||
*/const P1=[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]],n0=e("truck",P1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const U1=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],n0=e("user-round",U1);/**
|
||||
*/const U1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],k0=e("upload",U1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const E1=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],k0=e("user",E1);/**
|
||||
*/const D1=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],i0=e("user-round",D1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const B1=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],i0=e("users",B1);/**
|
||||
*/const E1=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],p0=e("user",E1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const D1=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],p0=e("webhook",D1);/**
|
||||
*/const B1=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],r0=e("users",B1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const R1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],r0=e("wifi-off",R1);/**
|
||||
*/const R1=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],l0=e("webhook",R1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const T1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],l0=e("wifi",T1);/**
|
||||
*/const T1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],M0=e("wifi-off",T1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const W1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],M0=e("x",W1);/**
|
||||
*/const W1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],_0=e("wifi",W1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const F1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],_0=e("zap",F1);export{N2 as $,Z1 as A,Q1 as B,i2 as C,r2 as D,l2 as E,_2 as F,u2 as G,h0 as H,K2 as I,d0 as J,f2 as K,C2 as L,P2 as M,W2 as N,s0 as O,D2 as P,I2 as Q,O2 as R,J2 as S,y0 as T,k0 as U,c0 as V,q2 as W,M0 as X,x2 as Y,_0 as Z,n2 as _,H2 as a,v2 as a0,e0 as a1,k2 as a2,m2 as a3,B2 as a4,d2 as a5,o2 as a6,y2 as a7,b2 as a8,j2 as a9,p2 as aa,e2 as ab,A2 as ac,n0 as ad,h2 as ae,g2 as af,w2 as ag,G2 as ah,L2 as ai,p0 as aj,l0 as ak,r0 as al,X1 as am,a0 as an,$2 as ao,z2 as b,i0 as c,X2 as d,K1 as e,Q2 as f,t2 as g,a2 as h,V2 as i,Y2 as j,c2 as k,O1 as l,E2 as m,G1 as n,Z2 as o,U2 as p,T2 as q,t0 as r,J1 as s,Y1 as t,S2 as u,s2 as v,R2 as w,F2 as x,o0 as y,M2 as z};
|
||||
*/const F1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],x0=e("x",F1);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const I1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],v0=e("zap",I1);export{w2 as $,K1 as A,J1 as B,r2 as C,M2 as D,_2 as E,v2 as F,N2 as G,d0 as H,Q2 as I,k0 as J,z2 as K,A2 as L,U2 as M,I2 as N,n0 as O,T2 as P,Z2 as Q,K2 as R,Y2 as S,s0 as T,p0 as U,y0 as V,j2 as W,x0 as X,m2 as Y,v0 as Z,i2 as _,L2 as a,g2 as a0,t0 as a1,p2 as a2,u2 as a3,R2 as a4,k2 as a5,y2 as a6,h2 as a7,C2 as a8,H2 as a9,l2 as aa,a2 as ab,V2 as ac,i0 as ad,d2 as ae,$2 as af,s2 as ag,b2 as ah,J2 as ai,P2 as aj,l0 as ak,_0 as al,M0 as am,Y1 as an,c0 as ao,f2 as ap,q2 as b,r0 as c,e0 as d,G1 as e,X2 as f,c2 as g,t2 as h,S2 as i,a0 as j,o2 as k,Z1 as l,B2 as m,Q1 as n,G2 as o,E2 as p,F2 as q,o0 as r,X1 as s,e2 as t,D2 as u,n2 as v,W2 as w,O2 as x,h0 as y,x2 as z};
|
||||
@@ -1 +0,0 @@
|
||||
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--color-neutral-200) / 1)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:6Line truncated
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-CJrI6NVV.js","assets/react-vendor-l-BBvuKH.js","assets/dateTime-DDi7rqpW.js","assets/icons-vendor-Bgrth_9N.js","assets/charts-vendor-DlHaeEQJ.js","assets/vendor-cRYyTeIw.js","assets/vendor-DUblxfbA.css","assets/contract-COFcZjyb.js","assets/AccountList-DX3reM6l.js","assets/OrderList-B4B8_a2q.js","assets/CardList-DDZ2JnUG.js","assets/ItemList-C0hxXhgx.js","assets/Settings-CQ_-2bDk.js","assets/Rules-CMO3kj4s.js","assets/Notifications-BCUsqoS1.js","assets/Chat-QumIYKUd.js"])))=>i.map(i=>d[i]);
|
||||
import{c as I,j as t,a as l,d as K}from"./react-vendor-l-BBvuKH.js";import{o as W}from"./vendor-cRYyTeIw.js";import{L as z,a as P,S as J,U as Q,A as X,b as ee,c as te,M as se,C as ne,B as re,d as ae,Z as oe,e as ie,f as ce,G as R,g as le,h as de,i as ue}from"./icons-vendor-Bgrth_9N.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const c of r)if(c.type==="childList")for(const o of c.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function s(r){const c={};return r.integrity&&(c.integrity=r.integrity),r.referrerPolicy&&(c.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?c.credentials="include":r.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(r){if(r.ep)return;r.ep=!0;const c=s(r);fetch(r.href,c)}})();class he extends I.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleReload=()=>{window.location.reload()}}static getDerivedStateFromError(){return{hasError:!0}}render(){const{hasError:n}=this.state,{children:s}=this.props;return n?t.jsx("main",{className:"flex min-h-screen items-center justify-center bg-canvas p-6 text-ink",children:t.jsxs("section",{className:"max-w-md text-center",children:[t.jsx("h1",{className:"text-xl font-semibold",children:"页面暂时无法显示"}),t.jsx("button",{className:"ios-btn-primary mt-6 px-4 py-2",type:"button",onClick:this.handleReload,children:"重新加载"})]})}):s}}let _=!1;class O extends Error{constructor(n,s){super(pe(s,n)),this.name="ApiError",this.status=n,this.code=N(s)?s.code:`http_${n}`,this.requestId=N(s)?s.request_id:void 0,this.request_id=this.requestId,this.details=N(s)?s.details:void 0,this.payload=s}}const me=()=>{_||typeof window>"u"||(_=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{_=!1}))},fe=(e,n)=>{const s=new AbortController,a=()=>s.abort(e==null?void 0:e.reason);e!=null&&e.aborted?a():e==null||e.addEventListener("abort",a,{once:!0});const r=globalThis.setTimeout(()=>s.abort(new DOMException("timeout","TimeoutError")),Math.max(1,n));return{signal:s.signal,cleanup:()=>{globalThis.clearTimeout(r),e==null||e.removeEventListener("abort",a)}}},N=e=>{if(typeof e!="object"||e===null)return!1;const n=e;return typeof n.code=="string"&&typeof n.message=="string"},pe=(e,n)=>typeof e=="string"?e:N(e)?e.message:`请求失败: ${n}`,xe=3e4,ge=async(e,n)=>{const s=new URL(typeof e=="string"?e:e instanceof URL?e.toString():e.url),a=e instanceof Request?e:new Request(e,n),r=a.headers.get("content-type")||"",c=a.method==="GET"||a.method==="HEAD"?void 0:r.includes("multipart/form-data")?await a.clone().formData():await a.clone().text(),o=s.origin==="http://localhost"?`${s.pathname}${s.search}`:e;return await fetch(o,{method:a.method,headers:a.headers,body:c,signal:a.signal,credentials:"include"})},be=typeof location>"u"?"http://localhost":location.origin,v=W({baseUrl:be,fetch:ge});function nt(e){return e}async function w(e,n={}){var a;const s=fe(n.signal,n.timeoutMs??xe);try{const r=await e(s.signal);if(r.response.status===401&&!n.skipAuthLogout&&me(),r.error!==void 0)throw new O(r.response.status,r.error);if(r.data===void 0)throw new O(r.response.status,void 0);return r.data}catch(r){throw s.signal.aborted?new Error((a=n.signal)!=null&&a.aborted?"请求已取消":"请求超时,请稍后重试"):r}finally{s.cleanup()}}const ve=async e=>{const n=await w(s=>v.POST("/api/v1/session/login",{body:e,signal:s}),{skipAuthLogout:!0});return{...n,token:n.token??void 0}},we=async e=>{const n=await w(s=>v.POST("/api/v1/session/initialize",{body:{password:e},signal:s}),{skipAuthLogout:!0});return{...n,token:n.token??void 0}},ye=async e=>w(n=>v.GET("/api/v1/session",{signal:n}),e),Le=async()=>({success:!0,message:(await w(n=>v.POST("/api/v1/session/logout",{body:{},signal:n}))).message}),U=l.createContext(void 0),je=({children:e})=>{const[n,s]=l.useState(!1),[a,r]=l.useState(!1),[c,o]=l.useState(!0),[i,u]=l.useState(!1),d=()=>{s(!1),r(!1)};l.useEffect(()=>{const x=new AbortController;let p=!0;ye({signal:x.signal}).then(b=>{if(p){if((b==null?void 0:b.initialized)===!1){u(!0),d();return}u(!1),b!=null&&b.authenticated?(s(!0),r(b.is_admin===!0)):d()}}).catch(b=>{!p||b instanceof DOMException&&b.name==="AbortError"||(u(!1),d())}).finally(()=>{p&&o(!1)});const h=()=>d();return window.addEventListener("auth:logout",h),(()=>{p=!1,x.abort(),window.removeEventListener("auth:logout",h)})},[]);const m=async x=>{const p=await ve(x);return p.success&&(u(!1),s(!0),r(p.is_admin===!0)),p},g=async x=>{const p=await we(x);return p.success&&(u(!1),s(!0),r(p.is_admin===!0)),p},f=async()=>{try{await Le()}finally{d()}};return t.jsx(U.Provider,{value:{checkingAuth:c,isLoggedIn:n,isAdmin:a,needsInit:i,signIn:m,initialize:g,signOut:f},children:e})},q=()=>{const e=l.useCoLine truncated
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-COZgQmUP.js","assets/react-vendor-l-BBvuKH.js","assets/dateTime-DDi7rqpW.js","assets/icons-vendor-CIGXYOCp.js","assets/charts-vendor-DlHaeEQJ.js","assets/vendor-cRYyTeIw.js","assets/vendor-DUblxfbA.css","assets/contract-COFcZjyb.js","assets/AccountList-CJjq4Hao.js","assets/OrderList-CIcqa_PS.js","assets/CardList-DmAKXVzi.js","assets/ItemList-BLPsnCuG.js","assets/Settings-BsnTwWjn.js","assets/Rules-B7fgxH9m.js","assets/Notifications-D90C7V4V.js","assets/Chat-B0sXFnFc.js"])))=>i.map(i=>d[i]);
|
||||
import{c as I,j as t,a as l,d as K}from"./react-vendor-l-BBvuKH.js";import{o as W}from"./vendor-cRYyTeIw.js";import{L as z,a as P,S as J,U as Q,A as X,b as ee,c as te,M as se,C as ne,B as re,d as ae,Z as oe,e as ie,f as ce,G as R,g as le,h as de,i as ue}from"./icons-vendor-CIGXYOCp.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const c of r)if(c.type==="childList")for(const o of c.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function s(r){const c={};return r.integrity&&(c.integrity=r.integrity),r.referrerPolicy&&(c.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?c.credentials="include":r.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(r){if(r.ep)return;r.ep=!0;const c=s(r);fetch(r.href,c)}})();class he extends I.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleReload=()=>{window.location.reload()}}static getDerivedStateFromError(){return{hasError:!0}}render(){const{hasError:n}=this.state,{children:s}=this.props;return n?t.jsx("main",{className:"flex min-h-screen items-center justify-center bg-canvas p-6 text-ink",children:t.jsxs("section",{className:"max-w-md text-center",children:[t.jsx("h1",{className:"text-xl font-semibold",children:"页面暂时无法显示"}),t.jsx("button",{className:"ios-btn-primary mt-6 px-4 py-2",type:"button",onClick:this.handleReload,children:"重新加载"})]})}):s}}let _=!1;class O extends Error{constructor(n,s){super(pe(s,n)),this.name="ApiError",this.status=n,this.code=N(s)?s.code:`http_${n}`,this.requestId=N(s)?s.request_id:void 0,this.request_id=this.requestId,this.details=N(s)?s.details:void 0,this.payload=s}}const me=()=>{_||typeof window>"u"||(_=!0,window.dispatchEvent(new Event("auth:logout")),queueMicrotask(()=>{_=!1}))},fe=(e,n)=>{const s=new AbortController,a=()=>s.abort(e==null?void 0:e.reason);e!=null&&e.aborted?a():e==null||e.addEventListener("abort",a,{once:!0});const r=globalThis.setTimeout(()=>s.abort(new DOMException("timeout","TimeoutError")),Math.max(1,n));return{signal:s.signal,cleanup:()=>{globalThis.clearTimeout(r),e==null||e.removeEventListener("abort",a)}}},N=e=>{if(typeof e!="object"||e===null)return!1;const n=e;return typeof n.code=="string"&&typeof n.message=="string"},pe=(e,n)=>typeof e=="string"?e:N(e)?e.message:`请求失败: ${n}`,xe=3e4,ge=async(e,n)=>{const s=new URL(typeof e=="string"?e:e instanceof URL?e.toString():e.url),a=e instanceof Request?e:new Request(e,n),r=a.headers.get("content-type")||"",c=a.method==="GET"||a.method==="HEAD"?void 0:r.includes("multipart/form-data")?await a.clone().formData():await a.clone().text(),o=s.origin==="http://localhost"?`${s.pathname}${s.search}`:e;return await fetch(o,{method:a.method,headers:a.headers,body:c,signal:a.signal,credentials:"include"})},be=typeof location>"u"?"http://localhost":location.origin,v=W({baseUrl:be,fetch:ge});function nt(e){return e}async function w(e,n={}){var a;const s=fe(n.signal,n.timeoutMs??xe);try{const r=await e(s.signal);if(r.response.status===401&&!n.skipAuthLogout&&me(),r.error!==void 0)throw new O(r.response.status,r.error);if(r.data===void 0)throw new O(r.response.status,void 0);return r.data}catch(r){throw s.signal.aborted?new Error((a=n.signal)!=null&&a.aborted?"请求已取消":"请求超时,请稍后重试"):r}finally{s.cleanup()}}const ve=async e=>{const n=await w(s=>v.POST("/api/v1/session/login",{body:e,signal:s}),{skipAuthLogout:!0});return{...n,token:n.token??void 0}},we=async e=>{const n=await w(s=>v.POST("/api/v1/session/initialize",{body:{password:e},signal:s}),{skipAuthLogout:!0});return{...n,token:n.token??void 0}},ye=async e=>w(n=>v.GET("/api/v1/session",{signal:n}),e),Le=async()=>({success:!0,message:(await w(n=>v.POST("/api/v1/session/logout",{body:{},signal:n}))).message}),U=l.createContext(void 0),je=({children:e})=>{const[n,s]=l.useState(!1),[a,r]=l.useState(!1),[c,o]=l.useState(!0),[i,u]=l.useState(!1),d=()=>{s(!1),r(!1)};l.useEffect(()=>{const x=new AbortController;let p=!0;ye({signal:x.signal}).then(b=>{if(p){if((b==null?void 0:b.initialized)===!1){u(!0),d();return}u(!1),b!=null&&b.authenticated?(s(!0),r(b.is_admin===!0)):d()}}).catch(b=>{!p||b instanceof DOMException&&b.name==="AbortError"||(u(!1),d())}).finally(()=>{p&&o(!1)});const h=()=>d();return window.addEventListener("auth:logout",h),(()=>{p=!1,x.abort(),window.removeEventListener("auth:logout",h)})},[]);const m=async x=>{const p=await ve(x);return p.success&&(u(!1),s(!0),r(p.is_admin===!0)),p},g=async x=>{const p=await we(x);return p.success&&(u(!1),s(!0),r(p.is_admin===!0)),p},f=async()=>{try{await Le()}finally{d()}};return t.jsx(U.Provider,{value:{checkingAuth:c,isLoggedIn:n,isAdmin:a,needsInit:i,signIn:m,initialize:g,signOut:f},children:e})},q=()=>{const e=l.useCoLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(147 197 253 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--color-neutral-200) / 1)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}input::placeholder,textarea::placeholder{opacity:1;color:rgb(var(--color-neutral-400) / 1)}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:6Line truncated
|
||||
@@ -6,12 +6,12 @@
|
||||
<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-CiBUw4Te.js"></script>
|
||||
<script type="module" crossorigin src="/static/assets/index-DawJY7_a.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/react-vendor-l-BBvuKH.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/vendor-cRYyTeIw.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-Bgrth_9N.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-CIGXYOCp.js">
|
||||
<link rel="stylesheet" crossorigin href="/static/assets/vendor-DUblxfbA.css">
|
||||
<link rel="stylesheet" crossorigin href="/static/assets/index-D5pYdG6n.css">
|
||||
<link rel="stylesheet" crossorigin href="/static/assets/index-mo8bfmYY.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
// Package mtop: 订单改价域 — mtop.taobao.idle.trade.user.adjust.price 调用与重试。
|
||||
package mtop
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"xianyu-go/internal/xianyu/protocol"
|
||||
)
|
||||
|
||||
// AdjustPriceAPI 是卖家对待付款订单改价的 MTOP 端点。
|
||||
const AdjustPriceAPI = "https://h5api.m.goofish.com/h5/mtop.taobao.idle.trade.user.adjust.price/1.0/"
|
||||
|
||||
// adjustPricePayload 是订单改价接口要求的 JSON 请求体,避免订单号直接拼接进 JSON 而破坏签名原文。
|
||||
type adjustPricePayload struct {
|
||||
// ModifyFee 是改价后的订单总价,单位为分。
|
||||
ModifyFee int64 `json:"modifyFee"`
|
||||
// NewTransportFee 是改价后运费;当前自动化规则固定免运费。
|
||||
NewTransportFee string `json:"newTransportFee"`
|
||||
// OrderID 是待付款订单的闲鱼订单标识。
|
||||
OrderID string `json:"orderId"`
|
||||
}
|
||||
|
||||
// AdjustOrderPriceContext 调用 mtop.taobao.idle.trade.user.adjust.price 修改待付款订单价格。
|
||||
// priceCents 是改价后的订单总价,单位为分;平台只接受买家尚未付款的订单。
|
||||
// 签名 token 过期时使用响应下发的新 Cookie 重签并重试,与确认发货保持同一恢复策略。
|
||||
func (c *ClientImpl) AdjustOrderPriceContext(ctx context.Context, cookiesStr, orderID string, priceCents int64) (ok bool, ret []string, updatedCookies string, err error) {
|
||||
// currentCookies 是本轮请求实际使用的扁平 Cookie,优先取上下文中的会话状态。
|
||||
currentCookies := cookiesStr
|
||||
if // session 是上下文携带的响应 Cookie 会话,存在时以其合并状态为准。
|
||||
session := cookieSessionFromContext(ctx); session != nil {
|
||||
currentCookies, _, _ = session.State()
|
||||
}
|
||||
// lastRet 保存最后一次业务返回,供重试耗尽后回传调用方。
|
||||
var lastRet []string
|
||||
for // attempt 是含首次在内的 token 重签尝试序号。
|
||||
attempt := 0; attempt < 4; attempt++ {
|
||||
// previousCookies 记录本次请求前的 Cookie,用于判断响应是否下发了新 token。
|
||||
previousCookies := currentCookies
|
||||
// ok、ret、updated、requestErr 分别是单次调用的业务成功标志、业务返回、Cookie 更新和传输错误。
|
||||
ok, ret, updated, requestErr := c.adjustOrderPriceOnce(ctx, currentCookies, orderID, priceCents)
|
||||
if requestErr != nil {
|
||||
return false, ret, currentCookies, requestErr
|
||||
}
|
||||
lastRet = ret
|
||||
if updated != "" {
|
||||
currentCookies = updated
|
||||
}
|
||||
if ok {
|
||||
return true, ret, currentCookies, nil
|
||||
}
|
||||
if isSessionExpiredRet(ret) {
|
||||
return false, ret, currentCookies, sessionExpiredError("订单改价接口", ret)
|
||||
}
|
||||
if !isTokenExpiredRet(ret) {
|
||||
return false, ret, currentCookies, nil
|
||||
}
|
||||
if attempt == 3 {
|
||||
break
|
||||
}
|
||||
|
||||
// MTop 通常会在 token 过期响应中通过 Set-Cookie 下发新签名 token;
|
||||
// 未下发时主动刷新一次 token 再重试。
|
||||
if currentCookies == previousCookies {
|
||||
// refreshed、refreshErr 分别是 token 主动刷新结果和刷新失败原因。
|
||||
refreshed, refreshErr := c.RefreshTokenContext(ctx, currentCookies)
|
||||
if refreshErr != nil {
|
||||
return false, ret, currentCookies, fmt.Errorf("订单改价 token 过期且刷新失败: %w", refreshErr)
|
||||
}
|
||||
if refreshed.UpdatedCookies != "" {
|
||||
currentCookies = refreshed.UpdatedCookies
|
||||
}
|
||||
}
|
||||
if // err 是重试间隔等待期间的上下文取消错误。
|
||||
err := sleepCtx(ctx, MTopRetryGap); err != nil {
|
||||
return false, ret, currentCookies, err
|
||||
}
|
||||
}
|
||||
return false, lastRet, currentCookies, nil
|
||||
}
|
||||
|
||||
// adjustOrderPriceOnce 执行一次订单改价请求;业务成功要求 ret 为 SUCCESS 且 data.success 为 true。
|
||||
func (c *ClientImpl) adjustOrderPriceOnce(ctx context.Context, cookiesStr, orderID string, priceCents int64) (ok bool, ret []string, updatedCookies string, err error) {
|
||||
// hc 是带统一日志的 HTTP 客户端。
|
||||
hc := c.httpClient()
|
||||
// adjustURL 是实际请求端点,测试可通过 AdjustPriceURL 覆盖。
|
||||
adjustURL := c.AdjustPriceURL
|
||||
if adjustURL == "" {
|
||||
adjustURL = AdjustPriceAPI
|
||||
}
|
||||
// signingCookies、requestCookies 分别是参与签名的 Cookie 和随请求发送的 Cookie。
|
||||
signingCookies, requestCookies := mtopRequestCookies(ctx, cookiesStr, "https://www.goofish.com/", adjustURL)
|
||||
// token 是从 Cookie 提取的 MTOP 签名 token。
|
||||
token := protocol.SignToken(signingCookies)
|
||||
// t 是签名使用的毫秒时间戳。
|
||||
t := strconv.FormatInt(time.Now().UnixMilli(), 10)
|
||||
// payload 是订单改价请求的结构化参数,序列化结果同时作为签名原文和 HTTP 请求体。
|
||||
payload := adjustPricePayload{ModifyFee: priceCents, NewTransportFee: "0", OrderID: orderID}
|
||||
// dataBytes、marshalErr 分别是序列化后的请求原文和理论上仅可能由未来字段变更引入的错误。
|
||||
dataBytes, marshalErr := json.Marshal(payload)
|
||||
if marshalErr != nil {
|
||||
return false, nil, cookiesStr, fmt.Errorf("序列化订单改价请求: %w", marshalErr)
|
||||
}
|
||||
// dataVal 是改价请求体:modifyFee 为整数分,运费固定为 0。
|
||||
dataVal := string(dataBytes)
|
||||
// sign 是本次请求的 MTOP 签名。
|
||||
sign := protocol.GenerateSign(t, token, dataVal)
|
||||
|
||||
// query 是改价请求的 URL 查询参数。
|
||||
query := buildAdjustPriceQuery(t, sign)
|
||||
// body 是 URL 编码后的请求体。
|
||||
body := "data=" + url.QueryEscape(dataVal)
|
||||
// req、err 分别是构造的 HTTP 请求和构造错误。
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost,
|
||||
adjustURL+"?"+query,
|
||||
strings.NewReader(body))
|
||||
if err != nil {
|
||||
return false, nil, cookiesStr, err
|
||||
}
|
||||
setCommonHeaders(req, requestCookies)
|
||||
// resp、err 分别是 HTTP 响应和传输错误。
|
||||
resp, err := hc.Do(req)
|
||||
if err != nil {
|
||||
return false, nil, cookiesStr, fmt.Errorf("订单改价请求失败: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
// updated 是合并响应 Set-Cookie 后的最新扁平 Cookie。
|
||||
updated := absorbMTopResponseCookies(ctx, cookiesStr, resp)
|
||||
// raw、err 分别是响应正文和读取错误。
|
||||
raw, err := readMTopBody(resp)
|
||||
if err != nil {
|
||||
return false, nil, updated, err
|
||||
}
|
||||
// res 是改价响应的最小解析结构;data.success 是平台的业务成功标志。
|
||||
var res struct {
|
||||
Ret []string `json:"ret"`
|
||||
Data struct {
|
||||
Success bool `json:"success"`
|
||||
} `json:"data"`
|
||||
}
|
||||
if // err 是响应 JSON 解析错误。
|
||||
err := json.Unmarshal(raw, &res); err != nil {
|
||||
return false, nil, updated, fmt.Errorf("解析订单改价响应失败: %w (body=%s)", err, truncate(string(raw), 300))
|
||||
}
|
||||
if hasMTopSuccess(res.Ret) && res.Data.Success {
|
||||
return true, res.Ret, updated, nil
|
||||
}
|
||||
return false, res.Ret, updated, nil
|
||||
}
|
||||
|
||||
// buildAdjustPriceQuery 构造订单改价请求的固定查询参数。
|
||||
func buildAdjustPriceQuery(t, sign string) string {
|
||||
// parts 是按顺序拼接的查询键值对。
|
||||
parts := [][2]string{
|
||||
{"jsv", "2.7.2"},
|
||||
{"appKey", protocol.SignAppKey},
|
||||
{"t", t},
|
||||
{"sign", sign},
|
||||
{"v", "1.0"},
|
||||
{"type", "originaljson"},
|
||||
{"accountSite", "xianyu"},
|
||||
{"dataType", "json"},
|
||||
{"timeout", "20000"},
|
||||
{"api", "mtop.taobao.idle.trade.user.adjust.price"},
|
||||
{"sessionOption", "AutoLoginOnly"},
|
||||
}
|
||||
// b 是查询字符串构造器。
|
||||
var b strings.Builder
|
||||
// i、p 分别是当前键值对的下标和内容。
|
||||
for i, p := range parts {
|
||||
if i > 0 {
|
||||
b.WriteByte('&')
|
||||
}
|
||||
b.WriteString(p[0])
|
||||
b.WriteByte('=')
|
||||
b.WriteString(p[1])
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package mtop
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// adjustPriceCookies 是订单改价单测使用的最小签名 Cookie。
|
||||
const adjustPriceCookies = "unb=123; _m_h5_tk=token_1;"
|
||||
|
||||
// TestAdjustOrderPriceSuccess: ret SUCCESS 且 data.success=true 时业务成功,请求体携带整数分价格。
|
||||
func TestAdjustOrderPriceSuccess(t *testing.T) {
|
||||
// requests 统计服务端收到的请求次数。
|
||||
var requests atomic.Int32
|
||||
// gotBody 保存服务端收到的请求体,用于校验改价参数。
|
||||
var gotBody atomic.Value
|
||||
// server 是模拟 MTOP 改价端点的本地 HTTP 服务。
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
requests.Add(1)
|
||||
// body、_ 分别是读取到的请求体和忽略的读取错误。
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
gotBody.Store(string(body))
|
||||
fmt.Fprint(w, `{"api":"mtop.taobao.idle.trade.user.adjust.price","ret":["SUCCESS::调用成功"],"data":{"success":true,"serverTime":"1"},"v":"1.0"}`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
// client 是指向本地服务的 MTOP 客户端。
|
||||
client := &ClientImpl{HTTPClient: server.Client(), AdjustPriceURL: server.URL + "/"}
|
||||
// orderID 是含 JSON 特殊字符的订单标识,用于验证请求体由 JSON 编码生成而不是字符串拼接。
|
||||
orderID := `order-"quoted"`
|
||||
// ok、ret、updated、err 分别是改价结果、业务返回、Cookie 更新和调用错误。
|
||||
ok, ret, updated, err := client.AdjustOrderPriceContext(context.Background(), adjustPriceCookies, orderID, 990)
|
||||
if err != nil {
|
||||
t.Fatalf("err=%v", err)
|
||||
}
|
||||
if !ok || len(ret) == 0 || !strings.Contains(ret[0], "SUCCESS") {
|
||||
t.Fatalf("ok=%v ret=%v", ok, ret)
|
||||
}
|
||||
if updated != adjustPriceCookies {
|
||||
t.Fatalf("无 Set-Cookie 时 updated 应保持原样: %q", updated)
|
||||
}
|
||||
if requests.Load() != 1 {
|
||||
t.Fatalf("requests=%d want 1", requests.Load())
|
||||
}
|
||||
// body 是服务端记录的实际请求体。
|
||||
body, _ := gotBody.Load().(string)
|
||||
if !strings.Contains(body, "%22modifyFee%22%3A990") || !strings.Contains(body, "order-%5C%22quoted%5C%22") {
|
||||
t.Fatalf("请求体缺少改价参数: %q", body)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceDataSuccessFalse: ret SUCCESS 但 data.success=false 时视为业务失败且不重试。
|
||||
func TestAdjustOrderPriceDataSuccessFalse(t *testing.T) {
|
||||
// requests 统计服务端收到的请求次数。
|
||||
var requests atomic.Int32
|
||||
// server 是返回 data.success=false 的本地改价端点。
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
requests.Add(1)
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"success":false}}`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
// client 是指向本地服务的 MTOP 客户端。
|
||||
client := &ClientImpl{HTTPClient: server.Client(), AdjustPriceURL: server.URL + "/"}
|
||||
// ok、ret、err 分别是改价结果、业务返回和调用错误。
|
||||
ok, ret, _, err := client.AdjustOrderPriceContext(context.Background(), adjustPriceCookies, "order-1", 990)
|
||||
if err != nil || ok || len(ret) == 0 {
|
||||
t.Fatalf("ok=%v ret=%v err=%v", ok, ret, err)
|
||||
}
|
||||
if requests.Load() != 1 {
|
||||
t.Fatalf("requests=%d want 1", requests.Load())
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceBizFailure: 非 token 过期的业务失败不重试,返回 ok=false 且无错误。
|
||||
func TestAdjustOrderPriceBizFailure(t *testing.T) {
|
||||
// requests 统计服务端收到的请求次数。
|
||||
var requests atomic.Int32
|
||||
// server 是返回订单状态错误的本地改价端点。
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
requests.Add(1)
|
||||
fmt.Fprint(w, `{"ret":["FAIL_BIZ_ORDER_NOT_ALLOW_MODIFY::当前订单不允许修改价格"],"data":{}}`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
// client 是指向本地服务的 MTOP 客户端。
|
||||
client := &ClientImpl{HTTPClient: server.Client(), AdjustPriceURL: server.URL + "/"}
|
||||
// ok、ret、err 分别是改价结果、业务返回和调用错误。
|
||||
ok, ret, _, err := client.AdjustOrderPriceContext(context.Background(), adjustPriceCookies, "order-1", 990)
|
||||
if err != nil || ok || len(ret) == 0 || !strings.Contains(ret[0], "FAIL_BIZ_ORDER_NOT_ALLOW_MODIFY") {
|
||||
t.Fatalf("ok=%v ret=%v err=%v", ok, ret, err)
|
||||
}
|
||||
if requests.Load() != 1 {
|
||||
t.Fatalf("requests=%d want 1", requests.Load())
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceSessionExpired: Session 失效返回可识别的 SessionExpiredError。
|
||||
func TestAdjustOrderPriceSessionExpired(t *testing.T) {
|
||||
// server 是返回 Session 失效的本地改价端点。
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["FAIL_SYS_SESSION_EXPIRED::Session过期"]}`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
// client 是指向本地服务的 MTOP 客户端。
|
||||
client := &ClientImpl{HTTPClient: server.Client(), AdjustPriceURL: server.URL + "/"}
|
||||
// ok、err 分别是改价结果和调用错误。
|
||||
ok, _, _, err := client.AdjustOrderPriceContext(context.Background(), adjustPriceCookies, "order-1", 990)
|
||||
if ok || !IsSessionExpiredErr(err) {
|
||||
t.Fatalf("ok=%v err=%v", ok, err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceTokenRetry: token 过期时使用响应下发的新 Cookie 重签并重试成功。
|
||||
func TestAdjustOrderPriceTokenRetry(t *testing.T) {
|
||||
// requests 统计服务端收到的请求次数。
|
||||
var requests atomic.Int32
|
||||
// server 是首次返回 token 过期并下发新 token、第二次成功的本地改价端点。
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if requests.Add(1) == 1 {
|
||||
http.SetCookie(w, &http.Cookie{Name: "_m_h5_tk", Value: "token_2"})
|
||||
fmt.Fprint(w, `{"ret":["FAIL_SYS_TOKEN_EXOIRED::令牌过期"]}`)
|
||||
return
|
||||
}
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"success":true}}`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
// client 是指向本地服务的 MTOP 客户端。
|
||||
client := &ClientImpl{HTTPClient: server.Client(), AdjustPriceURL: server.URL + "/"}
|
||||
// ok、updated、err 分别是改价结果、Cookie 更新和调用错误。
|
||||
ok, _, updated, err := client.AdjustOrderPriceContext(context.Background(), adjustPriceCookies, "order-1", 990)
|
||||
if err != nil || !ok {
|
||||
t.Fatalf("ok=%v err=%v", ok, err)
|
||||
}
|
||||
if !strings.Contains(updated, "token_2") {
|
||||
t.Fatalf("updated 应包含新 token: %q", updated)
|
||||
}
|
||||
if requests.Load() != 2 {
|
||||
t.Fatalf("requests=%d want 2", requests.Load())
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceTokenExpiredNoCookieRefreshFails 验证 token 过期而响应未更新 Cookie 时,会透传主动刷新失败。
|
||||
func TestAdjustOrderPriceTokenExpiredNoCookieRefreshFails(t *testing.T) {
|
||||
// requests 统计改价端点收到的请求次数。
|
||||
var requests atomic.Int32
|
||||
// server 是同时模拟改价和 token 刷新端点的本地 HTTP 服务。
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Query().Get("api") == "mtop.taobao.idlemessage.pc.login.token" {
|
||||
fmt.Fprint(w, `{"ret":["FAIL_SYS_SESSION_EXPIRED::Session过期"]}`)
|
||||
return
|
||||
}
|
||||
requests.Add(1)
|
||||
fmt.Fprint(w, `{"ret":["FAIL_SYS_TOKEN_EXOIRED::令牌过期"]}`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
// client 是指向本地服务的 MTOP 客户端,其中 token 端点会返回不可恢复的会话失效。
|
||||
client := &ClientImpl{HTTPClient: server.Client(), AdjustPriceURL: server.URL + "/adjust", TokenURL: server.URL + "/token"}
|
||||
// err 保存 token 主动刷新失败后的调用错误。
|
||||
_, _, _, err := client.AdjustOrderPriceContext(context.Background(), adjustPriceCookies, "order-1", 990)
|
||||
if err == nil || !strings.Contains(err.Error(), "订单改价 token 过期且刷新失败") {
|
||||
t.Fatalf("err=%v", err)
|
||||
}
|
||||
if requests.Load() != 1 {
|
||||
t.Fatalf("改价端点请求次数=%d,期望 1", requests.Load())
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceContextCanceled 验证已取消的上下文不会继续执行改价重试。
|
||||
func TestAdjustOrderPriceContextCanceled(t *testing.T) {
|
||||
// server 是不应被已取消请求成功调用的本地改价端点。
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"ret":["SUCCESS::调用成功"],"data":{"success":true}}`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
// client 是指向本地服务的 MTOP 客户端。
|
||||
client := &ClientImpl{HTTPClient: server.Client(), AdjustPriceURL: server.URL + "/"}
|
||||
// ctx、cancel 分别是已取消的请求上下文和其释放函数。
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
// err 保存 HTTP 请求因上下文取消返回的错误。
|
||||
_, _, _, err := client.AdjustOrderPriceContext(ctx, adjustPriceCookies, "order-1", 990)
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
t.Fatalf("err=%v,期望 context.Canceled", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdjustOrderPriceMalformedResponse 验证无法解析的 MTOP 响应会作为传输错误返回,避免把远端状态误判为业务拒绝。
|
||||
func TestAdjustOrderPriceMalformedResponse(t *testing.T) {
|
||||
// server 是返回损坏 JSON 的本地改价端点。
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{invalid`)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
// client 是指向本地服务的 MTOP 客户端。
|
||||
client := &ClientImpl{HTTPClient: server.Client(), AdjustPriceURL: server.URL + "/"}
|
||||
// err 保存响应 JSON 解析错误。
|
||||
_, _, _, err := client.AdjustOrderPriceContext(context.Background(), adjustPriceCookies, "order-1", 990)
|
||||
if err == nil || !strings.Contains(err.Error(), "解析订单改价响应失败") {
|
||||
t.Fatalf("err=%v", err)
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ const (
|
||||
type Client interface {
|
||||
FetchUserProfile(ctx context.Context, cookiesStr string) (*UserProfileResult, error)
|
||||
ConsignContext(ctx context.Context, cookiesStr, orderID string) (ok bool, ret []string, updatedCookies string, err error)
|
||||
AdjustOrderPriceContext(ctx context.Context, cookiesStr, orderID string, priceCents int64) (ok bool, ret []string, updatedCookies string, err error)
|
||||
FetchItemsPage(ctx context.Context, cookiesStr string, pageNumber, pageSize int) (*ItemListResult, error)
|
||||
FetchAllItems(ctx context.Context, cookiesStr string, pageSize, maxPages int) (*ItemListResult, error)
|
||||
PublishItem(ctx context.Context, cookiesStr string, req PublishItemRequest) (*PublishItemResult, error)
|
||||
@@ -68,9 +69,11 @@ type ClientImpl struct {
|
||||
HTTPClient *http.Client
|
||||
// Logger 记录 MTOP 请求的安全摘要(不会输出 Cookie、签名或响应正文)。
|
||||
// 未设置时使用 slog.Default,测试可传入丢弃日志的 logger。
|
||||
Logger *slog.Logger
|
||||
TokenURL string
|
||||
ConsignURL string
|
||||
Logger *slog.Logger
|
||||
TokenURL string
|
||||
ConsignURL string
|
||||
// AdjustPriceURL 覆盖订单改价端点,仅供测试注入本地 HTTP 服务。
|
||||
AdjustPriceURL string
|
||||
OrderDetailURL string
|
||||
SoldOrdersURL string
|
||||
ItemDetailURL string
|
||||
|
||||
Reference in new issue
Block a user