feat: 对齐闲鱼续期流程并完善业务管理
对齐官方 WebSocket 批量握手、注册、心跳、ACK、同步恢复及运行时设备标识生命周期。 保留 Cookie 完整属性,接入静默续期和保存登录信息设置,并在凭证更新后重建账号连接。 完善订单与商品同步、卡券和通知渠道交互,更新前端品牌、时间展示及嵌入资源。 补充 Go 与前端回归测试,确保完整检查和生产构建通过。
This commit is contained in:
1 parent
3cc1d4094d
commit
d77c317452
69 files changed
+3169
-819
No files matched your search
@@ -20,6 +20,8 @@ import {
|
||||
getAccountAISettings,
|
||||
getNotificationChannels,
|
||||
getAccountBindings,
|
||||
getLongLoginSettings,
|
||||
setLongLoginSettings,
|
||||
} from '../services/api';
|
||||
import { shouldUpdateAccountPause } from './accountPause';
|
||||
import {
|
||||
@@ -49,6 +51,7 @@ const AccountList: React.FC = () => {
|
||||
const [qrReauthTarget, setQrReauthTarget] = useState<AccountDetail | null>(null);
|
||||
const [activeModal, setActiveModal] = useState<ModalType>(null);
|
||||
const [editingAccount, setEditingAccount] = useState<AccountDetail | null>(null);
|
||||
const [longLogin, setLongLogin] = useState({ loading: false, saving: false, canOpen: false, enabled: false, error: '' });
|
||||
|
||||
// 通知渠道绑定(编辑弹窗用)
|
||||
const [notifChannels, setNotifChannels] = useState<NotificationChannel[]>([]);
|
||||
@@ -328,7 +331,28 @@ const AccountList: React.FC = () => {
|
||||
clear_password: false,
|
||||
});
|
||||
setActiveModal('edit');
|
||||
await loadNotificationBindings(account.id);
|
||||
setLongLogin({ loading: true, saving: false, canOpen: false, enabled: false, error: '' });
|
||||
const [, longLoginResult] = await Promise.allSettled([
|
||||
loadNotificationBindings(account.id),
|
||||
getLongLoginSettings(account.id),
|
||||
]);
|
||||
if (longLoginResult.status === 'fulfilled') {
|
||||
setLongLogin({ loading: false, saving: false, canOpen: longLoginResult.value.can_open_long_login, enabled: longLoginResult.value.enabled, error: '' });
|
||||
} else {
|
||||
setLongLogin({ loading: false, saving: false, canOpen: false, enabled: false, error: '无法读取闲鱼保存登录信息状态' });
|
||||
}
|
||||
};
|
||||
|
||||
const handleLongLoginToggle = async () => {
|
||||
if (!editingAccount || longLogin.loading || longLogin.saving || !longLogin.canOpen) return;
|
||||
const enabled = !longLogin.enabled;
|
||||
setLongLogin(current => ({ ...current, saving: true, error: '' }));
|
||||
try {
|
||||
const result = await setLongLoginSettings(editingAccount.id, enabled);
|
||||
setLongLogin({ loading: false, saving: false, canOpen: result.can_open_long_login, enabled: result.enabled, error: '' });
|
||||
} catch (error) {
|
||||
setLongLogin(current => ({ ...current, saving: false, error: error instanceof Error ? error.message : '保存登录信息设置失败' }));
|
||||
}
|
||||
};
|
||||
|
||||
const openAIModal = async (account: AccountDetail) => {
|
||||
@@ -966,6 +990,22 @@ const AccountList: React.FC = () => {
|
||||
登录信息
|
||||
</h3>
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between gap-4 rounded-xl bg-blue-50 p-4">
|
||||
<div>
|
||||
<div className="font-bold text-gray-900">保存登录信息</div>
|
||||
<div className="mt-1 text-xs text-gray-500">状态直接读取并修改闲鱼官方长登录设置</div>
|
||||
{longLogin.error && <div className="mt-1 text-xs text-red-600">{longLogin.error}</div>}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="保存登录信息"
|
||||
disabled={longLogin.loading || longLogin.saving || !longLogin.canOpen}
|
||||
onClick={() => void handleLongLoginToggle()}
|
||||
className={`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${longLogin.enabled ? 'bg-[#0094f7]' : 'bg-gray-300'} disabled:cursor-not-allowed disabled:opacity-50`}
|
||||
>
|
||||
<span className={`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${longLogin.enabled ? 'translate-x-6' : 'translate-x-0'}`} />
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-bold text-gray-700 mb-2">用户名</label>
|
||||
<input
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Card } from '../types';
|
||||
import { getCards, createCard, updateCard, deleteCard, batchCreateCards, appendCardData } from '../services/api';
|
||||
import { Plus, CreditCard, Clock, FileText, Image as ImageIcon, Code, Edit, Trash2, Save, X, Eye, EyeOff, Package, Copy, Upload, Loader2, FileDown, ListPlus } from 'lucide-react';
|
||||
import { Plus, CreditCard, Clock, FileText, Image as ImageIcon, Code, Edit, Trash2, Save, X, Eye, EyeOff, Package, Copy, Upload, Loader2, FileDown, ListPlus, Search, SlidersHorizontal } from 'lucide-react';
|
||||
import { filterCards } from './cardListState';
|
||||
|
||||
type AddCardForm = {
|
||||
name: string;
|
||||
@@ -55,6 +56,8 @@ const CardList: React.FC = () => {
|
||||
const [appendTargetId, setAppendTargetId] = useState<string>('');
|
||||
const [appendContent, setAppendContent] = useState('');
|
||||
const [appendResult, setAppendResult] = useState<{ added: number } | null>(null);
|
||||
const [typeFilter, setTypeFilter] = useState<Card['type'] | ''>('');
|
||||
const [nameSearch, setNameSearch] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
getCards().then(setCards);
|
||||
@@ -213,6 +216,10 @@ const CardList: React.FC = () => {
|
||||
};
|
||||
|
||||
const dataCards = cards.filter(c => c.type === 'data');
|
||||
const filteredCards = useMemo(
|
||||
() => filterCards(cards, typeFilter, nameSearch),
|
||||
[cards, nameSearch, typeFilter],
|
||||
);
|
||||
|
||||
const downloadCardTemplate = () => {
|
||||
const headers = ['名称', '类型', '内容', '描述', '启用', '延迟秒', '多规格', '规格名', '规格值'];
|
||||
@@ -306,28 +313,61 @@ const CardList: React.FC = () => {
|
||||
</div>
|
||||
|
||||
<div className="ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white">
|
||||
<div className="flex flex-col gap-3 border-b border-gray-50 bg-[#FAFAFA] p-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="flex flex-1 flex-col gap-3 sm:flex-row">
|
||||
<div className="relative sm:w-48">
|
||||
<SlidersHorizontal className="pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400" />
|
||||
<select
|
||||
aria-label="按卡密类型筛选"
|
||||
value={typeFilter}
|
||||
onChange={event => setTypeFilter(event.target.value as Card['type'] | '')}
|
||||
className="ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm"
|
||||
>
|
||||
<option value="">全部类型</option>
|
||||
<option value="data">批量卡密</option>
|
||||
<option value="text">文本</option>
|
||||
<option value="api">API</option>
|
||||
<option value="image">图片</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="relative w-full sm:max-w-sm">
|
||||
<Search className="pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400" />
|
||||
<input
|
||||
type="search"
|
||||
aria-label="按卡密名称搜索"
|
||||
placeholder="搜索卡密名称..."
|
||||
value={nameSearch}
|
||||
onChange={event => setNameSearch(event.target.value)}
|
||||
className="ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="whitespace-nowrap px-1 text-xs font-bold text-gray-400">
|
||||
显示 {filteredCards.length} / {cards.length} 组
|
||||
</div>
|
||||
</div>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left border-collapse">
|
||||
<table className="w-full table-fixed text-left border-collapse">
|
||||
<thead>
|
||||
<tr className="bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50">
|
||||
<th className="px-8 py-5 w-[18%]">卡密名称</th>
|
||||
<th className="px-6 py-5 w-[12%]">卡密组ID</th>
|
||||
<th className="px-6 py-5 w-[10%]">类型</th>
|
||||
<th className="px-6 py-5 w-[22%]">内容/库存</th>
|
||||
<th className="px-6 py-5 w-[18%]">描述</th>
|
||||
<th className="px-6 py-5 w-[10%]">状态</th>
|
||||
<th className="px-6 py-5 w-[10%] text-right">操作</th>
|
||||
<th className="w-[23%] px-5 py-5">卡密名称</th>
|
||||
<th className="w-[8%] px-3 py-5">卡密组ID</th>
|
||||
<th className="w-[7%] px-2 py-5">类型</th>
|
||||
<th className="w-[27%] px-5 py-5">内容/库存</th>
|
||||
<th className="w-[19%] px-5 py-5">描述</th>
|
||||
<th className="w-[7%] px-2 py-5">状态</th>
|
||||
<th className="w-[9%] px-3 py-5 text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-50">
|
||||
{cards.map((card) => {
|
||||
{filteredCards.map((card) => {
|
||||
// 计算库存或内容预览
|
||||
let stockInfo = '';
|
||||
if (card.type === 'data' && card.data_content) {
|
||||
const lines = card.data_content.split('\n').filter(line => line.trim());
|
||||
stockInfo = `库存: ${lines.length} 条`;
|
||||
} else if (card.type === 'text' && card.text_content) {
|
||||
stockInfo = card.text_content.substring(0, 20) + (card.text_content.length > 20 ? '...' : '');
|
||||
stockInfo = card.text_content;
|
||||
} else if (card.type === 'api' && card.api_config) {
|
||||
stockInfo = card.api_config.url;
|
||||
} else if (card.type === 'image' && card.image_url) {
|
||||
@@ -336,26 +376,26 @@ const CardList: React.FC = () => {
|
||||
|
||||
return (
|
||||
<tr key={card.id} className="hover:bg-[#FFFDE7]/50 transition-colors group">
|
||||
<td className="px-8 py-5">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="p-2 bg-gray-50 rounded-xl group-hover:bg-white transition-colors">
|
||||
<td className="px-5 py-5 align-middle">
|
||||
<div className="flex items-center gap-2.5">
|
||||
<div className="shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white">
|
||||
<CardIcon type={card.type} />
|
||||
</div>
|
||||
<span className="font-bold text-gray-900">{card.name}</span>
|
||||
<span className="line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900" title={card.name}>{card.name}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-6 py-5">
|
||||
<td className="px-3 py-5">
|
||||
<button
|
||||
onClick={() => copyCardID(card.id)}
|
||||
className="inline-flex items-center gap-2 rounded-xl bg-gray-100 px-3 py-2 font-mono text-xs font-extrabold text-gray-700 hover:bg-gray-200 transition-colors"
|
||||
className="inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200"
|
||||
title="复制卡密组ID,用于批量铺货表格"
|
||||
>
|
||||
{card.id}
|
||||
<Copy className="w-3.5 h-3.5" />
|
||||
<span className="truncate">{card.id}</span>
|
||||
<Copy className="h-3 w-3 shrink-0" />
|
||||
</button>
|
||||
</td>
|
||||
<td className="px-6 py-5">
|
||||
<span className={`px-3 py-1.5 rounded-lg text-xs font-bold ${
|
||||
<td className="px-2 py-5">
|
||||
<span className={`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${
|
||||
card.type === 'text' ? 'bg-blue-50 text-blue-600' :
|
||||
card.type === 'data' ? 'bg-purple-50 text-purple-600' :
|
||||
card.type === 'api' ? 'bg-blue-50 text-blue-600' :
|
||||
@@ -366,20 +406,20 @@ const CardList: React.FC = () => {
|
||||
card.type === 'api' ? 'API' : '图片'}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-6 py-5">
|
||||
<span className="text-sm text-gray-600 font-mono block truncate" title={stockInfo}>
|
||||
<td className="px-5 py-5">
|
||||
<span className="line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600" title={stockInfo}>
|
||||
{stockInfo}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-6 py-5">
|
||||
<td className="px-5 py-5">
|
||||
<span
|
||||
className="text-sm text-gray-500 block max-w-[200px] truncate"
|
||||
className="block truncate text-sm text-gray-500"
|
||||
title={card.description || '-'}
|
||||
>
|
||||
{card.description || '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-6 py-5">
|
||||
<td className="px-2 py-5">
|
||||
<button
|
||||
onClick={() => toggleCardStatus(card)}
|
||||
className={`w-12 h-8 rounded-full relative transition-colors ${
|
||||
@@ -391,20 +431,20 @@ const CardList: React.FC = () => {
|
||||
}`}></div>
|
||||
</button>
|
||||
</td>
|
||||
<td className="px-6 py-5">
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<td className="px-3 py-5">
|
||||
<div className="flex items-center justify-end gap-0.5">
|
||||
<button
|
||||
onClick={() => handleEdit(card)}
|
||||
className="p-2 text-gray-400 hover:text-black hover:bg-gray-100 rounded-xl transition-colors"
|
||||
className="rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black"
|
||||
title="编辑"
|
||||
>
|
||||
<Edit className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleDelete(card.id)}
|
||||
className="p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors"
|
||||
className="rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500"
|
||||
>
|
||||
<Trash2 className="w-5 h-5" />
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
@@ -415,10 +455,10 @@ const CardList: React.FC = () => {
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{cards.length === 0 && (
|
||||
{filteredCards.length === 0 && (
|
||||
<div className="py-20 text-center text-gray-400">
|
||||
<Package className="w-12 h-12 mx-auto mb-4 opacity-30" />
|
||||
<p>暂无卡密配置,请点击右上角添加。</p>
|
||||
<p>{cards.length === 0 ? '暂无卡密配置,请点击右上角添加。' : '没有符合当前筛选条件的卡密组。'}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
||||
import { DashboardStats, OrderAnalytics, Order, OrderStatus, Item } from '../types';
|
||||
import { getDashboardStats, getOrderAnalytics, getValidOrders, getItems } from '../services/api';
|
||||
import { getDateRange, getPreviousDateRange, TimeRange } from '../dateRange';
|
||||
import { formatLocalDateTime } from '../dateTime';
|
||||
import { TrendingUp, Users, ShoppingCart, AlertCircle, DollarSign, Activity, Package, ArrowUpRight, Calendar, X, BarChart3, PackageCheck, ExternalLink, Eye, Edit } from 'lucide-react';
|
||||
import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, BarChart, Bar, PieChart, Pie, Cell, Legend } from 'recharts';
|
||||
|
||||
@@ -588,7 +589,7 @@ const Dashboard: React.FC = () => {
|
||||
<td className="px-6 py-4">
|
||||
<div className="text-sm font-bold text-gray-800">{order.buyer_id}</div>
|
||||
{order.created_at && (
|
||||
<div className="text-xs text-gray-400 mt-1">{order.created_at}</div>
|
||||
<div className="text-xs text-gray-400 mt-1">{formatLocalDateTime(order.created_at)}</div>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { selectActivePublishBatch } from './itemPublishBatchState';
|
||||
import { Item, AccountDetail, ShippingRule } from '../types';
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
deleteItem,
|
||||
getShippingRules
|
||||
} from '../services/api';
|
||||
import { ArrowRight, Box, CheckCircle2, CircleDashed, Edit, Link2, PackagePlus, Plus, RefreshCw, Save, ShoppingBag, Trash2, UploadCloud, X } from 'lucide-react';
|
||||
import { ArrowRight, Box, CheckCircle2, CircleDashed, Edit, Filter, Link2, PackagePlus, Plus, RefreshCw, Save, ShoppingBag, Trash2, UploadCloud, User, X } from 'lucide-react';
|
||||
|
||||
interface ItemListProps {
|
||||
onConfigureDelivery: (item: Item) => void;
|
||||
@@ -77,6 +77,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
const [shippingRules, setShippingRules] = useState<ShippingRule[]>([]);
|
||||
const [accounts, setAccounts] = useState<AccountDetail[]>([]);
|
||||
const [selectedAccount, setSelectedAccount] = useState<string>('');
|
||||
const [accountFilter, setAccountFilter] = useState<string>('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [publishing, setPublishing] = useState(false);
|
||||
const [batchLoading, setBatchLoading] = useState(false);
|
||||
@@ -510,24 +511,72 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const accountMap = useMemo(
|
||||
() => new Map(accounts.map(account => [account.id, account])),
|
||||
[accounts],
|
||||
);
|
||||
const visibleItems = useMemo(
|
||||
() => accountFilter ? items.filter(item => item.cookie_id === accountFilter) : items,
|
||||
[accountFilter, items],
|
||||
);
|
||||
const accountName = (cookieId: string) => {
|
||||
const account = accountMap.get(cookieId);
|
||||
const name = account?.remark || account?.nickname;
|
||||
return name ? `${name} · ${cookieId.slice(0, 6)}` : `账号 ${cookieId.slice(0, 8)}`;
|
||||
};
|
||||
const accountNickname = (cookieId: string) => {
|
||||
const account = accountMap.get(cookieId);
|
||||
return account?.remark || account?.nickname || '未命名账号';
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6 animate-fade-in">
|
||||
<div className="flex justify-between items-center">
|
||||
<div className="flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4">
|
||||
<div>
|
||||
<h2 className="text-3xl font-bold text-gray-900">商品管理</h2>
|
||||
<p className="text-gray-500 mt-2 text-sm">监控并管理所有账号下的闲鱼商品。</p>
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<select
|
||||
className="ios-input px-4 py-3 rounded-xl text-sm"
|
||||
value={selectedAccount}
|
||||
onChange={e => setSelectedAccount(e.target.value)}
|
||||
>
|
||||
<option value="">选择账号以同步</option>
|
||||
{accounts.map(acc => (
|
||||
<option key={acc.id} value={acc.id}>{acc.nickname}</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="flex flex-wrap items-end gap-3">
|
||||
<div className="flex min-w-[200px] flex-col gap-1.5">
|
||||
<label htmlFor="item-account-filter" className="px-1 text-[11px] font-extrabold tracking-wide text-gray-500">
|
||||
商品列表筛选
|
||||
</label>
|
||||
<div className="relative">
|
||||
<Filter className="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none" />
|
||||
<select
|
||||
id="item-account-filter"
|
||||
aria-label="按账号筛选商品列表"
|
||||
className="ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm"
|
||||
value={accountFilter}
|
||||
onChange={event => setAccountFilter(event.target.value)}
|
||||
>
|
||||
<option value="">全部账号</option>
|
||||
{accounts.map(account => (
|
||||
<option key={account.id} value={account.id}>{accountName(account.id)}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex min-w-[200px] flex-col gap-1.5">
|
||||
<label htmlFor="item-sync-account" className="px-1 text-[11px] font-extrabold tracking-wide text-gray-500">
|
||||
同步商品账号
|
||||
</label>
|
||||
<div className="relative">
|
||||
<User className="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none" />
|
||||
<select
|
||||
id="item-sync-account"
|
||||
aria-label="选择要同步商品的账号"
|
||||
className="ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm"
|
||||
value={selectedAccount}
|
||||
onChange={e => setSelectedAccount(e.target.value)}
|
||||
>
|
||||
<option value="">请选择账号</option>
|
||||
{accounts.map(acc => (
|
||||
<option key={acc.id} value={acc.id}>{accountName(acc.id)}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleSync}
|
||||
disabled={loading || !selectedAccount}
|
||||
@@ -569,7 +618,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4">
|
||||
{items.map(item => {
|
||||
{visibleItems.map(item => {
|
||||
const linkedRules = rulesForItem(item);
|
||||
const hasRule = linkedRules.length > 0;
|
||||
return (
|
||||
@@ -603,6 +652,10 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
</div>
|
||||
</div>
|
||||
<h3 className="font-bold text-gray-900 line-clamp-2 text-xs mb-1.5 h-8 leading-4">{item.item_title}</h3>
|
||||
<div className="mb-2 inline-flex min-w-0 max-w-full items-center gap-1 self-start rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700" title={accountNickname(item.cookie_id)}>
|
||||
<User className="h-3 w-3 shrink-0" />
|
||||
<span className="min-w-0 truncate whitespace-nowrap">{accountNickname(item.cookie_id)}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center text-[10px] text-gray-500 mb-2">
|
||||
<span className="bg-gray-100 px-1.5 py-0.5 rounded truncate max-w-[80px]">ID: {item.item_id}</span>
|
||||
<span className={`inline-flex items-center gap-1 font-bold ${hasRule ? 'text-emerald-600' : 'text-amber-600'}`}>
|
||||
@@ -622,10 +675,10 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{items.length === 0 && (
|
||||
{visibleItems.length === 0 && (
|
||||
<div className="col-span-full py-20 text-center text-gray-400">
|
||||
<ShoppingBag className="w-12 h-12 mx-auto mb-4 opacity-30" />
|
||||
暂无商品数据,请选择账号进行同步
|
||||
{accountFilter ? '该账号暂无商品数据' : '暂无商品数据,请选择账号进行同步'}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -675,7 +728,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
<label className="block text-sm font-bold text-gray-700">所属账号</label>
|
||||
<select className="w-full ios-input px-4 py-3 rounded-xl" value={addForm.cookie_id} onChange={e => setAddForm({...addForm, cookie_id: e.target.value})}>
|
||||
<option value="">选择账号</option>
|
||||
{accounts.map(acc => <option key={acc.id} value={acc.id}>{acc.nickname || acc.remark || acc.id}</option>)}
|
||||
{accounts.map(acc => <option key={acc.id} value={acc.id}>{accountName(acc.id)}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
@@ -727,7 +780,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
<label className="block text-sm font-bold text-gray-700">发布账号</label>
|
||||
<select className="w-full ios-input px-4 py-3 rounded-xl" value={publishForm.cookie_id} onChange={e => setPublishForm({...publishForm, cookie_id: e.target.value})}>
|
||||
<option value="">选择账号</option>
|
||||
{accounts.map(acc => <option key={acc.id} value={acc.id}>{acc.nickname || acc.remark || acc.id}</option>)}
|
||||
{accounts.map(acc => <option key={acc.id} value={acc.id}>{accountName(acc.id)}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
@@ -857,7 +910,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
onChange={e => setSelectedAccount(e.target.value)}
|
||||
>
|
||||
<option value="">选择账号</option>
|
||||
{accounts.map(acc => <option key={acc.id} value={acc.id}>{acc.nickname || acc.remark || acc.id}</option>)}
|
||||
{accounts.map(acc => <option key={acc.id} value={acc.id}>{accountName(acc.id)}</option>)}
|
||||
</select>
|
||||
<p className="text-xs text-gray-500">表格中“账号ID”为空时,会使用这里选择的账号。</p>
|
||||
</div>
|
||||
@@ -924,7 +977,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-50 text-gray-700">
|
||||
{[
|
||||
['账号ID', '没有在上方选择默认账号时填写', '填写账号 ID;已经选择默认账号时可以留空'],
|
||||
['账号ID', '需要覆盖默认账号时填写', '上方默认发布账号为必选;本列留空时使用默认账号,填写后仅覆盖当前行'],
|
||||
['标题', '每个商品都要填', '填写买家能看到的商品标题'],
|
||||
['描述', '可以留空', '留空时会使用商品标题作为描述'],
|
||||
['价格', '每个商品都要填', '只填数字,例如 19.90'],
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
Check, MessageCircle, Mail, Webhook, Send as Telegram, Eye, EyeOff, Save,
|
||||
} from 'lucide-react';
|
||||
import { normalizeSMTPSettings } from '../smtpSettings';
|
||||
import { buildEmailChannelConfig, enableCustomSMTP, normalizeEmailChannelConfig } from '../notificationEmailConfig';
|
||||
|
||||
type ChannelTypeMeta = {
|
||||
label: string;
|
||||
@@ -139,18 +140,14 @@ const CHANNEL_TYPES: Record<NotificationChannelType, ChannelTypeMeta> = {
|
||||
icon: Mail,
|
||||
fields: [
|
||||
{ key: 'to_email', label: '收件邮箱', placeholder: '[email protected]', required: true },
|
||||
{ key: 'smtp_server', label: '覆盖 SMTP 服务器', placeholder: 'smtp.qq.com', help: '留空时使用上方系统级 SMTP 配置' },
|
||||
{ key: 'smtp_port', label: '覆盖 SMTP 端口', placeholder: '587', type: 'number', help: '留空时使用系统级 SMTP 端口' },
|
||||
{ key: 'smtp_user', label: '覆盖发件邮箱', placeholder: '[email protected]', help: '留空时使用系统级发件邮箱' },
|
||||
{ key: 'smtp_password', label: '覆盖密码 / 授权码', type: 'password', help: '留空时使用系统级授权码' },
|
||||
],
|
||||
guide: {
|
||||
steps: [
|
||||
'先在页面上方保存系统级 SMTP 服务器、端口、发件邮箱和授权码',
|
||||
'邮件渠道只需要填写收件邮箱',
|
||||
'如果某个渠道要使用不同发件邮箱,再填写下面的覆盖 SMTP 字段',
|
||||
'通常先保存页面中的系统 SMTP 配置',
|
||||
'邮件渠道只需填写收件邮箱,即可完整继承系统 SMTP',
|
||||
'只有确实需要另一套发件服务时,才开启“使用独立 SMTP”并填写整套配置',
|
||||
],
|
||||
note: '收件邮箱会写入 to_email;SMTP 字段留空时后端会复用系统级 SMTP 配置。',
|
||||
note: '继承和独立 SMTP 是互斥模式,不会再混用两套配置中的部分字段。',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -188,6 +185,7 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
|
||||
const [smtp, setSmtp] = useState<SystemSettings>({});
|
||||
const [smtpSaving, setSmtpSaving] = useState(false);
|
||||
const [showSmtpPassword, setShowSmtpPassword] = useState(false);
|
||||
const [showChannelSmtpPassword, setShowChannelSmtpPassword] = useState(false);
|
||||
|
||||
const [form, setForm] = useState({
|
||||
name: '',
|
||||
@@ -256,18 +254,28 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
|
||||
const openCreate = () => {
|
||||
setEditing(null);
|
||||
setForm({ name: '', type: 'bark', enabled: true, config: {}, event_types: [] });
|
||||
setShowChannelSmtpPassword(false);
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
const openEdit = (ch: NotificationChannel) => {
|
||||
setEditing(ch);
|
||||
const normalizedEmailConfig = ch.type === 'email'
|
||||
? normalizeEmailChannelConfig({ ...(ch.config || {}) })
|
||||
: null;
|
||||
const config = normalizedEmailConfig
|
||||
? (normalizedEmailConfig.use_custom_smtp === true
|
||||
? enableCustomSMTP(normalizedEmailConfig, smtp)
|
||||
: normalizedEmailConfig)
|
||||
: { ...(ch.config || {}) };
|
||||
setForm({
|
||||
name: ch.name,
|
||||
type: ch.type,
|
||||
enabled: ch.enabled,
|
||||
config: { ...(ch.config || {}) },
|
||||
config,
|
||||
event_types: ch.event_types || [],
|
||||
});
|
||||
setShowChannelSmtpPassword(false);
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
@@ -283,9 +291,27 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
|
||||
showToast('error', '请填写渠道名称');
|
||||
return;
|
||||
}
|
||||
let config = form.config;
|
||||
if (form.type === 'email') {
|
||||
config = buildEmailChannelConfig(form.config);
|
||||
if (config.use_custom_smtp) {
|
||||
const required = [
|
||||
['smtp_server', '独立 SMTP 服务器'],
|
||||
['smtp_port', '独立 SMTP 端口'],
|
||||
['smtp_user', '独立 SMTP 登录邮箱'],
|
||||
['smtp_password', '独立 SMTP 密码 / 授权码'],
|
||||
['smtp_from_address', '独立 SMTP 发件地址'],
|
||||
] as const;
|
||||
const missing = required.find(([key]) => !String(config[key] || '').trim());
|
||||
if (missing) {
|
||||
showToast('error', `请填写 ${missing[1]}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
const payload = { name: form.name.trim(), type: form.type, config: form.config, event_types: form.event_types, enabled: form.enabled };
|
||||
const payload = { name: form.name.trim(), type: form.type, config, event_types: form.event_types, enabled: form.enabled };
|
||||
if (editing) {
|
||||
await updateNotificationChannel(editing.id, payload);
|
||||
} else {
|
||||
@@ -664,6 +690,137 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{form.type === 'email' && (
|
||||
<div className="overflow-hidden rounded-2xl border border-blue-100 bg-blue-50/40">
|
||||
<div className="flex items-center justify-between gap-4 p-4">
|
||||
<div>
|
||||
<div className="text-sm font-extrabold text-gray-900">SMTP 来源</div>
|
||||
<p className="mt-1 text-xs leading-5 text-gray-500">
|
||||
{form.config.use_custom_smtp === true
|
||||
? '当前渠道使用一套完整、独立的发件配置。'
|
||||
: '当前渠道完整继承系统 SMTP,只单独设置收件邮箱。'}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
const useCustom = form.config.use_custom_smtp === true;
|
||||
setForm({
|
||||
...form,
|
||||
config: useCustom
|
||||
? { ...form.config, use_custom_smtp: false }
|
||||
: enableCustomSMTP(form.config, smtp),
|
||||
});
|
||||
}}
|
||||
className={`relative h-7 w-12 shrink-0 rounded-full transition-colors ${form.config.use_custom_smtp === true ? 'bg-[#0094f7]' : 'bg-gray-300'}`}
|
||||
aria-label="使用独立 SMTP"
|
||||
>
|
||||
<span className={`absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-sm transition-transform ${form.config.use_custom_smtp === true ? 'translate-x-5' : ''}`} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{form.config.use_custom_smtp === true && (
|
||||
<div className="space-y-4 border-t border-blue-100 bg-white/80 p-4">
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-bold text-gray-800">SMTP 服务器 <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="text"
|
||||
value={String(form.config.smtp_server || '')}
|
||||
onChange={e => setForm({ ...form, config: { ...form.config, smtp_server: e.target.value } })}
|
||||
placeholder="smtp.qq.com"
|
||||
className="w-full ios-input px-4 py-3 rounded-xl text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-bold text-gray-800">SMTP 端口 <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="number"
|
||||
value={String(form.config.smtp_port || 587)}
|
||||
onChange={e => setForm({ ...form, config: { ...form.config, smtp_port: e.target.value } })}
|
||||
placeholder="587"
|
||||
className="w-full ios-input px-4 py-3 rounded-xl text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-bold text-gray-800">登录邮箱 <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="email"
|
||||
value={String(form.config.smtp_user || '')}
|
||||
onChange={e => setForm({ ...form, config: { ...form.config, smtp_user: e.target.value } })}
|
||||
placeholder="[email protected]"
|
||||
className="w-full ios-input px-4 py-3 rounded-xl text-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-bold text-gray-800">密码 / 授权码 <span className="text-red-500">*</span></label>
|
||||
<div className="relative">
|
||||
<input
|
||||
type={showChannelSmtpPassword ? 'text' : 'password'}
|
||||
value={String(form.config.smtp_password || '')}
|
||||
onChange={e => setForm({ ...form, config: { ...form.config, smtp_password: e.target.value } })}
|
||||
placeholder="输入密码或授权码"
|
||||
className="w-full ios-input px-4 py-3 pr-12 rounded-xl text-sm"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowChannelSmtpPassword(value => !value)}
|
||||
className="absolute right-3 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600"
|
||||
>
|
||||
{showChannelSmtpPassword ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-bold text-gray-800">发件人显示名(可选)</label>
|
||||
<input
|
||||
type="text"
|
||||
value={String(form.config.smtp_from_name || '')}
|
||||
onChange={e => setForm({ ...form, config: { ...form.config, smtp_from_name: e.target.value } })}
|
||||
placeholder="闲鱼自动回复系统"
|
||||
className="w-full ios-input px-4 py-3 rounded-xl text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-bold text-gray-800">发件邮箱地址 <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="email"
|
||||
value={String(form.config.smtp_from_address || '')}
|
||||
onChange={e => setForm({ ...form, config: { ...form.config, smtp_from_address: e.target.value } })}
|
||||
placeholder="[email protected]"
|
||||
className="w-full ios-input px-4 py-3 rounded-xl text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
<label className="flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.config.smtp_use_tls !== false}
|
||||
onChange={e => setForm({ ...form, config: { ...form.config, smtp_use_tls: e.target.checked, smtp_use_ssl: e.target.checked ? false : form.config.smtp_use_ssl } })}
|
||||
/>
|
||||
STARTTLS(常用于 587)
|
||||
</label>
|
||||
<label className="flex items-center gap-3 rounded-xl border border-gray-200 p-3 text-xs font-bold text-gray-700">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.config.smtp_use_ssl === true}
|
||||
onChange={e => setForm({ ...form, config: { ...form.config, smtp_use_ssl: e.target.checked, smtp_use_tls: e.target.checked ? false : form.config.smtp_use_tls } })}
|
||||
/>
|
||||
SSL/TLS 直连(常用于 465)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label className="block text-sm font-bold text-gray-800">通知内容</label>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Order, OrderStatus, Item } from '../types';
|
||||
import { getOrders, syncOrders, syncSingleOrder, manualShipOrder, updateOrder, deleteOrder, importOrders, getItems } from '../services/api';
|
||||
import { AccountDetail, Order, OrderStatus, Item } from '../types';
|
||||
import { getOrders, syncOrders, syncSingleOrder, manualShipOrder, updateOrder, deleteOrder, importOrders, getItems, getAccountDetails } from '../services/api';
|
||||
import { Search, MoreHorizontal, Truck, RefreshCw, Copy, ChevronLeft, ChevronRight, PackageCheck, Edit, Eye, Plus, Save, X, User as UserIcon, Phone, MapPin, Upload, ExternalLink, Trash2 } from 'lucide-react';
|
||||
import { failedOrderImportRows, normalizeOrderImportResult, OrderImportResult } from './orderImportState';
|
||||
import { formatLocalDateTime } from '../dateTime';
|
||||
|
||||
const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => {
|
||||
const styles = {
|
||||
@@ -36,8 +37,10 @@ const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => {
|
||||
const OrderList: React.FC = () => {
|
||||
const [orders, setOrders] = useState<Order[]>([]);
|
||||
const [items, setItems] = useState<Item[]>([]);
|
||||
const [accounts, setAccounts] = useState<AccountDetail[]>([]);
|
||||
const [itemNames, setItemNames] = useState<Record<string, string>>({});
|
||||
const [filter, setFilter] = useState('all');
|
||||
const [accountFilter, setAccountFilter] = useState('');
|
||||
const [searchText, setSearchText] = useState(''); // 搜索文本
|
||||
const [debouncedSearch, setDebouncedSearch] = useState('');
|
||||
const requestSequence = useRef(0);
|
||||
@@ -65,7 +68,7 @@ const OrderList: React.FC = () => {
|
||||
setLoading(true);
|
||||
|
||||
try {
|
||||
const res = await getOrders(undefined, filter, page, 20, debouncedSearch);
|
||||
const res = await getOrders(accountFilter || undefined, filter, page, 20, debouncedSearch);
|
||||
if (sequence !== requestSequence.current) return;
|
||||
setOrders(res.data);
|
||||
setTotalPages(res.total_pages);
|
||||
@@ -77,15 +80,15 @@ const OrderList: React.FC = () => {
|
||||
};
|
||||
|
||||
// 从订单的 item_id 查找对应的商品名称(通过标题匹配)
|
||||
const getItemNameById = (orderId: string, orderItemTitle?: string): string => {
|
||||
const getItemNameById = (cookieId: string, orderId: string, orderItemTitle?: string): string => {
|
||||
// 如果订单有 item_title,优先使用
|
||||
if (orderItemTitle && orderItemTitle.trim()) {
|
||||
return orderItemTitle;
|
||||
}
|
||||
|
||||
// 尝试通过 item_id 直接匹配
|
||||
if (itemNames[orderId]) {
|
||||
return itemNames[orderId];
|
||||
if (itemNames[`${cookieId}:${orderId}`]) {
|
||||
return itemNames[`${cookieId}:${orderId}`];
|
||||
}
|
||||
|
||||
// 尝试在商品列表中查找相似标题的商品
|
||||
@@ -113,7 +116,7 @@ const OrderList: React.FC = () => {
|
||||
items.forEach(item => {
|
||||
// 使用 item_id 作为键,商品标题作为值
|
||||
if (item.item_id) {
|
||||
namesMap[item.item_id] = item.item_title || item.item_id;
|
||||
namesMap[`${item.cookie_id}:${item.item_id}`] = item.item_title || item.item_id;
|
||||
}
|
||||
});
|
||||
setItemNames(namesMap);
|
||||
@@ -123,7 +126,7 @@ const OrderList: React.FC = () => {
|
||||
const namesMap: Record<string, string> = {};
|
||||
itemsList.forEach(item => {
|
||||
if (item.item_id) {
|
||||
namesMap[item.item_id] = item.item_title || item.item_id;
|
||||
namesMap[`${item.cookie_id}:${item.item_id}`] = item.item_title || item.item_id;
|
||||
}
|
||||
});
|
||||
setItemNames(namesMap);
|
||||
@@ -139,10 +142,11 @@ const OrderList: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
loadOrders();
|
||||
}, [filter, page, debouncedSearch]);
|
||||
}, [accountFilter, filter, page, debouncedSearch]);
|
||||
|
||||
useEffect(() => {
|
||||
getItems().then((itemsList) => {
|
||||
Promise.all([getAccountDetails(), getItems()]).then(([accountList, itemsList]) => {
|
||||
setAccounts(accountList);
|
||||
setItems(itemsList);
|
||||
buildItemNamesMapFrom(itemsList);
|
||||
}).catch((e) => {
|
||||
@@ -150,10 +154,25 @@ const OrderList: React.FC = () => {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const accountMap = useMemo(
|
||||
() => new Map(accounts.map(account => [account.id, account])),
|
||||
[accounts],
|
||||
);
|
||||
|
||||
const accountName = (cookieId: string) => {
|
||||
const account = accountMap.get(cookieId);
|
||||
const name = account?.remark || account?.nickname;
|
||||
return name ? `${name} · ${cookieId.slice(0, 6)}` : `账号 ${cookieId.slice(0, 8)}`;
|
||||
};
|
||||
const accountNickname = (cookieId: string) => {
|
||||
const account = accountMap.get(cookieId);
|
||||
return account?.remark || account?.nickname || '未命名账号';
|
||||
};
|
||||
|
||||
const handleSync = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await syncOrders();
|
||||
const result = await syncOrders(accountFilter || undefined, filter);
|
||||
await loadOrders();
|
||||
if (result?.message) {
|
||||
alert(result.message);
|
||||
@@ -357,7 +376,22 @@ const OrderList: React.FC = () => {
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="relative w-full md:w-auto group">
|
||||
<div className="flex w-full md:w-auto flex-col sm:flex-row gap-3">
|
||||
<div className="relative">
|
||||
<UserIcon className="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none" />
|
||||
<select
|
||||
aria-label="按账号筛选订单"
|
||||
value={accountFilter}
|
||||
onChange={(event) => { setAccountFilter(event.target.value); setPage(1); }}
|
||||
className="ios-input pl-10 pr-9 py-2.5 rounded-xl w-full sm:w-56 bg-white border-none shadow-sm"
|
||||
>
|
||||
<option value="">全部账号</option>
|
||||
{accounts.map(account => (
|
||||
<option key={account.id} value={account.id}>{accountName(account.id)}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="relative group">
|
||||
<Search className="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-[#0094f7] transition-colors" />
|
||||
<input
|
||||
type="text"
|
||||
@@ -366,6 +400,7 @@ const OrderList: React.FC = () => {
|
||||
onChange={(e) => { setSearchText(e.target.value); setPage(1); }}
|
||||
className="ios-input pl-10 pr-4 py-2.5 rounded-xl w-64 bg-white border-none shadow-sm focus:ring-0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -395,10 +430,14 @@ const OrderList: React.FC = () => {
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<div className="font-bold text-gray-900 line-clamp-1 text-sm">
|
||||
{getItemNameById(order.item_id, order.item_title)}
|
||||
{getItemNameById(order.cookie_id, order.item_id, order.item_title)}
|
||||
</div>
|
||||
<div className="mt-1 flex w-fit min-w-0 max-w-full items-center gap-1 rounded-md bg-blue-50 px-2 py-1 text-[10px] font-extrabold text-blue-700" title={accountNickname(order.cookie_id)}>
|
||||
<UserIcon className="h-3 w-3 shrink-0" />
|
||||
<span className="min-w-0 truncate whitespace-nowrap">{accountNickname(order.cookie_id)}</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500 mt-1 font-medium">订单ID: {order.order_id}</div>
|
||||
<div className="text-xs text-gray-400 mt-0.5">数量: {order.quantity} • {order.created_at}</div>
|
||||
<div className="text-xs text-gray-400 mt-0.5">数量: {order.quantity} • {formatLocalDateTime(order.created_at)}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -536,6 +575,10 @@ const OrderList: React.FC = () => {
|
||||
<div className="text-xs text-gray-500 mb-1">订单号</div>
|
||||
<div className="font-mono text-sm font-bold text-gray-900">{selectedOrder.order_id}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-xs text-gray-500 mb-1">所属账号</div>
|
||||
<div className="truncate whitespace-nowrap text-sm font-bold text-blue-700" title={accountNickname(selectedOrder.cookie_id)}>{accountNickname(selectedOrder.cookie_id)}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-xs text-gray-500 mb-1">状态</div>
|
||||
<StatusBadge status={selectedOrder.status} />
|
||||
@@ -550,7 +593,7 @@ const OrderList: React.FC = () => {
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<div className="text-xs text-gray-500 mb-1">创建时间</div>
|
||||
<div className="text-sm font-medium text-gray-700">{selectedOrder.created_at}</div>
|
||||
<div className="text-sm font-medium text-gray-700">{formatLocalDateTime(selectedOrder.created_at)}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -564,7 +607,7 @@ const OrderList: React.FC = () => {
|
||||
)}
|
||||
<div className="flex-1">
|
||||
<div className="font-bold text-gray-900 mb-1">
|
||||
{getItemNameById(selectedOrder.item_id, selectedOrder.item_title)}
|
||||
{getItemNameById(selectedOrder.cookie_id, selectedOrder.item_id, selectedOrder.item_title)}
|
||||
</div>
|
||||
<div className="text-sm text-gray-500">商品ID: {selectedOrder.item_id}</div>
|
||||
{selectedOrder.item_price && (
|
||||
|
||||
@@ -1280,7 +1280,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="86400"
|
||||
max="3600"
|
||||
value={variant.delay_seconds || 0}
|
||||
onChange={event => updateVariant(index, { delay_seconds: Math.max(0, Number(event.target.value) || 0) })}
|
||||
className="w-28 ios-input px-2 py-1.5 rounded-lg text-xs"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { LayoutDashboard, Users, ShoppingBag, CreditCard, Settings, LogOut, Box, Sparkles, Zap, Bell } from 'lucide-react';
|
||||
import { YdisksBrandIcon } from './YdisksLogo';
|
||||
|
||||
interface SidebarProps {
|
||||
activeTab: string;
|
||||
@@ -24,8 +25,8 @@ const Sidebar: React.FC<SidebarProps> = ({ activeTab, isAdmin = false, onNavigat
|
||||
<div className="w-64 h-screen fixed left-0 top-0 bg-white border-r border-gray-100 flex flex-col justify-between z-20 shadow-[4px_0_24px_rgba(0,0,0,0.02)]">
|
||||
<div className="p-6">
|
||||
<div className="flex items-center gap-3 mb-12 px-2">
|
||||
<div className="w-10 h-10 bg-[#0094f7] squircle flex items-center justify-center shrink-0 p-1.5" style={{ filter: 'drop-shadow(0 4px 12px rgba(0,148,247,0.25))' }}>
|
||||
<img src="/static/ydisks-logo.svg" alt="Ydisks" className="w-full h-full" />
|
||||
<div className="shrink-0">
|
||||
<YdisksBrandIcon sizeClass="w-10 h-10" />
|
||||
</div>
|
||||
<h1 className="text-xl font-extrabold tracking-tight text-gray-900">Ydisks闲鱼助手 <span className="text-xs bg-[#0094f7] text-white px-1.5 py-0.5 rounded ml-1">PRO</span></h1>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import YdisksLogo, { YdisksBrandIcon } from './YdisksLogo';
|
||||
|
||||
describe('YdisksLogo', () => {
|
||||
test('uses the complete 256px brand coordinate system', () => {
|
||||
const html = renderToStaticMarkup(<YdisksLogo />);
|
||||
expect(html).toContain('viewBox="0 0 256 256"');
|
||||
expect(html).toContain('M121.73,57.0003');
|
||||
expect(html).toContain('fill="currentColor"');
|
||||
});
|
||||
|
||||
test('renders the complete gradient squircle brand wrapper', () => {
|
||||
const html = renderToStaticMarkup(<YdisksBrandIcon />);
|
||||
expect(html).toContain('viewBox="0 0 120 120"');
|
||||
expect(html).toContain('id="login-squircle-gradient"');
|
||||
expect(html).toContain('M 114.00 60.00');
|
||||
expect(html).toContain('w-12 h-12');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
|
||||
interface YdisksLogoProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
interface YdisksBrandIconProps {
|
||||
sizeClass?: string;
|
||||
logoClassName?: string;
|
||||
}
|
||||
|
||||
const YdisksLogo: React.FC<YdisksLogoProps> = ({ className = 'w-full h-full text-white' }) => (
|
||||
<svg className={className} viewBox="0 0 256 256" aria-hidden="true">
|
||||
<g stroke="none" fill="none" fillRule="evenodd">
|
||||
<path d="M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z" fill="currentColor" />
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const YdisksBrandIcon: React.FC<YdisksBrandIconProps> = ({
|
||||
sizeClass = 'w-12 h-12',
|
||||
logoClassName = 'w-full h-full text-white',
|
||||
}) => (
|
||||
<div className="relative z-10 flex items-center justify-center">
|
||||
<div className="absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25" />
|
||||
<div className={`relative ${sizeClass} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`}>
|
||||
<svg className="absolute inset-0 w-full h-full" viewBox="0 0 120 120" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="login-squircle-gradient" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stopColor="#0094f7" />
|
||||
<stop offset="100%" stopColor="#287efe" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<path d="M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z" fill="url(#login-squircle-gradient)" />
|
||||
</svg>
|
||||
<div className="relative z-10 flex items-center justify-center w-full h-full">
|
||||
<YdisksLogo className={logoClassName} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default YdisksLogo;
|
||||
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import type { Card } from '../types';
|
||||
import { filterCards } from './cardListState';
|
||||
|
||||
const cards = [
|
||||
{ id: 1, name: '年终总结 PPT', type: 'text' },
|
||||
{ id: 2, name: '年终总结兑换码', type: 'data' },
|
||||
{ id: 3, name: '产品介绍 PPT', type: 'text' },
|
||||
] as Card[];
|
||||
|
||||
describe('filterCards', () => {
|
||||
test('combines type and name filters with AND semantics', () => {
|
||||
expect(filterCards(cards, 'text', '年终')).toEqual([cards[0]]);
|
||||
});
|
||||
|
||||
test('matches names case-insensitively and ignores surrounding whitespace', () => {
|
||||
expect(filterCards(cards, '', ' ppt ')).toEqual([cards[0], cards[2]]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { Card } from '../types';
|
||||
|
||||
export const filterCards = (
|
||||
cards: Card[],
|
||||
typeFilter: Card['type'] | '',
|
||||
nameSearch: string,
|
||||
): Card[] => {
|
||||
const keyword = nameSearch.trim().toLocaleLowerCase();
|
||||
return cards.filter(card => (
|
||||
(!typeFilter || card.type === typeFilter)
|
||||
&& (!keyword || card.name.toLocaleLowerCase().includes(keyword))
|
||||
));
|
||||
};
|
||||
Reference in new issue
Block a user