合并 dev 分支仪表盘优化与文档更新
This commit is contained in:
commit
ad224bf4e9
10 files changed
+196
-68
No files matched your search
@@ -164,6 +164,9 @@ npm --prefix frontend ci
|
||||
npm --prefix frontend run build
|
||||
```
|
||||
|
||||
前端资源会在构建时通过 Go 的 `//go:embed` 嵌入服务;如果服务已经在运行,构建完成后
|
||||
需要重启 Go 服务,浏览器硬刷新本身不会替换运行中进程已加载的前端资源。
|
||||
|
||||
初始化管理员:
|
||||
|
||||
```bash
|
||||
|
||||
+12
-2
@@ -33,7 +33,15 @@ npm run build
|
||||
```
|
||||
|
||||
产物写入 `../internal/webui/static/`,由 Go 服务通过 `//go:embed` 内嵌并服务于 `/static/*`。
|
||||
生产部署无需单独分发前端,构建一次即可。
|
||||
生产部署无需单独分发前端。若 Go 服务已经运行,构建完成后必须重启 Go 服务,
|
||||
因为嵌入资源在 Go 编译时写入服务二进制;仅刷新浏览器不会更新已运行进程中的前端版本。
|
||||
|
||||
## Dashboard 图表约定
|
||||
|
||||
Dashboard 的营收趋势柱状图使用统一的品牌蓝 `#0094f7` 表示同一指标序列,日期之间
|
||||
只通过柱高区分营收,不使用不同颜色表达不同类别。饼图使用中心汇总值、图例和悬浮提示
|
||||
展示明细;悬停扇区会轻微放大。图表是展示型组件,点击或键盘焦点不会显示浏览器默认
|
||||
的粗蓝色 SVG 焦点框,避免被误解为业务选中状态。
|
||||
|
||||
## 路由
|
||||
|
||||
@@ -43,5 +51,7 @@ npm run build
|
||||
## 测试
|
||||
|
||||
```bash
|
||||
npx vitest run # 路由一致性、请求工具等单测
|
||||
npm test # 前端单元测试
|
||||
npm run typecheck # TypeScript 类型检查
|
||||
npm run build # 构建并更新 Go 嵌入资源
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { StatusBadge } from './Dashboard';
|
||||
|
||||
const dashboardSource = readFileSync(resolve(__dirname, 'Dashboard.tsx'), 'utf8');
|
||||
const globalStyles = readFileSync(resolve(__dirname, '../index.css'), 'utf8');
|
||||
|
||||
describe('Dashboard presentation safeguards', () => {
|
||||
test('keeps order status badges on one line', () => {
|
||||
const html = renderToStaticMarkup(<StatusBadge status="shipped" />);
|
||||
|
||||
expect(html).toContain('已发货');
|
||||
expect(html).toContain('inline-flex');
|
||||
expect(html).toContain('whitespace-nowrap');
|
||||
expect(dashboardSource).toContain('min-w-[760px]');
|
||||
});
|
||||
|
||||
test('pie charts use enlarged active sectors without focus rings or external label lines', () => {
|
||||
expect(dashboardSource.match(/accessibilityLayer=\{false\}/g)).toHaveLength(2);
|
||||
expect(dashboardSource.match(/activeShape=\{\{/g)).toHaveLength(2);
|
||||
expect(dashboardSource).toContain('outerRadius: 96');
|
||||
expect(dashboardSource).toContain('outerRadius: 98');
|
||||
expect(dashboardSource.match(/stroke: 'none'/g)).toHaveLength(2);
|
||||
expect(dashboardSource.match(/strokeWidth: 0/g)).toHaveLength(2);
|
||||
expect(dashboardSource.match(/rootTabIndex=\{-1\}/g)).toHaveLength(2);
|
||||
expect(dashboardSource.match(/label=\{false\}/g)).toHaveLength(2);
|
||||
expect(dashboardSource.match(/labelLine=\{false\}/g)).toHaveLength(2);
|
||||
expect(dashboardSource.match(/wrapperStyle=\{\{ zIndex: 30, outline: 'none' \}\}/g)).toHaveLength(2);
|
||||
expect(dashboardSource.match(/absolute inset-0 z-10/g)).toHaveLength(2);
|
||||
expect(globalStyles).toContain('.dashboard-pie-chart .recharts-sector:focus');
|
||||
expect(dashboardSource).toContain('dashboard-revenue-chart h-[350px] w-full');
|
||||
expect(dashboardSource).toContain('activeBar={false}');
|
||||
expect(dashboardSource).not.toContain('stroke="#000000"');
|
||||
expect(dashboardSource).not.toContain("['#0094f7', '#FCD34D', '#0071e3']");
|
||||
expect(dashboardSource).toContain('fill="#0094f7"');
|
||||
expect(globalStyles).toContain('.dashboard-revenue-chart .recharts-rectangle:focus');
|
||||
expect(globalStyles).toContain('.dashboard-revenue-chart .recharts-curve:focus');
|
||||
expect(globalStyles).toContain('.dashboard-revenue-chart [class*="recharts-zIndex-layer_"]:focus');
|
||||
expect(globalStyles).toContain('stroke: none !important');
|
||||
});
|
||||
});
|
||||
@@ -7,7 +7,7 @@ import { TrendingUp, Users, ShoppingCart, AlertCircle, DollarSign, Activity, Pac
|
||||
import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, BarChart, Bar, PieChart, Pie, Cell, Legend } from 'recharts';
|
||||
|
||||
// 状态徽章组件
|
||||
const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => {
|
||||
export const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => {
|
||||
const styles = {
|
||||
processing: 'bg-blue-100 text-blue-800',
|
||||
pending_ship: 'bg-[#0094f7] text-white',
|
||||
@@ -29,7 +29,7 @@ const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<span className={`px-3 py-1.5 rounded-lg text-xs font-bold ${styles[status] || styles.cancelled}`}>
|
||||
<span className={`inline-flex items-center justify-center whitespace-nowrap px-3 py-1.5 rounded-lg text-xs leading-none font-bold ${styles[status] || styles.cancelled}`}>
|
||||
{labels[status] || status}
|
||||
</span>
|
||||
);
|
||||
@@ -341,7 +341,7 @@ const Dashboard: React.FC = () => {
|
||||
<h3 className="text-xl font-bold text-gray-900">营收趋势分析</h3>
|
||||
<p className="text-sm text-gray-400 mt-1">{selectedRangeLabel}的销售额走势</p>
|
||||
</div>
|
||||
<div className="h-[350px] w-full">
|
||||
<div className="dashboard-revenue-chart h-[350px] w-full">
|
||||
{chartData.length === 0 || analytics.revenue_stats.total_amount === 0 ? (
|
||||
<div className="h-full flex flex-col items-center justify-center text-gray-400">
|
||||
<ShoppingCart className="w-16 h-16 mb-4 opacity-20" />
|
||||
@@ -386,11 +386,17 @@ const Dashboard: React.FC = () => {
|
||||
fill="#0094f7"
|
||||
maxBarSize={72}
|
||||
radius={[12, 12, 0, 0]}
|
||||
stroke="#000000"
|
||||
activeBar={false}
|
||||
stroke="none"
|
||||
strokeWidth={0}
|
||||
>
|
||||
{chartData.map((entry, index) => (
|
||||
<Cell key={`cell-${index}`} fill={['#0094f7', '#FCD34D', '#0071e3'][index % 3]} />
|
||||
{chartData.map((_, index) => (
|
||||
<Cell
|
||||
key={`cell-${index}`}
|
||||
fill="#0094f7"
|
||||
stroke="none"
|
||||
strokeWidth={0}
|
||||
/>
|
||||
))}
|
||||
</Bar>
|
||||
</BarChart>
|
||||
@@ -474,35 +480,61 @@ const Dashboard: React.FC = () => {
|
||||
{/* 商品下单占比 */}
|
||||
<div className="ios-card p-6 rounded-xl">
|
||||
<h3 className="font-bold text-lg text-gray-900 mb-6">商品下单占比</h3>
|
||||
<div className="h-[280px]">
|
||||
<div
|
||||
className="dashboard-pie-chart h-[280px] relative"
|
||||
role="img"
|
||||
aria-label={`商品下单占比,共 ${totalOrders} 单`}
|
||||
>
|
||||
{sourceDataData.length === 0 ? (
|
||||
<div className="flex items-center justify-center h-full text-gray-400">暂无数据</div>
|
||||
) : (
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<Pie
|
||||
data={sourceDataData}
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
innerRadius={60}
|
||||
outerRadius={90}
|
||||
paddingAngle={2}
|
||||
dataKey="value"
|
||||
label={({ name, payload }) => `${name} ${Number(payload?.percent || 0).toFixed(1)}%`}
|
||||
labelLine={false}
|
||||
>
|
||||
{sourceDataData.map((entry, index) => (
|
||||
<Cell key={`cell-${index}`} fill={entry.color} />
|
||||
))}
|
||||
</Pie>
|
||||
<Legend
|
||||
verticalAlign="bottom"
|
||||
height={36}
|
||||
iconType="circle"
|
||||
formatter={(value) => <span style={{ color: '#6B7280', fontWeight: 500 }}>{value}</span>}
|
||||
/>
|
||||
</PieChart>
|
||||
</ResponsiveContainer>
|
||||
<>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart accessibilityLayer={false}>
|
||||
<Pie
|
||||
data={sourceDataData}
|
||||
cx="50%"
|
||||
cy="45%"
|
||||
innerRadius={60}
|
||||
outerRadius={90}
|
||||
paddingAngle={2}
|
||||
dataKey="value"
|
||||
activeShape={{
|
||||
outerRadius: 96,
|
||||
stroke: 'none',
|
||||
strokeWidth: 0,
|
||||
}}
|
||||
rootTabIndex={-1}
|
||||
label={false}
|
||||
labelLine={false}
|
||||
>
|
||||
{sourceDataData.map((entry, index) => (
|
||||
<Cell key={`cell-${index}`} fill={entry.color} />
|
||||
))}
|
||||
</Pie>
|
||||
<Tooltip
|
||||
formatter={(value) => `${Number(value || 0)} 单`}
|
||||
wrapperStyle={{ zIndex: 30, outline: 'none' }}
|
||||
contentStyle={{
|
||||
backgroundColor: '#fff',
|
||||
border: '1px solid #e5e7eb',
|
||||
borderRadius: '10px',
|
||||
boxShadow: '0 8px 20px rgba(15, 23, 42, 0.08)'
|
||||
}}
|
||||
/>
|
||||
<Legend
|
||||
verticalAlign="bottom"
|
||||
height={36}
|
||||
iconType="circle"
|
||||
formatter={(value) => <span style={{ color: '#6B7280', fontWeight: 500 }}>{value}</span>}
|
||||
/>
|
||||
</PieChart>
|
||||
</ResponsiveContainer>
|
||||
<div className="pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center pb-9">
|
||||
<span className="text-2xl font-extrabold text-gray-900 tabular-nums">{totalOrders}</span>
|
||||
<span className="text-xs font-medium text-gray-400 mt-0.5">总订单</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -559,13 +591,13 @@ const Dashboard: React.FC = () => {
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<table className="w-full text-left border-collapse">
|
||||
<table className="w-full min-w-[760px] 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-6 py-4">订单信息</th>
|
||||
<th className="px-6 py-4">买家信息</th>
|
||||
<th className="px-6 py-4">金额</th>
|
||||
<th className="px-6 py-4">状态</th>
|
||||
<th className="px-6 py-4 whitespace-nowrap">状态</th>
|
||||
<th className="px-6 py-4 text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -595,7 +627,7 @@ const Dashboard: React.FC = () => {
|
||||
<td className="px-6 py-4 text-base font-extrabold text-gray-900 font-feature-settings-tnum">
|
||||
¥{order.amount || '0.00'}
|
||||
</td>
|
||||
<td className="px-6 py-4">
|
||||
<td className="px-6 py-4 whitespace-nowrap">
|
||||
<StatusBadge status={order.status || order.order_status || 'unknown'} />
|
||||
</td>
|
||||
<td className="px-6 py-4 text-right">
|
||||
@@ -624,24 +656,36 @@ const Dashboard: React.FC = () => {
|
||||
<div className="flex items-center justify-center h-[300px] text-gray-400">暂无数据</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="h-[300px] relative">
|
||||
<div
|
||||
className="dashboard-pie-chart h-[280px] relative"
|
||||
role="img"
|
||||
aria-label={`商品金额分析,总金额 ${formatCurrency(totalAmount)}`}
|
||||
>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<PieChart accessibilityLayer={false}>
|
||||
<Pie
|
||||
data={categoryDataData}
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
innerRadius={60}
|
||||
outerRadius={100}
|
||||
outerRadius={92}
|
||||
paddingAngle={2}
|
||||
dataKey="value"
|
||||
label={({ name, payload }) => `${name} ${payload?.percentage || '0.0'}%`}
|
||||
activeShape={{
|
||||
outerRadius: 98,
|
||||
stroke: 'none',
|
||||
strokeWidth: 0,
|
||||
}}
|
||||
rootTabIndex={-1}
|
||||
label={false}
|
||||
labelLine={false}
|
||||
>
|
||||
{categoryDataData.map((entry, index) => (
|
||||
<Cell key={`cell-${index}`} fill={entry.color || COLORS[index % COLORS.length]} />
|
||||
))}
|
||||
</Pie>
|
||||
<Tooltip
|
||||
wrapperStyle={{ zIndex: 30, outline: 'none' }}
|
||||
contentStyle={{
|
||||
backgroundColor: '#fff',
|
||||
border: '1px solid #e5e7eb',
|
||||
@@ -652,18 +696,22 @@ const Dashboard: React.FC = () => {
|
||||
/>
|
||||
</PieChart>
|
||||
</ResponsiveContainer>
|
||||
<div className="pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center">
|
||||
<span className="text-lg font-extrabold text-gray-900 tabular-nums">{formatCurrency(totalAmount)}</span>
|
||||
<span className="text-xs font-medium text-gray-400 mt-0.5">总金额</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-3 mt-4">
|
||||
{categoryDataData.map((cat) => (
|
||||
<div key={cat.name} className="flex justify-between items-center text-sm">
|
||||
<div className="flex items-center gap-2">
|
||||
<div key={cat.name} className="flex justify-between items-center gap-3 text-sm">
|
||||
<div className="flex items-center gap-2 min-w-0 flex-1">
|
||||
<div
|
||||
className="w-3 h-3 rounded-full"
|
||||
className="w-3 h-3 rounded-full shrink-0"
|
||||
style={{ backgroundColor: cat.color || COLORS[categoryDataData.indexOf(cat) % COLORS.length] }}
|
||||
></div>
|
||||
<span className="text-gray-600 font-medium">{cat.name}</span>
|
||||
<span className="text-gray-600 font-medium truncate" title={cat.name}>{cat.name}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex items-center gap-3 shrink-0 whitespace-nowrap">
|
||||
<span className="font-bold text-gray-900">¥{cat.value.toLocaleString()}</span>
|
||||
<span className="text-xs text-gray-500 bg-gray-100 px-2 py-0.5 rounded">{cat.percentage}%</span>
|
||||
</div>
|
||||
|
||||
@@ -53,6 +53,29 @@ body {
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
/* 仪表盘饼图是展示型图表,避免 Recharts 的 SVG 焦点框和扇区焦点框形成无意义长条。 */
|
||||
.dashboard-pie-chart .recharts-surface:focus,
|
||||
.dashboard-pie-chart .recharts-pie:focus,
|
||||
.dashboard-pie-chart .recharts-pie-sector:focus,
|
||||
.dashboard-pie-chart .recharts-sector:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* 营收柱形/折线图的数据图形点击后不显示浏览器默认的粗蓝色 SVG 焦点框。 */
|
||||
.dashboard-revenue-chart .recharts-surface:focus,
|
||||
.dashboard-revenue-chart .recharts-bar-rectangle:focus,
|
||||
.dashboard-revenue-chart .recharts-rectangle:focus,
|
||||
.dashboard-revenue-chart .recharts-curve:focus,
|
||||
.dashboard-revenue-chart .recharts-dot:focus,
|
||||
.dashboard-revenue-chart [class*="recharts-zIndex-layer_"]:focus {
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.dashboard-revenue-chart .recharts-bar-rectangle,
|
||||
.dashboard-revenue-chart .recharts-rectangle {
|
||||
stroke: none !important;
|
||||
}
|
||||
|
||||
/* 闲鱼风格输入框 */
|
||||
.ios-input {
|
||||
background: #F7F8FA;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import{j as e,r as n,b as Le,c as ba,d as ya}from"./react-vendor-DZnRGM0-.js";import{L as fa,U as Wt,S as Vt,C as Zs,B as Gt,Z as Xs,a as ys,b as it,c as Jt,d as ja,e as cs,A as gt,D as Na,f as bt,P as Kt,g as Ls,E as Qt,T as va,h as wa,i as $e,Q as Ws,j as ds,k as ss,l as bs,m as yt,R as qe,n as Yt,o as _a,p as Je,X as we,K as ka,q as os,r as rs,s as as,t as ts,u as ft,v as As,w as fs,x as Zt,y as Xt,z as Ss,F as Ht,G as Ca,H as jt,I as Nt,J as Sa,M as La,N as Aa,O as Ia,V as Vs,W as $s,Y as Hs,_ as $a,$ as Ra,a0 as et,a1 as Pa,a2 as Da,a3 as st,a4 as vt,a5 as Ta,a6 as Ms,a7 as ea,a8 as Fa,a9 as Ea,aa as ot,ab as sa,ac as Ma,ad as Oa}from"./icons-vendor-RenKjhri.js";import{R as Rs,B as qa,X as wt,Y as _t,T as Ps,a as Ba,C as Gs,A as za,b as Ua,c as Wa,P as kt,d as Ct,L as Va}from"./charts-vendor-B_BfwiL0.js";import"./vendor-w5t2K9ux.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const x of document.querySelectorAll('link[rel="modulepreload"]'))d(x);new MutationObserver(x=>{for(const w of x)if(w.type==="childList")for(const L of w.addedNodes)L.tagName==="LINK"&&L.rel==="modulepreload"&&d(L)}).observe(document,{childList:!0,subtree:!0});function r(x){const w={};return x.integrity&&(w.integrity=x.integrity),x.referrerPolicy&&(w.referrerPolicy=x.referrerPolicy),x.crossOrigin==="use-credentials"?w.credentials="include":x.crossOrigin==="anonymous"?w.credentials="omit":w.credentials="same-origin",w}function d(x){if(x.ep)return;x.ep=!0;const w=r(x);fetch(x.href,w)}})();const Ga=({className:s="w-full h-full text-white"})=>e.jsx("svg",{className:s,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),tt=({sizeClass:s="w-12 h-12",logoClassName:t="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${s} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0094f7"}),e.jsx("stop",{offset:"100%",stopColor:"#287efe"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 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 88Line 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(it,{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:us,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:c,children:"取消"}),e.jsxs("button",{onClick:Z,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:c,children:[c?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(as,{className:"w-4 h-4"}),c?"保存中...":"保存"]})]})})]})}),document.body)]})},vr=s=>({total:Number((s==null?void 0:s.total)||0),success_count:Number((s==null?void 0:s.success_count)||0),failed_count:Number((s==null?void 0:s.failed_count)||0),results:Array.isArray(s==null?void 0:s.results)?s.results.map(t=>({order_id:String((t==null?void 0:t.order_id)||"unknown"),success:(t==null?void 0:t.success)===!0,message:String((t==null?void 0:t.message)||"")})):[]}),wr=s=>(s==null?void 0:s.results.filter(t=>!t.success))||[],Tt=({status:s})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},r={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:r[s]||s})},_r=()=>{const[s,t]=n.useState([]),[r,d]=n.useState([]),[x,w]=n.useState([]),[L,F]=n.useState({}),[g,D]=n.useState("all"),[y,G]=n.useState(""),[ee,ae]=n.useState(""),[ie,S]=n.useState(""),q=n.useRef(0),[le,J]=n.useState(1),[Y,B]=n.useState(1),[me,oe]=n.useState(!1),[k,E]=n.useState(!1),[U,V]=n.useState(!1),[ue,A]=n.useState(!1),[R,K]=n.useState(null),[I,he]=n.useState(null),[_e,Ne]=n.useState({}),[re,m]=n.useState(!1),[h,z]=n.useState(""),[j,X]=n.useState(!1),[se,ne]=n.useState(null),[ve,$]=n.useState(null),[i,T]=n.useState(null),[b,c]=n.useState(!1),[_,C]=n.useState(null),[M,te]=n.useState(null),H=async()=>{const u=++q.current;oe(!0);try{const P=await yl(y||void 0,g,le,20,ie);if(u!==q.current)return;t(P.data),B(P.total_pages)}catch(P){console.error("加载订单失败:",P)}finally{u===q.current&&oe(!1)}},ce=(u,P,de)=>{if(de&&de.trim())return de;if(L[`${u}:${P}`])return L[`${u}:${P}`];const Ce=r.find(Ye=>{if(de&&Ye.item_title){const Ze=de.toLowerCase(),Xe=Ye.item_title.toLowerCase();return Xe.includes(Ze)||Ze.includes(Xe)}return!1});return Ce!=null&&Ce.item_title?Ce.item_title:"未知商品"},be=u=>{const P={};u.forEach(de=>{de.item_id&&(P[`${de.cookie_id}:${de.item_id}`]=de.item_title||de.item_id)}),F(P)};n.useEffect(()=>{const u=window.setTimeout(()=>{J(1),S(ee.trim())},300);return()=>window.clearTimeout(u)},[ee]),n.useEffect(()=>{H()},[y,g,le,ie]),n.useEffect(()=>{Promise.all([Bs(),js()]).then(([u,P])=>{w(u),d(P),be(P)}).catch(u=>{console.error("加载商品列表失败:",u)})},[]);const ke=n.useMemo(()=>new Map(x.map(u=>[u.id,u])),[x]),Re=u=>{const P=ke.get(u),de=(P==null?void 0:P.remark)||(P==null?void 0:P.nickname);return de?`${de} · ${u.slice(0,6)}`:`账号 ${u.slice(0,8)}`},Ie=u=>{const P=ke.get(u);return(P==null?void 0:P.remark)||(P==null?void 0:P.nickname)||"未命名账号"},Fe=async()=>{oe(!0);try{const u=await Nl(y||void 0,g);await H(),u!=null&&u.message&&alert(u.message)}catch(u){console.error("同步订单失败:",u),alert((u==null?void 0:u.message)||"同步失败,请重试")}finally{oe(!1)}},Be=u=>{z(u),ne(null),m(!0)},Ee=async u=>{var P;X(!0),ne(null);try{const de=await wl([h],u),Ce=(P=de==null?void 0:de.results)==null?void 0:P[0];Ce!=null&&Ce.success?(ne({success:!0,message:Ce.message}),H()):ne({success:!1,message:(Ce==null?void 0:Ce.message)||"发货失败"})}catch(de){ne({success:!1,message:(de==null?void 0:de.message)||"请求失败"})}finally{X(!1)}},Ve=u=>{K(u),E(!0)},Me=u=>{he({...u}),V(!0)},Pe=async()=>{if(!(!I||!I.order_id))try{const u={};I.status!==void 0&&(u.order_status=I.status),I.buyer_id!==void 0&&(u.buyer_id=I.buyer_id),I.amount!==void 0&&(u.amount=I.amount),I.receiver_name!==void 0&&(u.receiver_name=I.receiver_name),I.receiver_p
Line truncated
|
||||
VIP-MONTH-002
|
||||
VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(M=>M.map(te=>`"${String(te).replace(/"/g,'""')}"`).join(",")).join(`
|
||||
`),c=new Blob(["\uFEFF"+b],{type:"text/csv;charset=utf-8"}),_=URL.createObjectURL(c),C=document.createElement("a");C.href=_,C.download="卡密组批量导入模板.csv",document.body.appendChild(C),C.click(),C.remove(),URL.revokeObjectURL(_)},ne=async()=>{if(q){me(!0),Y(null);try{const i=await Il(q);if(Y(i),i.created>0){const T=await es();t(T)}}catch(i){Y({error:(i==null?void 0:i.message)||"上传失败"})}finally{me(!1)}}},ve=async()=>{if(!(!oe||!E.trim())){me(!0),ue(null);try{const i=await $l(oe,E);ue({added:i.added}),U("");const T=await es();t(T)}catch(i){alert("追加失败:"+((i==null?void 0:i.message)||"未知错误"))}finally{me(!1)}}},$=()=>{var i;S("create"),le(null),Y(null),k((i=j[0])!=null&&i.id?String(j[0].id):""),U(""),ue(null),ae(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:$,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Ss,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>w(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(ts,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-[#FAFAFA] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(Ht,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:A,onChange:i=>R(i.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(As,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:K,onChange:i=>I(i.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",X.length," / ",s.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:X.map(i=>{let T="";return i.type==="data"&&i.data_content?T=`库存: ${i.data_content.split(`
|
||||
`).filter(c=>c.trim()).length} 条`:i.type==="text"&&i.text_content?T=i.text_content:i.type==="api"&&i.api_config?T=i.api_config.url:i.type==="image"&&i.image_url&&(T="图片链接"),e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(he,{type:i.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:i.name,children:i.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>z(i.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:i.id}),e.jsx(Ca,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${i.type==="text"?"bg-blue-50 text-blue-600":i.type==="data"?"bg-purple-50 text-purple-600":i.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:i.type==="text"?"文本":i.type==="data"?"批量":i.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:T,children:T})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:i.description||"-",children:i.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>h(i),className:`w-12 h-8 rounded-full relative transition-colors ${i.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${i.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>_e(i),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(fs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>re(i.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Je,{className:"h-4 w-4"})})]})})]},i.id)})})]})}),X.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(Kt,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:s.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),r&&L&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>d(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(we,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:g.name||"",onChange:i=>D({...g,name:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:g.type||"text",onChange:i=>D({...g,type:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(L==null?void 0:L.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),g.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:g.api_url||"",onChange:i=>D({...g,api_url:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxLine truncated
|
||||
卡号1:密码1
|
||||
卡号2:密码2
|
||||
或者
|
||||
兑换码1
|
||||
兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:g.data_content?g.data_content.split(`
|
||||
`).filter(i=>i.trim()).length:0})," 条"]})]})]}),g.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:g.image_url||"",onChange:i=>D({...g,image_url:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),g.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:g.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:i=>{i.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:g.delay_seconds||0,onChange:i=>D({...g,delay_seconds:parseInt(i.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:g.description||"",onChange:i=>D({...g,description:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>D({...g,enabled:!g.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${g.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${g.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>d(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Ne,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),x&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>w(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(we,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:y.name,onChange:i=>G({...y,name:i.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>G({...y,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${y.type==="data"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(Zs,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>G({...y,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${y.type==="text"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(jt,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>G({...y,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${y.type==="image"?"bg-[#0094f7] text-white":"bg-gray-100 text-grayLine truncated
|
||||
CODE-789012
|
||||
...`:"请输入每次发货时发送的固定文字"}),y.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-[#0094f7]",children:y.content.split(`
|
||||
`).filter(i=>i.trim()).length})," 条"]})]}),y.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:y.api_method,onChange:i=>G({...y,api_method:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:y.api_timeout,onChange:i=>G({...y,api_timeout:parseInt(i.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:y.api_headers,onChange:i=>G({...y,api_headers:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:y.api_params,onChange:i=>G({...y,api_params:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:y.description,onChange:i=>G({...y,description:i.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:y.delay_seconds,onChange:i=>G({...y,delay_seconds:parseInt(i.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:m,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),ee&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>ae(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(we,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>S("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${ie==="create"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Sa,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>S("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${ie==="append"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Ss,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),ie==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:se,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 tex
Line truncated
|
||||
VIP-002
|
||||
VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),V&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",V.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>ae(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),ie==="create"?e.jsxs("button",{onClick:ne,disabled:!q||B,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[B?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(Ss,{className:"w-4 h-4"}),B?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:ve,disabled:!oe||!E.trim()||B||j.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[B?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(ts,{className:"w-4 h-4"}),B?"处理中...":"追加卡密"]})]})]})}),document.body)]})},Sr=s=>s.find(t=>t.status==="running"||t.status==="canceling"),Lr=s=>{const t=String(s||"").trim();return t?/^[¥¥]/.test(t)?t:`¥${t}`:"-"},Ar=({onConfigureDelivery:s})=>{const[t,r]=n.useState([]),[d,x]=n.useState([]),[w,L]=n.useState([]),[F,g]=n.useState(""),[D,y]=n.useState(""),[G,ee]=n.useState(!1),[ae,ie]=n.useState(!1),[S,q]=n.useState(!1),[le,J]=n.useState(!1),[Y,B]=n.useState(!1),[me,oe]=n.useState(!1),[k,E]=n.useState(!1),[U,V]=n.useState("upload"),[ue,A]=n.useState(null),[R,K]=n.useState(null),[I,he]=n.useState(""),[_e,Ne]=n.useState(!1),[re,m]=n.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[h,z]=n.useState(null),[j,X]=n.useState(null),[se,ne]=n.useState(null),ve=n.useRef(!1),[$,i]=n.useState(null),[T,b]=n.useState({}),[c,_]=n.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[C,M]=n.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[te,H]=n.useState([]);n.useEffect(()=>{if(!me||C.images.length===0){H([]);return}const l=C.images.map((N,Z)=>({key:N.name+Z,url:URL.createObjectURL(N)}));return H(l),()=>{l.forEach(N=>URL.revokeObjectURL(N.url))}},[me,C.images]);const ce=async()=>{const l=await js();r(l)},be=async()=>{x(await lt())};n.useEffect(()=>{Promise.all([Bs(),js(),lt(),It(20)]).then(([l,N,Z,We])=>{L(l),r(N),x(Z);const Ge=We.find(De=>["running","canceling"].includes(De.status))||We.find(De=>De.status!=="preview");ne(Ge||null)}).catch(l=>console.error("加载商品配置失败:",l))},[]),n.useEffect(()=>{if(!k||!(j!=null&&j.id)||!["running","canceling"].includes(j.status))return;const l=window.setInterval(async()=>{if(!ve.current){ve.current=!0;try{const N=await hs(j.id);X(N),ne(N),["running","canceling"].includes(N.status)||(V("done"),await ce(),await be())}catch(N){console.error("刷新批量铺货进度失败:",N)}finally{ve.current=!1}}},3e3);return()=>{window.clearInterval(l)}},[k,j==null?void 0:j.id,j==null?void 0:j.status]);const ke=async()=>{if(!F)return alert("请先选择账号");ee(!0);try{const l=await Rl(F);await ce(),alert((l==null?void 0:l.message)||"商品同步完成")}catch(l){console.error("同步商品失败:",l),alert((l==null?void 0:l.message)||"同步失败,请重试")}finally{ee(!1)}},Re=l=>{i(l),b({...l}),J(!0)},Ie=async()=>{if($)try{await zl($.cookie_id,$.item_id,{item_title:T.item_title||"",item_description:T.item_description||"",item_category:T.item_category||"",item_price:T.item_price||"",item_detail:T.item_detail||$.item_detail||""}),await ce(),await be(),J(!1),i(null)}catch(l){console.error("更新商品失败:",l),alert("更新失败,请重试")}},Fe=async l=>{if(confirm(`确认删除商品"${l.item_title}"吗?`))try{await Pl(l.cookie_id,l.item_id),r(N=>N.filter(Z=>!(Z.cookie_id===l.cookie_id&&Z.item_id===l.item_id)))}catch(N){console.error("删除商品失败:",N),alert("删除失败,请重试")}},Be=async()=>{try{if(!c.cookie_id||!c.item_id){alert("请选择账号并填写商品ID");return}await Dl(c.cookie_id,{item_id:c.item_id,item_title:c.item_title,item_price:c.item_price,item_detail:c.item_image?JSON.stringify({item_image:c.item_image}):""}),await ce(),B(!1),_({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(l){console.error("添加商品失败:",l),alert("添加失败,请重试")}},Ee=async()=>{if(!C.cookie_id)return alert("请选择发布账号");if(!C.title.trim())return alert("请填写商品标题");if(!C.price.trim())return alert("请填写商品价格");if(!C.quantity||Number(C.quantity)<=0)return alert("库存数量必须大于 0");if(C.images.length===0)return alert("至少上传 1 张商品图片");if(C.postage_mode==="fixed"&&!C
Line truncated
|
||||
`),We=new Blob(["\uFEFF"+Z],{type:"text/csv;charset=utf-8"}),Ge=URL.createObjectURL(We),De=document.createElement("a");De.href=Ge,De.download="批量铺货模板.csv",document.body.appendChild(De),De.click(),De.remove(),URL.revokeObjectURL(Ge)},Ce=()=>{_(l=>({...l,cookie_id:F||l.cookie_id})),B(!0)},Ye=()=>{M(l=>({...l,cookie_id:F||l.cookie_id})),oe(!0)},Ze=l=>d.filter(N=>N.cookie_id===l.cookie_id&&N.item_id===l.item_id).length>0?d.filter(N=>N.cookie_id===l.cookie_id&&N.item_id===l.item_id):d.filter(N=>N.cookie_id===l.cookie_id&&!N.item_id),Xe=l=>{switch(l){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return l||"-"}},ze=l=>{switch(l){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},Ue=n.useMemo(()=>new Map(w.map(l=>[l.id,l])),[w]),xs=n.useMemo(()=>D?t.filter(l=>l.cookie_id===D):t,[D,t]),He=l=>{const N=Ue.get(l),Z=(N==null?void 0:N.remark)||(N==null?void 0:N.nickname);return Z?`${Z} · ${l.slice(0,6)}`:`账号 ${l.slice(0,8)}`},ms=l=>{const N=Ue.get(l);return(N==null?void 0:N.remark)||(N==null?void 0:N.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ia,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:D,onChange:l=>y(l.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(ds,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:F,onChange:l=>g(l.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]})]})]}),e.jsxs("button",{onClick:ke,disabled:G||!F,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(qe,{className:`w-4 h-4 ${G?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:Ce,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(ts,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:Ye,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Vs,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Ve(),className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx($s,{className:"w-4 h-4"}),se&&["running","canceling"].includes(se.status)?"继续批量任务":"批量铺货"]}),se&&!["running","canceling"].includes(se.status)&&e.jsx("button",{onClick:()=>void Pe(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[xs.map(l=>{const N=Ze(l),Z=N.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relat
Line truncated
|
||||
@@ -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(59 130 246 / .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(59 130 246 / .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:#e5e7eb}: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:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}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}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.fixed{positiLine 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(59 130 246 / .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(59 130 246 / .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:#e5e7eb}: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:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}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}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.fixed{positiLine truncated
|
||||
@@ -1,19 +0,0 @@
|
||||
import{j as e,r as i,b as Le,c as ba,d as ya}from"./react-vendor-DZnRGM0-.js";import{L as fa,U as Wt,S as Vt,C as Zs,B as Gt,Z as Xs,a as ys,b as it,c as Jt,d as ja,e as cs,A as gt,D as Na,f as bt,P as Kt,g as Ls,E as Qt,T as va,h as wa,i as $e,Q as Us,j as ds,k as ss,l as bs,m as yt,R as Oe,n as Yt,o as _a,p as Je,X as ve,K as ka,q as os,r as rs,s as as,t as ts,u as ft,v as As,w as fs,x as Zt,y as Xt,z as Ss,F as Ht,G as Ca,H as jt,I as Nt,J as Sa,M as La,N as Aa,O as Ia,V as Ws,W as $s,Y as Hs,_ as $a,$ as Ra,a0 as et,a1 as Pa,a2 as Da,a3 as st,a4 as vt,a5 as Fa,a6 as Es,a7 as ea,a8 as Ta,a9 as Ea,aa as ot,ab as sa,ac as Ma,ad as Oa}from"./icons-vendor-RenKjhri.js";import{R as Rs,B as qa,X as wt,Y as _t,T as Vs,a as Ba,C as Gs,A as za,b as Ua,c as Wa,P as kt,d as Ct,L as Va}from"./charts-vendor-B_BfwiL0.js";import"./vendor-w5t2K9ux.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const x of document.querySelectorAll('link[rel="modulepreload"]'))d(x);new MutationObserver(x=>{for(const w of x)if(w.type==="childList")for(const S of w.addedNodes)S.tagName==="LINK"&&S.rel==="modulepreload"&&d(S)}).observe(document,{childList:!0,subtree:!0});function r(x){const w={};return x.integrity&&(w.integrity=x.integrity),x.referrerPolicy&&(w.referrerPolicy=x.referrerPolicy),x.crossOrigin==="use-credentials"?w.credentials="include":x.crossOrigin==="anonymous"?w.credentials="omit":w.credentials="same-origin",w}function d(x){if(x.ep)return;x.ep=!0;const w=r(x);fetch(x.href,w)}})();const Ga=({className:s="w-full h-full text-white"})=>e.jsx("svg",{className:s,viewBox:"0 0 256 256","aria-hidden":"true",children:e.jsx("g",{stroke:"none",fill:"none",fillRule:"evenodd",children:e.jsx("path",{d:"M121.73,57.0003 C138.901,57.0003 154.897,65.5053 164.52,79.7493 C166.029,81.9823 165.441,85.0143 163.209,86.5233 C160.976,88.0323 157.944,87.4433 156.436,85.2113 C148.629,73.6553 135.655,66.7563 121.73,66.7563 C104.076789,66.7563 88.6201962,77.6596007 82.5581814,93.8184545 C83.9120803,93.7133631 85.2800264,93.66 86.6602,93.66 C111.537727,93.66 132.442611,110.997575 137.926382,134.224255 L162.5425,92.109 L162.615557,91.9879406 L162.756884,91.77367 L162.911804,91.5639102 L162.98657,91.4716759 C163.351845,91.025169 163.786059,90.6571744 164.264191,90.3738733 L164.550153,90.2178351 L164.729252,90.1315693 L164.989203,90.021723 L165.230265,89.9354653 L165.542393,89.8445739 C165.666021,89.8126706 165.790834,89.7857324 165.916565,89.7637431 L166.116517,89.7342499 C166.29505,89.7098142 166.475001,89.6957386 166.655596,89.6918808 L166.7539,89.693 C196.8909,89.693 221.4079,114.21 221.4079,144.347 C221.4079,174.482 196.8909,199 166.7539,199 L125.0869,199 C122.3919,199 120.2079,196.815 120.2079,194.122 C120.2079,191.429 122.3919,189.244 125.0869,189.244 L166.7539,189.244 C191.5109,189.244 211.6519,169.104 211.6519,144.347 C211.6519,120.513406 192.985349,100.957891 169.504046,99.5322548 L112.7745,196.584 C111.8995,198.08 110.2965,199 108.5635,199 L86.6602,199 C57.6182,199 33.9902,175.373 33.9902,146.33 C33.9902,122.475163 49.9316132,102.273061 71.7206298,95.817503 L71.9446339,94.967678 C78.0600632,72.5405324 98.33054,57.0003 121.73,57.0003 Z M86.6602,103.417 C62.9972,103.417 43.7462,122.667 43.7462,146.33 C43.7462,169.992 62.9972,189.244 86.6602,189.244 L105.7645,189.244 L129.869462,148.004782 C129.678439,147.482425 129.5742,146.918336 129.5742,146.33 C129.5742,122.667 110.3232,103.417 86.6602,103.417 Z",fill:"currentColor"})})}),tt=({sizeClass:s="w-12 h-12",logoClassName:t="w-full h-full text-white"})=>e.jsxs("div",{className:"relative z-10 flex items-center justify-center",children:[e.jsx("div",{className:"absolute -inset-1 bg-blue-500/20 rounded-xl blur opacity-25"}),e.jsxs("div",{className:`relative ${s} rounded-xl flex items-center justify-center group-hover:scale-105 transition-transform duration-300`,children:[e.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"login-squircle-gradient",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0094f7"}),e.jsx("stop",{offset:"100%",stopColor:"#287efe"})]})}),e.jsx("path",{d:"M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 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 88Line 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(it,{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:us,className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",disabled:y,children:"取消"}),e.jsxs("button",{onClick:Z,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",disabled:y,children:[y?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(as,{className:"w-4 h-4"}),y?"保存中...":"保存"]})]})})]})}),document.body)]})},vr=s=>({total:Number((s==null?void 0:s.total)||0),success_count:Number((s==null?void 0:s.success_count)||0),failed_count:Number((s==null?void 0:s.failed_count)||0),results:Array.isArray(s==null?void 0:s.results)?s.results.map(t=>({order_id:String((t==null?void 0:t.order_id)||"unknown"),success:(t==null?void 0:t.success)===!0,message:String((t==null?void 0:t.message)||"")})):[]}),wr=s=>(s==null?void 0:s.results.filter(t=>!t.success))||[],Ft=({status:s})=>{const t={processing:"bg-blue-100 text-blue-800",pending_ship:"bg-[#0094f7] text-white",shipped:"bg-blue-100 text-blue-700",completed:"bg-green-100 text-green-700",cancelled:"bg-gray-100 text-gray-500",refunding:"bg-red-100 text-red-600",unknown:"bg-gray-100 text-gray-500"},r={processing:"处理中",pending_ship:"待发货",shipped:"已发货",completed:"已完成",cancelled:"已取消",refunding:"退款中",unknown:"未知"};return e.jsx("span",{className:`px-3 py-1.5 rounded-lg text-xs font-bold ${t[s]||t.cancelled}`,children:r[s]||s})},_r=()=>{const[s,t]=i.useState([]),[r,d]=i.useState([]),[x,w]=i.useState([]),[S,F]=i.useState({}),[g,R]=i.useState("all"),[b,G]=i.useState(""),[se,re]=i.useState(""),[ie,k]=i.useState(""),B=i.useRef(0),[ne,J]=i.useState(1),[Y,z]=i.useState(1),[xe,oe]=i.useState(!1),[_,T]=i.useState(!1),[U,V]=i.useState(!1),[me,L]=i.useState(!1),[A,K]=i.useState(null),[I,ae]=i.useState(null),[we,Ce]=i.useState({}),[ue,m]=i.useState(!1),[h,q]=i.useState(""),[j,te]=i.useState(!1),[le,H]=i.useState(null),[je,P]=i.useState(null),[o,D]=i.useState(null),[n,y]=i.useState(!1),[E,C]=i.useState(null),[M,he]=i.useState(null),X=async()=>{const u=++B.current;oe(!0);try{const $=await yl(b||void 0,g,ne,20,ie);if(u!==B.current)return;t($.data),z($.total_pages)}catch($){console.error("加载订单失败:",$)}finally{u===B.current&&oe(!1)}},ee=(u,$,ce)=>{if(ce&&ce.trim())return ce;if(S[`${u}:${$}`])return S[`${u}:${$}`];const _e=r.find(Ye=>{if(ce&&Ye.item_title){const Ze=ce.toLowerCase(),Xe=Ye.item_title.toLowerCase();return Xe.includes(Ze)||Ze.includes(Xe)}return!1});return _e!=null&&_e.item_title?_e.item_title:"未知商品"},Se=u=>{const $={};u.forEach(ce=>{ce.item_id&&($[`${ce.cookie_id}:${ce.item_id}`]=ce.item_title||ce.item_id)}),F($)};i.useEffect(()=>{const u=window.setTimeout(()=>{J(1),k(se.trim())},300);return()=>window.clearTimeout(u)},[se]),i.useEffect(()=>{X()},[b,g,ne,ie]),i.useEffect(()=>{Promise.all([qs(),js()]).then(([u,$])=>{w(u),d($),Se($)}).catch(u=>{console.error("加载商品列表失败:",u)})},[]);const Ne=i.useMemo(()=>new Map(x.map(u=>[u.id,u])),[x]),We=u=>{const $=Ne.get(u),ce=($==null?void 0:$.remark)||($==null?void 0:$.nickname);return ce?`${ce} · ${u.slice(0,6)}`:`账号 ${u.slice(0,8)}`},Ie=u=>{const $=Ne.get(u);return($==null?void 0:$.remark)||($==null?void 0:$.nickname)||"未命名账号"},Fe=async()=>{oe(!0);try{const u=await Nl(b||void 0,g);await X(),u!=null&&u.message&&alert(u.message)}catch(u){console.error("同步订单失败:",u),alert((u==null?void 0:u.message)||"同步失败,请重试")}finally{oe(!1)}},qe=u=>{q(u),H(null),m(!0)},Te=async u=>{var $;te(!0),H(null);try{const ce=await wl([h],u),_e=($=ce==null?void 0:ce.results)==null?void 0:$[0];_e!=null&&_e.success?(H({success:!0,message:_e.message}),X()):H({success:!1,message:(_e==null?void 0:_e.message)||"发货失败"})}catch(ce){H({success:!1,message:(ce==null?void 0:ce.message)||"请求失败"})}finally{te(!1)}},Ve=u=>{K(u),T(!0)},Ee=u=>{ae({...u}),V(!0)},Re=async()=>{if(!(!I||!I.order_id))try{const u={};I.status!==void 0&&(u.order_status=I.status),I.buyer_id!==void 0&&(u.buyer_id=I.buyer_id),I.amount!==void 0&&(u.amount=I.amount),I.receiver_name!==void 0&&(u.receiver_name=I.receiver_name),I.receiver_phon
Line truncated
|
||||
VIP-MONTH-002
|
||||
VIP-MONTH-003`,"按行消费的卡密队列","是","0","否","",""],["感谢文案","text","感谢购买,如有问题联系客服~","固定文本","是","0","否","",""],["教程图","image","https://cdn.example.com/tutorial.jpg","图片URL","是","0","否","",""]]].map(M=>M.map(he=>`"${String(he).replace(/"/g,'""')}"`).join(",")).join(`
|
||||
`),y=new Blob(["\uFEFF"+n],{type:"text/csv;charset=utf-8"}),E=URL.createObjectURL(y),C=document.createElement("a");C.href=E,C.download="卡密组批量导入模板.csv",document.body.appendChild(C),C.click(),C.remove(),URL.revokeObjectURL(E)},H=async()=>{if(B){xe(!0),Y(null);try{const o=await Il(B);if(Y(o),o.created>0){const D=await es();t(D)}}catch(o){Y({error:(o==null?void 0:o.message)||"上传失败"})}finally{xe(!1)}}},je=async()=>{if(!(!oe||!T.trim())){xe(!0),me(null);try{const o=await $l(oe,T);me({added:o.added}),U("");const D=await es();t(D)}catch(o){alert("追加失败:"+((o==null?void 0:o.message)||"未知错误"))}finally{xe(!1)}}},P=()=>{var o;k("create"),ne(null),Y(null),_((o=j[0])!=null&&o.id?String(j[0].id):""),U(""),me(null),re(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-4xl font-extrabold text-gray-900 tracking-tight",children:"卡密库存"}),e.jsx("p",{className:"text-gray-500 mt-2 font-medium",children:"管理自动发货的卡密、链接或图片资源。"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:P,className:"px-4 py-3 bg-gray-100 hover:bg-gray-200 rounded-2xl font-bold text-gray-700 flex items-center gap-2 transition-colors",children:[e.jsx(Ss,{className:"w-5 h-5"}),"批量导入"]}),e.jsxs("button",{onClick:()=>w(!0),className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 transition-transform hover:scale-105 active:scale-95",children:[e.jsx(ts,{className:"w-5 h-5"}),"添加新卡密"]})]})]}),e.jsxs("div",{className:"ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-gray-50 bg-[#FAFAFA] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative sm:w-48",children:[e.jsx(Ht,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsxs("select",{"aria-label":"按卡密类型筛选",value:L,onChange:o=>A(o.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-9 text-sm shadow-sm",children:[e.jsx("option",{value:"",children:"全部类型"}),e.jsx("option",{value:"data",children:"批量卡密"}),e.jsx("option",{value:"text",children:"文本"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"image",children:"图片"})]})]}),e.jsxs("div",{className:"relative w-full sm:max-w-sm",children:[e.jsx(As,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search","aria-label":"按卡密名称搜索",placeholder:"搜索卡密名称...",value:K,onChange:o=>I(o.target.value),className:"ios-input w-full rounded-xl border-none bg-white py-2.5 pl-10 pr-4 text-sm shadow-sm"})]})]}),e.jsxs("div",{className:"whitespace-nowrap px-1 text-xs font-bold text-gray-400",children:["显示 ",te.length," / ",s.length," 组"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-white text-gray-400 text-xs font-bold uppercase tracking-wider border-b border-gray-50",children:[e.jsx("th",{className:"w-[23%] px-5 py-5",children:"卡密名称"}),e.jsx("th",{className:"w-[8%] px-3 py-5",children:"卡密组ID"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"类型"}),e.jsx("th",{className:"w-[27%] px-5 py-5",children:"内容/库存"}),e.jsx("th",{className:"w-[19%] px-5 py-5",children:"描述"}),e.jsx("th",{className:"w-[7%] px-2 py-5",children:"状态"}),e.jsx("th",{className:"w-[9%] px-3 py-5 text-right",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:te.map(o=>{let D="";return o.type==="data"&&o.data_content?D=`库存: ${o.data_content.split(`
|
||||
`).filter(y=>y.trim()).length} 条`:o.type==="text"&&o.text_content?D=o.text_content:o.type==="api"&&o.api_config?D=o.api_config.url:o.type==="image"&&o.image_url&&(D="图片链接"),e.jsxs("tr",{className:"hover:bg-[#FFFDE7]/50 transition-colors group",children:[e.jsx("td",{className:"px-5 py-5 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white",children:e.jsx(ae,{type:o.type})}),e.jsx("span",{className:"line-clamp-3 min-w-0 text-[13px] font-bold leading-5 text-gray-900",title:o.name,children:o.name})]})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("button",{onClick:()=>q(o.id),className:"inline-flex max-w-full items-center gap-1 rounded-lg bg-gray-100 px-2 py-1.5 font-mono text-[11px] font-extrabold text-gray-700 transition-colors hover:bg-gray-200",title:"复制卡密组ID,用于批量铺货表格",children:[e.jsx("span",{className:"truncate",children:o.id}),e.jsx(Ca,{className:"h-3 w-3 shrink-0"})]})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("span",{className:`inline-flex rounded-md px-2 py-1 text-[11px] font-bold ${o.type==="text"?"bg-blue-50 text-blue-600":o.type==="data"?"bg-purple-50 text-purple-600":o.type==="api"?"bg-blue-50 text-blue-600":"bg-pink-50 text-pink-600"}`,children:o.type==="text"?"文本":o.type==="data"?"批量":o.type==="api"?"API":"图片"})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"line-clamp-3 break-all font-mono text-sm leading-5 text-gray-600",title:D,children:D})}),e.jsx("td",{className:"px-5 py-5",children:e.jsx("span",{className:"block truncate text-sm text-gray-500",title:o.description||"-",children:o.description||"-"})}),e.jsx("td",{className:"px-2 py-5",children:e.jsx("button",{onClick:()=>h(o),className:`w-12 h-8 rounded-full relative transition-colors ${o.enabled?"bg-green-500":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-sm transition-transform ${o.enabled?"left-5":"left-1"}`})})}),e.jsx("td",{className:"px-3 py-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e.jsx("button",{onClick:()=>we(o),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-black",title:"编辑",children:e.jsx(fs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>ue(o.id),className:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500",children:e.jsx(Je,{className:"h-4 w-4"})})]})})]},o.id)})})]})}),te.length===0&&e.jsxs("div",{className:"py-20 text-center text-gray-400",children:[e.jsx(Kt,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:s.length===0?"暂无卡密配置,请点击右上角添加。":"没有符合当前筛选条件的卡密组。"})]})]}),r&&S&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"编辑卡密"}),e.jsx("button",{onClick:()=>d(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:["卡密名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:g.name||"",onChange:o=>R({...g,name:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",placeholder:"例如:游戏点卡、会员卡等"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡券类型"}),e.jsxs("select",{value:g.type||"text",onChange:o=>R({...g,type:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"",children:"请选择类型"}),e.jsx("option",{value:"text",children:"固定文字"}),e.jsx("option",{value:"data",children:"批量数据"}),(S==null?void 0:S.type)==="api"&&e.jsx("option",{value:"api",children:"API接口(仅保留现有配置)"}),e.jsx("option",{value:"image",children:"图片"})]})]})]}),g.type==="api"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 space-y-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:"API 配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"API 地址"}),e.jsx("input",{type:"url",value:g.api_url||"",onChange:o=>R({...g,api_url:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://api.example.com/get-card"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsLine truncated
|
||||
卡号1:密码1
|
||||
卡号2:密码2
|
||||
或者
|
||||
兑换码1
|
||||
兑换码2`}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"支持格式:卡号:密码 或 单独的兑换码"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-blue-600",children:g.data_content?g.data_content.split(`
|
||||
`).filter(o=>o.trim()).length:0})," 条"]})]})]}),g.type==="image"&&e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 bg-gray-50",children:[e.jsx("h3",{className:"font-bold text-gray-900 mb-3",children:"图片配置"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片 URL"}),e.jsx("input",{type:"url",value:g.image_url||"",onChange:o=>R({...g,image_url:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl font-mono text-sm",placeholder:"https://example.com/image.png"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"输入图片卡密的 URL 地址"})]}),g.image_url&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"图片预览"}),e.jsx("img",{src:g.image_url,alt:"预览",className:"max-w-full max-h-48 rounded-xl border border-gray-200",onError:o=>{o.currentTarget.src="https://via.placeholder.com/400x200?text=图片加载失败"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"延时发货时间(秒)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:g.delay_seconds||0,onChange:o=>R({...g,delay_seconds:parseInt(o.target.value)||0}),className:"flex-1 ios-input px-4 py-3 rounded-xl",min:"0",max:"3600",placeholder:"0"}),e.jsx("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:"秒"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"0表示立即发货,最大3600秒(1小时)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"备注信息"}),e.jsx("textarea",{value:g.description||"",onChange:o=>R({...g,description:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-40 resize-none",placeholder:"可选的备注信息"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 rounded-xl",children:[e.jsx("span",{className:"font-bold text-gray-900",children:"启用状态"}),e.jsx("button",{type:"button",onClick:()=>R({...g,enabled:!g.enabled}),className:`w-14 h-8 rounded-full transition-colors duration-300 relative ${g.enabled?"bg-[#0094f7]":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${g.enabled?"translate-x-7":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>d(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:Ce,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),"保存更改"]})]})})]})}),document.body),x&&Le.createPortal(e.jsx("div",{className:"modal-overlay-centered",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"780px"},children:[e.jsxs("div",{className:"modal-header flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-extrabold text-gray-900",children:"添加新卡密"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"选择交付方式并录入自动发货内容"})]}),e.jsx("button",{onClick:()=>w(!1),className:"p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0",title:"关闭",children:e.jsx(ve,{className:"w-5 h-5 text-gray-500"})})]}),e.jsx("div",{className:"modal-body",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"卡密名称"}),e.jsx("input",{type:"text",value:b.name,onChange:o=>G({...b,name:o.target.value}),placeholder:"例如:VIP会员卡密",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:"类型"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>G({...b,type:"data",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="data"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[e.jsx(Zs,{className:"w-5 h-5 mx-auto mb-1"}),"批量库存"]}),e.jsxs("button",{type:"button",onClick:()=>G({...b,type:"text",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="text"?"bg-[#0094f7] text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(jt,{className:"w-5 h-5 mx-auto mb-1"}),"文本"]}),e.jsxs("button",{type:"button",onClick:()=>G({...b,type:"image",content:""}),className:`p-3 rounded-xl font-bold transition-all ${b.type==="image"?"bg-[#0094f7] text-white":"bg-gray-100 text-grayLine truncated
|
||||
CODE-789012
|
||||
...`:"请输入每次发货时发送的固定文字"}),b.type==="data"&&e.jsxs("p",{className:"text-xs text-gray-500",children:["当前库存:",e.jsx("span",{className:"font-bold text-[#0094f7]",children:b.content.split(`
|
||||
`).filter(o=>o.trim()).length})," 条"]})]}),b.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:b.api_method,onChange:o=>G({...b,api_method:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:b.api_timeout,onChange:o=>G({...b,api_timeout:parseInt(o.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:b.api_headers,onChange:o=>G({...b,api_headers:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:b.api_params,onChange:o=>G({...b,api_params:o.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:b.description,onChange:o=>G({...b,description:o.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:b.delay_seconds,onChange:o=>G({...b,delay_seconds:parseInt(o.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:m,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),se&&Le.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>re(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(ve,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>k("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${ie==="create"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Sa,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>k("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${ie==="append"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(Ss,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),ie==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:le,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 tex
Line truncated
|
||||
VIP-002
|
||||
VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),V&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",V.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>re(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),ie==="create"?e.jsxs("button",{onClick:H,disabled:!B||z,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[z?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(Ss,{className:"w-4 h-4"}),z?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:je,disabled:!oe||!T.trim()||z||j.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[z?e.jsx($e,{className:"w-4 h-4 animate-spin"}):e.jsx(ts,{className:"w-4 h-4"}),z?"处理中...":"追加卡密"]})]})]})}),document.body)]})},Sr=s=>s.find(t=>t.status==="running"||t.status==="canceling"),Lr=s=>{const t=String(s||"").trim();return t?/^[¥¥]/.test(t)?t:`¥${t}`:"-"},Ar=({onConfigureDelivery:s})=>{const[t,r]=i.useState([]),[d,x]=i.useState([]),[w,S]=i.useState([]),[F,g]=i.useState(""),[R,b]=i.useState(""),[G,se]=i.useState(!1),[re,ie]=i.useState(!1),[k,B]=i.useState(!1),[ne,J]=i.useState(!1),[Y,z]=i.useState(!1),[xe,oe]=i.useState(!1),[_,T]=i.useState(!1),[U,V]=i.useState("upload"),[me,L]=i.useState(null),[A,K]=i.useState(null),[I,ae]=i.useState(""),[we,Ce]=i.useState(!1),[ue,m]=i.useState({catId:"",catName:"",channelCatId:"",tbCatId:""}),[h,q]=i.useState(null),[j,te]=i.useState(null),[le,H]=i.useState(null),je=i.useRef(!1),[P,o]=i.useState(null),[D,n]=i.useState({}),[y,E]=i.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[C,M]=i.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[he,X]=i.useState([]);i.useEffect(()=>{if(!xe||C.images.length===0){X([]);return}const l=C.images.map((N,Z)=>({key:N.name+Z,url:URL.createObjectURL(N)}));return X(l),()=>{l.forEach(N=>URL.revokeObjectURL(N.url))}},[xe,C.images]);const ee=async()=>{const l=await js();r(l)},Se=async()=>{x(await lt())};i.useEffect(()=>{Promise.all([qs(),js(),lt(),It(20)]).then(([l,N,Z,Ue])=>{S(l),r(N),x(Z);const Ge=Ue.find(Pe=>["running","canceling"].includes(Pe.status))||Ue.find(Pe=>Pe.status!=="preview");H(Ge||null)}).catch(l=>console.error("加载商品配置失败:",l))},[]),i.useEffect(()=>{if(!_||!(j!=null&&j.id)||!["running","canceling"].includes(j.status))return;const l=window.setInterval(async()=>{if(!je.current){je.current=!0;try{const N=await hs(j.id);te(N),H(N),["running","canceling"].includes(N.status)||(V("done"),await ee(),await Se())}catch(N){console.error("刷新批量铺货进度失败:",N)}finally{je.current=!1}}},3e3);return()=>{window.clearInterval(l)}},[_,j==null?void 0:j.id,j==null?void 0:j.status]);const Ne=async()=>{if(!F)return alert("请先选择账号");se(!0);try{const l=await Rl(F);await ee(),alert((l==null?void 0:l.message)||"商品同步完成")}catch(l){console.error("同步商品失败:",l),alert((l==null?void 0:l.message)||"同步失败,请重试")}finally{se(!1)}},We=l=>{o(l),n({...l}),J(!0)},Ie=async()=>{if(P)try{await zl(P.cookie_id,P.item_id,{item_title:D.item_title||"",item_description:D.item_description||"",item_category:D.item_category||"",item_price:D.item_price||"",item_detail:D.item_detail||P.item_detail||""}),await ee(),await Se(),J(!1),o(null)}catch(l){console.error("更新商品失败:",l),alert("更新失败,请重试")}},Fe=async l=>{if(confirm(`确认删除商品"${l.item_title}"吗?`))try{await Pl(l.cookie_id,l.item_id),r(N=>N.filter(Z=>!(Z.cookie_id===l.cookie_id&&Z.item_id===l.item_id)))}catch(N){console.error("删除商品失败:",N),alert("删除失败,请重试")}},qe=async()=>{try{if(!y.cookie_id||!y.item_id){alert("请选择账号并填写商品ID");return}await Dl(y.cookie_id,{item_id:y.item_id,item_title:y.item_title,item_price:y.item_price,item_detail:y.item_image?JSON.stringify({item_image:y.item_image}):""}),await ee(),z(!1),E({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(l){console.error("添加商品失败:",l),alert("添加失败,请重试")}},Te=async()=>{if(!C.cookie_id)return alert("请选择发布账号");if(!C.title.trim())return alert("请填写商品标题");if(!C.price.trim())return alert("请填写商品价格");if(!C.quantity||Number(C.quantity)<=0)return alert("库存数量必须大于 0");if(C.images.length===0)return alert("至少上传 1 张商品图片");if(C.postage_mode==="fixed"&&!C.p
Line truncated
|
||||
`),Ue=new Blob(["\uFEFF"+Z],{type:"text/csv;charset=utf-8"}),Ge=URL.createObjectURL(Ue),Pe=document.createElement("a");Pe.href=Ge,Pe.download="批量铺货模板.csv",document.body.appendChild(Pe),Pe.click(),Pe.remove(),URL.revokeObjectURL(Ge)},_e=()=>{E(l=>({...l,cookie_id:F||l.cookie_id})),z(!0)},Ye=()=>{M(l=>({...l,cookie_id:F||l.cookie_id})),oe(!0)},Ze=l=>d.filter(N=>N.cookie_id===l.cookie_id&&N.item_id===l.item_id).length>0?d.filter(N=>N.cookie_id===l.cookie_id&&N.item_id===l.item_id):d.filter(N=>N.cookie_id===l.cookie_id&&!N.item_id),Xe=l=>{switch(l){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return l||"-"}},Be=l=>{switch(l){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},ze=i.useMemo(()=>new Map(w.map(l=>[l.id,l])),[w]),xs=i.useMemo(()=>R?t.filter(l=>l.cookie_id===R):t,[R,t]),He=l=>{const N=ze.get(l),Z=(N==null?void 0:N.remark)||(N==null?void 0:N.nickname);return Z?`${Z} · ${l.slice(0,6)}`:`账号 ${l.slice(0,8)}`},ms=l=>{const N=ze.get(l);return(N==null?void 0:N.remark)||(N==null?void 0:N.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ia,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:R,onChange:l=>b(l.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(ds,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:F,onChange:l=>g(l.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),w.map(l=>e.jsx("option",{value:l.id,children:He(l.id)},l.id))]})]})]}),e.jsxs("button",{onClick:Ne,disabled:G||!F,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(Oe,{className:`w-4 h-4 ${G?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:_e,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(ts,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:Ye,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Ws,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void Ve(),className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx($s,{className:"w-4 h-4"}),le&&["running","canceling"].includes(le.status)?"继续批量任务":"批量铺货"]}),le&&!["running","canceling"].includes(le.status)&&e.jsx("button",{onClick:()=>void Re(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[xs.map(l=>{const N=Ze(l),Z=N.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relat
Line 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-av934L0W.js"></script>
|
||||
<script type="module" crossorigin src="/static/assets/index-2_f0Vmhn.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/react-vendor-DZnRGM0-.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-RenKjhri.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/vendor-w5t2K9ux.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/assets/charts-vendor-B_BfwiL0.js">
|
||||
<link rel="stylesheet" crossorigin href="/static/assets/index-C7AaUlyC.css">
|
||||
<link rel="stylesheet" crossorigin href="/static/assets/index-DMeflf1O.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
Reference in new issue
Block a user