fix: 完善同步生命周期并统一前端视觉

- 同步商品与订单时处理线上删除状态并联动自动化规则\n- 过滤卖家系统中的购买订单,修复订单逻辑删除与数据库迁移\n- 修复聊天新消息自动滚动,并统一前端颜色令牌与硬编码颜色检查
This commit is contained in:
Christ committed 2026-08-10 12:41:10 +08:00
1 parent cf76b8898b
commit 526ac44453
40 files changed
+802 -242

No files matched your search

+7 -7
View File
@@ -147,8 +147,8 @@ const App: React.FC = () => {
if (checkingAuth) {
return (
<div className="min-h-screen flex items-center justify-center bg-[#f5f5f7]">
<Loader2 className="w-8 h-8 text-[#0094f7] animate-spin" />
<div className="min-h-screen flex items-center justify-center bg-surface">
<Loader2 className="w-8 h-8 text-brand animate-spin" />
</div>
);
}
@@ -156,11 +156,11 @@ const App: React.FC = () => {
// Init Screen (system not initialized)
if (needsInit) {
return (
<div className="min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans">
<div className="min-h-screen flex items-center justify-center bg-canvas p-4 relative overflow-hidden font-sans">
<div className="absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"></div>
<div className="absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse" style={{animationDelay: '2s'}}></div>
<div className="bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-xl border border-white relative z-10 animate-fade-in">
<div className="bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-panel w-full max-w-xl border border-white relative z-10 animate-fade-in">
<div className="text-center mb-8">
<div className="mx-auto mb-6 flex justify-center">
<YdisksBrandIcon sizeClass="w-24 h-24" />
@@ -198,12 +198,12 @@ const App: React.FC = () => {
// Login Screen Component
if (!isLoggedIn) {
return (
<div className="min-h-screen flex items-center justify-center bg-[#F4F5F7] p-4 relative overflow-hidden font-sans">
<div className="min-h-screen flex items-center justify-center bg-canvas p-4 relative overflow-hidden font-sans">
{/* Animated Background Blobs */}
<div className="absolute top-[-10%] left-[-10%] w-[60%] h-[60%] bg-blue-200/40 rounded-full blur-[120px] animate-pulse"></div>
<div className="absolute bottom-[-10%] right-[-10%] w-[60%] h-[60%] bg-blue-200/30 rounded-full blur-[120px] animate-pulse" style={{animationDelay: '2s'}}></div>
<div className="bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.05)] w-full max-w-lg border border-white relative z-10 animate-fade-in">
<div className="bg-white/80 backdrop-blur-3xl p-8 md:p-12 rounded-xl shadow-panel w-full max-w-lg border border-white relative z-10 animate-fade-in">
{/* Header with Logo */}
<div className="text-center mb-10">
@@ -288,7 +288,7 @@ const App: React.FC = () => {
};
return (
<div className="flex min-h-screen bg-[#F4F5F7] text-[#111]">
<div className="flex min-h-screen bg-canvas text-ink">
<Sidebar
activeTab={activeTab}
isAdmin={isAdmin}
+9
View File
@@ -43,6 +43,15 @@ describe('online chat UI contract', () => {
expect(chat).toContain('justify-center py-1');
});
test('keeps the active chat at the bottom when new messages arrive', () => {
const chat = source('components/Chat.tsx');
expect(chat).toContain('shouldScrollToBottomRef');
expect(chat).toContain('skipNextMessageScrollRef');
expect(chat).toContain('onScroll={handleMessageScroll}');
expect(chat).toContain('container.scrollHeight - container.scrollTop - container.clientHeight');
expect(chat).toContain('[activeAccountID, activeChatID, messages, messagesLoading]');
});
test('sidebar exposes collapse control and chat primary navigation', () => {
const sidebar = source('components/Sidebar.tsx');
expect(sidebar).toContain("id: 'chat'");
+36
View File
@@ -0,0 +1,36 @@
import { readdirSync, readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, test } from 'vitest';
const componentsDir = resolve(__dirname, 'components');
const pageSources = [
resolve(__dirname, 'App.tsx'),
...readdirSync(componentsDir)
.filter((fileName) => fileName.endsWith('.tsx') && !fileName.endsWith('.test.tsx'))
.map((fileName) => resolve(componentsDir, fileName)),
];
// rgb(var(--color-*)), CSS classes and the central index.css are references.
// Literal colors in page code would bypass the design-token system.
const hardCodedColorPattern = /#[0-9a-f]{3,8}\b|rgba?\((?!var\(--color-)/gi;
describe('global color token contract', () => {
test('page components do not contain hard-coded color values', () => {
const violations = pageSources.flatMap((filePath) => {
const source = readFileSync(filePath, 'utf8');
return [...source.matchAll(hardCodedColorPattern)].map((match) => `${filePath}:${match[0]}`);
});
expect(violations).toEqual([]);
});
test('the primary brand and highlight colors are defined in the central stylesheet', () => {
const globalStyles = readFileSync(resolve(__dirname, 'index.css'), 'utf8');
expect(globalStyles).toContain('--color-brand: 0 148 247;');
expect(globalStyles).toContain('--color-brand-highlight: 0 113 227;');
expect(globalStyles).toContain('--color-success-500:');
expect(globalStyles).toContain('--color-warning-500:');
expect(globalStyles).toContain('--color-danger-500:');
});
});
+12 -12
View File
@@ -678,7 +678,7 @@ const AccountList: React.FC = () => {
}
};
if (loading) return <div className="p-20 flex justify-center"><Loader2 className="w-8 h-8 text-[#0094f7] animate-spin"/></div>;
if (loading) return <div className="p-20 flex justify-center"><Loader2 className="w-8 h-8 text-brand animate-spin"/></div>;
const filteredAccounts = accounts.filter(account => {
const keyword = accountSearch.trim().toLowerCase();
@@ -728,7 +728,7 @@ const AccountList: React.FC = () => {
const runtime = runtimePresentation(account);
const requiresLogin = account.runtime_state === 'auth_expired' || account.runtime_state === 'verification_required';
return (
<div key={account.id} className="ios-card rounded-xl p-6 group transition-all duration-300 hover:border-[#0094f7]">
<div key={account.id} className="ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand">
<div className="flex min-w-0 items-start gap-5 sm:gap-8">
<div className="relative">
{account.avatar_url ? (
@@ -898,7 +898,7 @@ const AccountList: React.FC = () => {
{deleteDialogAccount && createPortal(
<div className="modal-overlay-centered" role="presentation">
<div
className="h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-[0_24px_64px_rgba(15,23,42,0.22)]"
className="h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-modal"
role="dialog"
aria-modal="true"
aria-labelledby="delete-account-title"
@@ -947,7 +947,7 @@ const AccountList: React.FC = () => {
role="progressbar"
aria-label="正在删除账号"
>
<Loader2 className="h-5 w-5 flex-shrink-0 animate-spin text-[#0094f7]" />
<Loader2 className="h-5 w-5 flex-shrink-0 animate-spin text-brand" />
<div>
<div className="text-sm font-extrabold text-blue-950">正在删除账号</div>
<div className="mt-0.5 text-xs text-blue-700">正在清理关联数据,请保持页面打开…</div>
@@ -1015,8 +1015,8 @@ const AccountList: React.FC = () => {
: '请打开闲鱼APP扫描下方二维码'}
</p>
<div className={`w-full bg-[#F7F8FA] rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${qrStatus === 'verification' ? 'max-w-72 min-h-64 h-auto p-2' : 'max-w-64 aspect-square'}`}>
{qrStatus === 'loading' && <Loader2 className="w-10 h-10 text-[#0094f7] animate-spin" />}
<div className={`w-full bg-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${qrStatus === 'verification' ? 'max-w-72 min-h-64 h-auto p-2' : 'max-w-64 aspect-square'}`}>
{qrStatus === 'loading' && <Loader2 className="w-10 h-10 text-brand animate-spin" />}
{qrStatus === 'waiting' && <SquareQRCode src={qrCodeUrl} alt="闲鱼登录二维码" className="p-2" />}
{qrStatus === 'success' && (
<div className="absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in">
@@ -1111,7 +1111,7 @@ const AccountList: React.FC = () => {
type="button"
onClick={() => setEditForm({ ...editForm, auto_confirm: !editForm.auto_confirm })}
className={`w-14 h-8 rounded-full transition-colors duration-300 relative ${
editForm.auto_confirm ? 'bg-[#0094f7]' : 'bg-gray-300'
editForm.auto_confirm ? 'bg-brand' : 'bg-gray-300'
}`}
>
<span
@@ -1168,7 +1168,7 @@ const AccountList: React.FC = () => {
aria-label="保存登录信息"
disabled={longLogin.loading || longLogin.saving || !longLogin.canOpen}
onClick={() => void handleLongLoginToggle()}
className={`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${longLogin.enabled ? 'bg-[#0094f7]' : 'bg-gray-300'} disabled:cursor-not-allowed disabled:opacity-50`}
className={`relative h-8 w-14 flex-shrink-0 rounded-full transition-colors ${longLogin.enabled ? 'bg-brand' : 'bg-gray-300'} disabled:cursor-not-allowed disabled:opacity-50`}
>
<span className={`absolute left-1 top-1 h-6 w-6 rounded-full bg-white shadow-md transition-transform ${longLogin.enabled ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
@@ -1206,7 +1206,7 @@ const AccountList: React.FC = () => {
type="checkbox"
checked={editForm.clear_password}
onChange={(e) => setEditForm({ ...editForm, clear_password: e.target.checked, login_password: e.target.checked ? '' : editForm.login_password })}
className="w-4 h-4 accent-[#0094f7]"
className="w-4 h-4 accent-brand"
/>
<span className="text-sm font-bold text-gray-700">清空已保存密码</span>
</label>
@@ -1220,7 +1220,7 @@ const AccountList: React.FC = () => {
type="button"
onClick={() => setEditForm({ ...editForm, show_browser: !editForm.show_browser })}
className={`w-14 h-8 rounded-full transition-colors duration-300 relative ${
editForm.show_browser ? 'bg-[#0094f7]' : 'bg-gray-300'
editForm.show_browser ? 'bg-brand' : 'bg-gray-300'
}`}
>
<span
@@ -1302,7 +1302,7 @@ const AccountList: React.FC = () => {
}}
disabled={!bindingsLoaded}
className={`w-5 h-5 rounded-md border-2 flex items-center justify-center transition-colors flex-shrink-0 ${
checked ? 'bg-[#0094f7] border-[#0094f7]' : 'bg-white border-gray-300'
checked ? 'bg-brand border-brand' : 'bg-white border-gray-300'
}`}
>
{checked && <Check className="w-3.5 h-3.5 text-white" />}
@@ -1377,7 +1377,7 @@ const AccountList: React.FC = () => {
type="button"
onClick={() => setAiSettings({ ...aiSettings, ai_enabled: !aiSettings.ai_enabled })}
className={`w-14 h-8 rounded-full transition-colors duration-300 relative ${
aiSettings.ai_enabled ? 'bg-[#0094f7]' : 'bg-gray-300'
aiSettings.ai_enabled ? 'bg-brand' : 'bg-gray-300'
}`}
>
<span
+9 -9
View File
@@ -313,7 +313,7 @@ const CardList: React.FC = () => {
</div>
<div className="ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white">
<div className="flex flex-col gap-3 border-b border-gray-50 bg-[#FAFAFA] p-4 sm:flex-row sm:items-center sm:justify-between">
<div className="flex flex-col gap-3 border-b border-gray-50 bg-surface-muted p-4 sm:flex-row sm:items-center sm:justify-between">
<div className="flex flex-1 flex-col gap-3 sm:flex-row">
<div className="relative sm:w-48">
<SlidersHorizontal className="pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400" />
@@ -375,7 +375,7 @@ const CardList: React.FC = () => {
}
return (
<tr key={card.id} className="hover:bg-[#FFFDE7]/50 transition-colors group">
<tr key={card.id} className="hover:bg-warning-50/50 transition-colors group">
<td className="px-5 py-5 align-middle">
<div className="flex items-center gap-2.5">
<div className="shrink-0 rounded-xl bg-gray-50 p-2 transition-colors group-hover:bg-white">
@@ -667,7 +667,7 @@ const CardList: React.FC = () => {
type="button"
onClick={() => setEditForm({ ...editForm, enabled: !editForm.enabled })}
className={`w-14 h-8 rounded-full transition-colors duration-300 relative ${
editForm.enabled ? 'bg-[#0094f7]' : 'bg-gray-300'
editForm.enabled ? 'bg-brand' : 'bg-gray-300'
}`}
>
<span
@@ -739,7 +739,7 @@ const CardList: React.FC = () => {
<button
type="button"
onClick={() => setAddForm({ ...addForm, type: 'data', content: '' })}
className={`p-3 rounded-xl font-bold transition-all ${addForm.type === 'data' ? 'bg-[#0094f7] text-white' : 'bg-gray-100 text-gray-600 hover:bg-gray-200'}`}
className={`p-3 rounded-xl font-bold transition-all ${addForm.type === 'data' ? 'bg-brand text-white' : 'bg-gray-100 text-gray-600 hover:bg-gray-200'}`}
>
<CreditCard className="w-5 h-5 mx-auto mb-1" />
批量库存
@@ -747,7 +747,7 @@ const CardList: React.FC = () => {
<button
type="button"
onClick={() => setAddForm({ ...addForm, type: 'text', content: '' })}
className={`p-3 rounded-xl font-bold transition-all ${addForm.type === 'text' ? 'bg-[#0094f7] text-white' : 'bg-gray-100 text-gray-600'}`}
className={`p-3 rounded-xl font-bold transition-all ${addForm.type === 'text' ? 'bg-brand text-white' : 'bg-gray-100 text-gray-600'}`}
>
<FileText className="w-5 h-5 mx-auto mb-1" />
文本
@@ -755,7 +755,7 @@ const CardList: React.FC = () => {
<button
type="button"
onClick={() => setAddForm({ ...addForm, type: 'image', content: '' })}
className={`p-3 rounded-xl font-bold transition-all ${addForm.type === 'image' ? 'bg-[#0094f7] text-white' : 'bg-gray-100 text-gray-600'}`}
className={`p-3 rounded-xl font-bold transition-all ${addForm.type === 'image' ? 'bg-brand text-white' : 'bg-gray-100 text-gray-600'}`}
>
<ImageIcon className="w-5 h-5 mx-auto mb-1" />
图片
@@ -792,7 +792,7 @@ const CardList: React.FC = () => {
/>
)}
{addForm.type === 'data' && (
<p className="text-xs text-gray-500">当前库存:<span className="font-bold text-[#0094f7]">{addForm.content.split('\n').filter(line => line.trim()).length}</span> 条</p>
<p className="text-xs text-gray-500">当前库存:<span className="font-bold text-brand">{addForm.content.split('\n').filter(line => line.trim()).length}</span> 条</p>
)}
</div>
@@ -879,14 +879,14 @@ const CardList: React.FC = () => {
<div className="flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl">
<button
onClick={() => setBatchTab('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 ${batchTab === 'create' ? 'bg-[#0094f7] text-white shadow-md' : 'bg-white text-gray-600 hover:bg-gray-50'}`}
className={`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${batchTab === 'create' ? 'bg-brand text-white shadow-md' : 'bg-white text-gray-600 hover:bg-gray-50'}`}
>
<ListPlus className="w-4 h-4" />
批量创建卡密组
</button>
<button
onClick={() => setBatchTab('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 ${batchTab === 'append' ? 'bg-[#0094f7] text-white shadow-md' : 'bg-white text-gray-600 hover:bg-gray-50'}`}
className={`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${batchTab === 'append' ? 'bg-brand text-white shadow-md' : 'bg-white text-gray-600 hover:bg-gray-50'}`}
>
<Upload className="w-4 h-4" />
往单个组充卡密
+32 -9
View File
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
import {
AlertCircle, Check, CheckCheck, ImagePlus, Loader2, MessageCircleMore, RefreshCw,
Search, Send, Smile, UserRound, Wifi, WifiOff,
@@ -53,6 +53,9 @@ const Chat: React.FC = () => {
const activeAccountRef = useRef('');
const activeChatRef = useRef('');
const scrollRef = useRef<HTMLDivElement | null>(null);
const scrollContextRef = useRef({ accountID: '', chatID: '' });
const shouldScrollToBottomRef = useRef(true);
const skipNextMessageScrollRef = useRef(false);
const imageInputRef = useRef<HTMLInputElement | null>(null);
const refreshedAccountsRef = useRef(new Set<string>());
@@ -177,6 +180,7 @@ const Chat: React.FC = () => {
if (!activeAccountID || !activeChatID || olderLoading || !hasOlder) return;
const container = scrollRef.current;
const previousHeight = container?.scrollHeight || 0;
skipNextMessageScrollRef.current = true;
setOlderLoading(true);
setError('');
try {
@@ -192,6 +196,7 @@ const Chat: React.FC = () => {
if (container) container.scrollTop += container.scrollHeight - previousHeight;
});
} catch (loadError) {
skipNextMessageScrollRef.current = false;
setError(loadError instanceof Error ? loadError.message : '加载历史消息失败');
} finally {
setOlderLoading(false);
@@ -261,10 +266,28 @@ const Chat: React.FC = () => {
};
}, []);
useEffect(() => {
const handleMessageScroll = () => {
const container = scrollRef.current;
if (container) container.scrollTop = container.scrollHeight;
}, [activeAccountID, activeChatID, messagesLoading]);
if (!container) return;
const distanceFromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
shouldScrollToBottomRef.current = distanceFromBottom <= 48;
};
useLayoutEffect(() => {
const contextChanged = scrollContextRef.current.accountID !== activeAccountID
|| scrollContextRef.current.chatID !== activeChatID;
scrollContextRef.current = { accountID: activeAccountID, chatID: activeChatID };
if (contextChanged) shouldScrollToBottomRef.current = true;
const container = scrollRef.current;
if (!container) return;
if (skipNextMessageScrollRef.current) {
skipNextMessageScrollRef.current = false;
return;
}
if (messagesLoading || shouldScrollToBottomRef.current) container.scrollTop = container.scrollHeight;
}, [activeAccountID, activeChatID, messages, messagesLoading]);
const activeAccount = accounts.find(account => account.id === activeAccountID);
const activeSessions = sessionsByAccount[activeAccountID] || [];
@@ -343,7 +366,7 @@ const Chat: React.FC = () => {
if (loading) return <div className="flex h-[calc(100vh-4rem)] items-center justify-center"><Loader2 className="h-8 w-8 animate-spin text-sky-500" /></div>;
return (
<section className="flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-[0_16px_45px_rgba(15,23,42,0.06)]">
<section className="flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-chat">
<header className="border-b border-slate-200 bg-slate-50/70 px-5 pt-4">
<div className="mb-3 flex items-center justify-between gap-4">
<div>
@@ -400,7 +423,7 @@ const Chat: React.FC = () => {
<div className="min-h-0 flex-1 overflow-y-auto">
{filteredSessions.map(session => (
<button key={session.chat_id} type="button" onClick={() => setActiveChatID(session.chat_id)}
className={`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${session.chat_id === activeChatID ? 'bg-white shadow-[inset_3px_0_0_#0ea5e9]' : 'hover:bg-white/80'}`}>
className={`flex w-full gap-3 border-b border-slate-100 p-4 text-left transition-colors ${session.chat_id === activeChatID ? 'bg-white shadow-chat-active' : 'hover:bg-white/80'}`}>
<div className="flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-slate-200 text-slate-500">
{session.buyer_avatar_url ? <img src={session.buyer_avatar_url} alt="" className="h-full w-full object-cover" /> : <UserRound className="h-5 w-5" />}
</div>
@@ -427,7 +450,7 @@ const Chat: React.FC = () => {
</div>
</aside>
<main className="flex min-h-0 min-w-0 flex-col overflow-hidden bg-[#f7f8fa]">
<main className="flex min-h-0 min-w-0 flex-col overflow-hidden bg-surface-subtle">
{selectedSession ? (
<>
<div className="flex h-16 shrink-0 items-center border-b border-slate-200 bg-white px-5">
@@ -439,7 +462,7 @@ const Chat: React.FC = () => {
{activeAccount?.runtime_state === 'online' ? '账号在线' : '账号离线'}
</span>
</div>
<div ref={scrollRef} className="min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5">
<div ref={scrollRef} onScroll={handleMessageScroll} className="min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5">
{messagesLoading ? <div className="flex justify-center py-12"><Loader2 className="h-6 w-6 animate-spin text-sky-500" /></div> : <>
{hasOlder && <div className="flex justify-center pb-1">
<button type="button" onClick={() => void loadOlderMessages()} disabled={olderLoading}
@@ -490,7 +513,7 @@ const Chat: React.FC = () => {
</>}
</div>
{error && <div className="border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700">{error}</div>}
<div className="relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-[0_-8px_24px_rgba(15,23,42,0.04)]">
<div className="relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-chat-input">
<div className="mb-2 flex items-center gap-1">
<div className="relative">
<button type="button" onClick={() => setEmojiOpen(value => !value)} disabled={sending || activeAccount?.runtime_state !== 'online'} className="rounded-lg p-2 text-slate-500 hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40" title="闲鱼表情"><Smile className="h-5 w-5" /></button>
+2 -3
View File
@@ -33,9 +33,8 @@ describe('Dashboard presentation safeguards', () => {
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(dashboardSource).not.toMatch(/#[0-9A-Fa-f]{3,8}/);
expect(dashboardSource).toContain("fill={cssColor('brand')}");
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');
+51 -39
View File
@@ -6,11 +6,17 @@ import { formatLocalDateTime } from '../dateTime';
import { TrendingUp, Users, ShoppingCart, AlertCircle, DollarSign, Activity, Package, ArrowUpRight, Calendar, X, BarChart3, PackageCheck, ExternalLink, Eye, Edit } from 'lucide-react';
import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, BarChart, Bar, PieChart, Pie, Cell, Legend } from 'recharts';
const cssColor = (token: string, alpha?: number) => (
alpha === undefined
? `rgb(var(--color-${token}))`
: `rgb(var(--color-${token}) / ${alpha})`
);
// 状态徽章组件
export const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => {
const styles = {
processing: 'bg-blue-100 text-blue-800',
pending_ship: 'bg-[#0094f7] text-white',
pending_ship: 'bg-brand text-white',
shipped: 'bg-blue-100 text-blue-700',
completed: 'bg-green-100 text-green-700',
cancelled: 'bg-gray-100 text-gray-500',
@@ -42,7 +48,7 @@ const StatCard: React.FC<{ title: string; value: string | number; icon: React.El
<div className={`p-4 rounded-2xl ${colorClass} bg-opacity-10 backdrop-blur-sm`}>
<Icon className={`w-6 h-6 ${colorClass.replace('bg-', 'text-')}`} />
</div>
{trend && <span className="text-xs font-bold text-white bg-[#0094f7] px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm">
{trend && <span className="text-xs font-bold text-white bg-brand px-3 py-1.5 rounded-full flex items-center gap-1 shadow-sm">
<TrendingUp className="w-3 h-3" /> {trend}
</span>}
</div>
@@ -75,7 +81,13 @@ const Dashboard: React.FC = () => {
const rangeRequestSequence = useRef(0);
// 颜色配置
const COLORS = ['#0094f7', '#3B82F6', '#10B981', '#F59E0B', '#8B5CF6'];
const COLORS = [
cssColor('brand'),
cssColor('brand-highlight'),
cssColor('success-500'),
cssColor('warning-500'),
cssColor('accent-500'),
];
const formatCurrency = (value: number) => `¥${Number(value || 0).toLocaleString('zh-CN', { maximumFractionDigits: 2 })}`;
const loadRange = async (range: TimeRange) => {
let currentRange;
@@ -159,7 +171,7 @@ const Dashboard: React.FC = () => {
</div>
);
}
if (!stats || !analytics) return <div className="p-8 flex justify-center text-gray-400"><Activity className="w-8 h-8 animate-spin text-[#0094f7]" /></div>;
if (!stats || !analytics) return <div className="p-8 flex justify-center text-gray-400"><Activity className="w-8 h-8 animate-spin text-brand" /></div>;
const chartData = analytics.daily_stats?.map(d => ({
name: d.date.slice(5), // MM-DD
@@ -267,7 +279,7 @@ const Dashboard: React.FC = () => {
onClick={() => setTimeRange(option.key)}
className={`px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${
timeRange === option.key
? 'bg-[#0094f7] text-white shadow-md'
? 'bg-brand text-white shadow-md'
: 'bg-white text-gray-600 hover:text-black hover:bg-gray-50'
}`}
>
@@ -280,14 +292,14 @@ const Dashboard: React.FC = () => {
type="date"
value={customStartDate}
onChange={(e) => setCustomStartDate(e.target.value)}
className="px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"
className="px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"
/>
<span className="self-center text-gray-400">-</span>
<input
type="date"
value={customEndDate}
onChange={(e) => setCustomEndDate(e.target.value)}
className="px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-[#0094f7]"
className="px-3 py-2 rounded-xl text-sm border border-gray-200 focus:outline-none focus:ring-2 focus:ring-brand"
/>
<button
onClick={() => {
@@ -356,26 +368,26 @@ const Dashboard: React.FC = () => {
dataKey="name"
axisLine={false}
tickLine={false}
tick={{fill: '#374151', fontSize: 14, fontWeight: 600}}
tick={{fill: cssColor('neutral-700'), fontSize: 14, fontWeight: 600}}
dy={10}
/>
<YAxis
axisLine={false}
tickLine={false}
tick={{fill: '#9CA3AF', fontSize: 13, fontWeight: 500}}
tick={{fill: cssColor('neutral-400'), fontSize: 13, fontWeight: 500}}
tickFormatter={(value) => `¥${value}`}
/>
<Tooltip
contentStyle={{
backgroundColor: '#fff',
backgroundColor: cssColor('white'),
borderRadius: '8px',
border: '1px solid #e5e7eb',
boxShadow: '0 10px 25px -5px rgba(0, 0, 0, 0.1)',
border: `1px solid ${cssColor('neutral-200')}`,
boxShadow: 'var(--shadow-xl)',
padding: '12px 16px'
}}
labelStyle={{ color: '#6b7280', fontWeight: 500 }}
itemStyle={{ color: '#0094f7', fontWeight: 600 }}
cursor={{ fill: 'rgba(0, 148, 247, 0.08)' }}
labelStyle={{ color: cssColor('neutral-500'), fontWeight: 500 }}
itemStyle={{ color: cssColor('brand'), fontWeight: 600 }}
cursor={{ fill: cssColor('brand', 0.08) }}
formatter={(value) => {
const num = Number(value);
return [`¥${num.toFixed(2)}`, '营收'];
@@ -383,7 +395,7 @@ const Dashboard: React.FC = () => {
/>
<Bar
dataKey="amount"
fill="#0094f7"
fill={cssColor('brand')}
maxBarSize={72}
radius={[12, 12, 0, 0]}
activeBar={false}
@@ -393,7 +405,7 @@ const Dashboard: React.FC = () => {
{chartData.map((_, index) => (
<Cell
key={`cell-${index}`}
fill="#0094f7"
fill={cssColor('brand')}
stroke="none"
strokeWidth={0}
/>
@@ -407,36 +419,36 @@ const Dashboard: React.FC = () => {
<AreaChart data={chartData} margin={{ top: 10, right: 10, left: -20, bottom: 0 }}>
<defs>
<linearGradient id="colorAmount" x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stopColor="#0094f7" stopOpacity={0.5}/>
<stop offset="95%" stopColor="#0094f7" stopOpacity={0}/>
<stop offset="5%" stopColor={cssColor('brand')} stopOpacity={0.5}/>
<stop offset="95%" stopColor={cssColor('brand')} stopOpacity={0}/>
</linearGradient>
</defs>
<XAxis
dataKey="name"
axisLine={false}
tickLine={false}
tick={{fill: '#9CA3AF', fontSize: 13, fontWeight: 500}}
tick={{fill: cssColor('neutral-400'), fontSize: 13, fontWeight: 500}}
dy={15}
/>
<YAxis
axisLine={false}
tickLine={false}
tick={{fill: '#9CA3AF', fontSize: 13, fontWeight: 500}}
tick={{fill: cssColor('neutral-400'), fontSize: 13, fontWeight: 500}}
/>
<CartesianGrid vertical={false} stroke="#F3F4F6" strokeDasharray="3 3" />
<CartesianGrid vertical={false} stroke={cssColor('neutral-100')} strokeDasharray="3 3" />
<Tooltip
contentStyle={{
backgroundColor: '#fff',
backgroundColor: cssColor('white'),
borderRadius: '8px',
border: '1px solid #e5e7eb',
boxShadow: '0 10px 25px -5px rgba(0, 0, 0, 0.1)',
border: `1px solid ${cssColor('neutral-200')}`,
boxShadow: 'var(--shadow-xl)',
padding: '12px 16px'
}}
labelStyle={{ color: '#6b7280', fontWeight: 500 }}
itemStyle={{ color: '#0094f7', fontWeight: 600 }}
cursor={{ stroke: '#0094f7', strokeWidth: 2, strokeDasharray: '4 4' }}
labelStyle={{ color: cssColor('neutral-500'), fontWeight: 500 }}
itemStyle={{ color: cssColor('brand'), fontWeight: 600 }}
cursor={{ stroke: cssColor('brand'), strokeWidth: 2, strokeDasharray: '4 4' }}
/>
<Area type="monotone" dataKey="amount" stroke="#0094f7" strokeWidth={4} fillOpacity={1} fill="url(#colorAmount)" activeDot={{ r: 8, fill: '#fff', stroke: "#0094f7", strokeWidth: 2 }} />
<Area type="monotone" dataKey="amount" stroke={cssColor('brand')} strokeWidth={4} fillOpacity={1} fill="url(#colorAmount)" activeDot={{ r: 8, fill: cssColor('white'), stroke: cssColor('brand'), strokeWidth: 2 }} />
</AreaChart>
</ResponsiveContainer>
)}
@@ -466,7 +478,7 @@ const Dashboard: React.FC = () => {
</div>
<div className="h-3 rounded-full bg-gray-100 overflow-hidden">
<div
className="h-full rounded-full bg-[#0094f7]"
className="h-full rounded-full bg-brand"
style={{ width: `${Math.max(8, (item.sales / maxProductSales) * 100)}%` }}
/>
</div>
@@ -516,17 +528,17 @@ const Dashboard: React.FC = () => {
formatter={(value) => `${Number(value || 0)} 单`}
wrapperStyle={{ zIndex: 30, outline: 'none' }}
contentStyle={{
backgroundColor: '#fff',
border: '1px solid #e5e7eb',
backgroundColor: cssColor('white'),
border: `1px solid ${cssColor('neutral-200')}`,
borderRadius: '10px',
boxShadow: '0 8px 20px rgba(15, 23, 42, 0.08)'
boxShadow: 'var(--shadow-md)'
}}
/>
<Legend
verticalAlign="bottom"
height={36}
iconType="circle"
formatter={(value) => <span style={{ color: '#6B7280', fontWeight: 500 }}>{value}</span>}
formatter={(value) => <span style={{ color: cssColor('neutral-500'), fontWeight: 500 }}>{value}</span>}
/>
</PieChart>
</ResponsiveContainer>
@@ -544,7 +556,7 @@ const Dashboard: React.FC = () => {
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
{/* 参与统计的订单列表 */}
<div className="lg:col-span-2 ios-card p-0 rounded-xl border-0 bg-white overflow-hidden flex flex-col">
<div className="p-6 border-b border-gray-50 flex justify-between items-center bg-[#FAFAFA]">
<div className="p-6 border-b border-gray-50 flex justify-between items-center bg-surface-muted">
<div>
<h3 className="font-bold text-lg text-gray-900">参与统计的订单</h3>
{validOrdersTruncated && (
@@ -603,7 +615,7 @@ const Dashboard: React.FC = () => {
</thead>
<tbody className="divide-y divide-gray-50">
{filteredValidOrders.map((order) => (
<tr key={order.order_id} className="hover:bg-[#FFFDE7]/50 transition-colors group">
<tr key={order.order_id} className="hover:bg-warning-50/50 transition-colors group">
<td className="px-6 py-4">
<div className="flex items-center gap-3">
<div className="w-12 h-12 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0">
@@ -687,10 +699,10 @@ const Dashboard: React.FC = () => {
<Tooltip
wrapperStyle={{ zIndex: 30, outline: 'none' }}
contentStyle={{
backgroundColor: '#fff',
border: '1px solid #e5e7eb',
backgroundColor: cssColor('white'),
border: `1px solid ${cssColor('neutral-200')}`,
borderRadius: '6px',
boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1)'
boxShadow: 'var(--shadow-md)'
}}
formatter={(value) => `¥${Number(value || 0).toLocaleString()}`}
/>
+5 -5
View File
@@ -638,14 +638,14 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
</button>
<button
onClick={openPublishModal}
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"
className="px-5 py-3 rounded-2xl font-bold bg-emerald-500 text-white hover:bg-emerald-600 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100"
>
<PackagePlus className="w-4 h-4" />
发布商品
</button>
<button
onClick={() => void openBatchModal()}
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"
className="px-5 py-3 rounded-2xl font-bold bg-brand text-white hover:bg-brand-highlight transition-colors flex items-center gap-2 shadow-lg shadow-blue-100"
>
<UploadCloud className="w-4 h-4" />
{recentBatch && ['running', 'canceling'].includes(recentBatch.status) ? '继续批量任务' : '批量铺货'}
@@ -670,7 +670,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
<div className="absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10">
<button
onClick={() => handleEdit(item)}
className="p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-[#0094f7] hover:text-white transition-colors"
className="p-1.5 bg-white/90 backdrop-blur rounded-lg shadow-md text-gray-600 hover:bg-brand hover:text-white transition-colors"
title="编辑"
>
<Edit className="w-3.5 h-3.5" />
@@ -710,7 +710,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
<div className="space-y-2 mt-auto">
<button
onClick={() => onConfigureDelivery(item)}
className={`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${hasRule ? 'bg-gray-900 text-white hover:bg-black' : 'bg-[#0094f7] text-white hover:bg-[#0071e3] shadow-md shadow-blue-100'}`}
className={`w-full flex items-center justify-between gap-1 px-2.5 py-2 rounded-lg text-[11px] font-extrabold transition-all ${hasRule ? 'bg-gray-900 text-white hover:bg-black' : 'bg-brand text-white hover:bg-brand-highlight shadow-md shadow-blue-100'}`}
>
<span className="flex items-center gap-1.5"><Link2 className="w-3.5 h-3.5" />{hasRule ? '查看发货规则' : '关联发货规则'}</span>
<ArrowRight className="w-3.5 h-3.5" />
@@ -892,7 +892,7 @@ const ItemList: React.FC<ItemListProps> = ({ onConfigureDelivery }) => {
</div>
</div>
<div className="modal-footer">
<button disabled={publishing} onClick={handlePublishItem} className="w-full bg-emerald-600 hover:bg-emerald-700 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2">
<button disabled={publishing} onClick={handlePublishItem} className="w-full bg-emerald-500 hover:bg-emerald-600 disabled:opacity-60 text-white px-6 py-3.5 rounded-xl font-bold flex items-center justify-center gap-2">
<PackagePlus className="w-4 h-4" />
{publishing ? '正在发布...' : '发布到闲鱼'}
</button>
+12 -13
View File
@@ -394,7 +394,7 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
{/* 说明 */}
<div className="ios-card rounded-xl p-5 bg-blue-50/50 border border-blue-100">
<div className="flex items-start gap-3">
<Bell className="w-5 h-5 text-[#0094f7] mt-0.5 flex-shrink-0" />
<Bell className="w-5 h-5 text-brand mt-0.5 flex-shrink-0" />
<div className="text-sm text-gray-700 leading-6">
配置通知渠道并在「账号管理 → 编辑」里绑定后,以下事件会主动推送到该账号绑定的渠道:
<ul className="mt-2 space-y-1 text-gray-600">
@@ -409,7 +409,7 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
{/* 渠道列表 */}
{loading ? (
<div className="flex justify-center py-20">
<Loader2 className="w-8 h-8 text-[#0094f7] animate-spin" />
<Loader2 className="w-8 h-8 text-brand animate-spin" />
</div>
) : channels.length === 0 ? (
<div className="ios-card rounded-xl p-12 bg-white text-center">
@@ -454,7 +454,7 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
<button
onClick={() => handleTest(ch)}
disabled={testingId === ch.id}
className="px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-[#0094f7] hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50"
className="px-3 py-1.5 rounded-lg text-xs font-bold bg-blue-50 text-brand hover:bg-blue-100 transition-colors flex items-center gap-1 disabled:opacity-50"
>
{testingId === ch.id ? <Loader2 className="w-3 h-3 animate-spin" /> : <Send className="w-3 h-3" />}
测试
@@ -639,10 +639,10 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
key={t}
type="button"
onClick={() => setForm({ ...form, type: t, config: {} })}
className={`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${selected ? 'border-[#0094f7] bg-blue-50' : 'border-gray-100 hover:border-gray-300'}`}
className={`p-3 rounded-xl border-2 flex flex-col items-center gap-1.5 transition-all ${selected ? 'border-brand bg-blue-50' : 'border-gray-100 hover:border-gray-300'}`}
>
<TIcon className={`w-5 h-5 ${selected ? 'text-[#0094f7]' : 'text-gray-500'}`} />
<span className={`text-xs font-bold ${selected ? 'text-[#0094f7]' : 'text-gray-600'}`}>{m.label}</span>
<TIcon className={`w-5 h-5 ${selected ? 'text-brand' : 'text-gray-500'}`} />
<span className={`text-xs font-bold ${selected ? 'text-brand' : 'text-gray-600'}`}>{m.label}</span>
</button>
);
})}
@@ -712,7 +712,7 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
: enableCustomSMTP(form.config, smtp),
});
}}
className={`relative h-7 w-12 shrink-0 rounded-full transition-colors ${form.config.use_custom_smtp === true ? 'bg-[#0094f7]' : 'bg-gray-300'}`}
className={`relative h-7 w-12 shrink-0 rounded-full transition-colors ${form.config.use_custom_smtp === true ? 'bg-brand' : 'bg-gray-300'}`}
aria-label="使用独立 SMTP"
>
<span className={`absolute left-1 top-1 h-5 w-5 rounded-full bg-white shadow-sm transition-transform ${form.config.use_custom_smtp === true ? 'translate-x-5' : ''}`} />
@@ -839,13 +839,13 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
: [...form.event_types, event.value];
setForm({ ...form, event_types: next });
}}
className={`text-left rounded-xl border px-3 py-2.5 transition-colors ${checked ? 'border-[#0094f7] bg-blue-50' : 'border-gray-100 hover:border-gray-300'}`}
className={`text-left rounded-xl border px-3 py-2.5 transition-colors ${checked ? 'border-brand bg-blue-50' : 'border-gray-100 hover:border-gray-300'}`}
>
<div className="flex items-center gap-2">
<span className={`w-4 h-4 rounded border flex items-center justify-center ${checked ? 'bg-[#0094f7] border-[#0094f7]' : 'border-gray-300'}`}>
<span className={`w-4 h-4 rounded border flex items-center justify-center ${checked ? 'bg-brand border-brand' : 'border-gray-300'}`}>
{checked && <Check className="w-3 h-3 text-white" />}
</span>
<span className={`text-sm font-bold ${checked ? 'text-[#0094f7]' : 'text-gray-800'}`}>{event.label}</span>
<span className={`text-sm font-bold ${checked ? 'text-brand' : 'text-gray-800'}`}>{event.label}</span>
</div>
<p className="text-xs text-gray-500 mt-1 pl-6 leading-5">{event.description}</p>
</button>
@@ -858,7 +858,7 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
<button
type="button"
onClick={() => setForm({ ...form, enabled: !form.enabled })}
className={`relative w-11 h-6 rounded-full transition-colors ${form.enabled ? 'bg-[#0094f7]' : 'bg-gray-300'}`}
className={`relative w-11 h-6 rounded-full transition-colors ${form.enabled ? 'bg-brand' : 'bg-gray-300'}`}
>
<span className={`absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform ${form.enabled ? 'translate-x-5' : ''}`} />
</button>
@@ -889,8 +889,7 @@ const Notifications: React.FC<NotificationsProps> = ({ isAdmin = false }) => {
{/* Toast */}
{toast && (
<div className="fixed bottom-8 left-1/2 -translate-x-1/2 z-[10000] px-5 py-3 rounded-xl shadow-lg font-bold text-sm flex items-center gap-2 animate-fade-in"
style={{ background: toast.type === 'success' ? '#10b981' : '#ef4444', color: 'white' }}>
<div className={`fixed bottom-8 left-1/2 -translate-x-1/2 z-[10000] px-5 py-3 rounded-xl shadow-lg font-bold text-sm flex items-center gap-2 animate-fade-in text-white ${toast.type === 'success' ? 'bg-success-500' : 'bg-danger-500'}`}>
{toast.type === 'success' ? <Check className="w-4 h-4" /> : <X className="w-4 h-4" />}
{toast.text}
</div>
+5 -5
View File
@@ -9,7 +9,7 @@ import { formatLocalDateTime } from '../dateTime';
const StatusBadge: React.FC<{ status: OrderStatus }> = ({ status }) => {
const styles = {
processing: 'bg-blue-100 text-blue-800',
pending_ship: 'bg-[#0094f7] text-white',
pending_ship: 'bg-brand text-white',
shipped: 'bg-blue-100 text-blue-700',
completed: 'bg-green-100 text-green-700',
cancelled: 'bg-gray-100 text-gray-500',
@@ -356,7 +356,7 @@ const OrderList: React.FC = () => {
<div className="ios-card rounded-xl overflow-hidden shadow-lg border-0 bg-white">
{/* Toolbar */}
<div className="p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-[#FAFAFA]">
<div className="p-4 border-b border-gray-50 flex flex-col md:flex-row gap-4 justify-between items-center bg-surface-muted">
<div className="flex gap-1 p-1 bg-gray-200/50 rounded-xl overflow-x-auto max-w-full">
{[
{k:'all', v:'全部'},
@@ -392,7 +392,7 @@ const OrderList: React.FC = () => {
</select>
</div>
<div className="relative group">
<Search className="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-[#0094f7] transition-colors" />
<Search className="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-brand transition-colors" />
<input
type="text"
placeholder="搜索订单号/商品/买家..."
@@ -418,7 +418,7 @@ const OrderList: React.FC = () => {
</thead>
<tbody className="divide-y divide-gray-50">
{orders.map((order) => (
<tr key={order.id} className="hover:bg-[#FFFDE7]/50 transition-colors group">
<tr key={order.id} className="hover:bg-warning-50/50 transition-colors group">
<td className="px-6 py-5">
<div className="flex items-center gap-5">
<div className="w-14 h-14 rounded-xl bg-gray-100 overflow-hidden shadow-sm border border-gray-100 flex-shrink-0">
@@ -800,7 +800,7 @@ const OrderList: React.FC = () => {
<button
onClick={() => executeShip('full_delivery')}
disabled={shipLoading}
className="w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-[#0094f7] hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed"
className="w-full text-left p-4 rounded-xl border-2 border-gray-200 hover:border-brand hover:bg-blue-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed"
>
<div className="flex items-start gap-3">
<div className="w-10 h-10 rounded-xl bg-blue-100 flex items-center justify-center flex-shrink-0 mt-0.5">
+11 -11
View File
@@ -842,7 +842,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
onClick={() => setActiveTab(tab.id)}
className={`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-bold transition-all ${
activeTab === tab.id
? 'bg-[#0094f7] text-white shadow-md'
? 'bg-brand text-white shadow-md'
: 'bg-white text-gray-600 hover:text-black hover:bg-gray-50'
}`}
>
@@ -949,7 +949,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
</aside>
<section className="min-w-0 space-y-4">
<div className="rounded-xl border border-gray-100 bg-[#FAFAFA] p-4 shadow-sm">
<div className="rounded-xl border border-gray-100 bg-surface-muted p-4 shadow-sm">
<div className="flex flex-col gap-3 xl:flex-row xl:items-center">
<div className="relative min-w-0 flex-1">
<Search className="pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400" />
@@ -1112,7 +1112,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
type="button"
disabled={loading}
onClick={() => setAutomationPage(pageNumber)}
className={`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${pageNumber === automationPage ? 'bg-[#0094f7] text-white' : 'bg-gray-50 text-gray-600 hover:bg-gray-100'} disabled:cursor-not-allowed disabled:opacity-60`}
className={`h-9 min-w-9 rounded-lg px-2 text-sm font-bold transition-colors ${pageNumber === automationPage ? 'bg-brand text-white' : 'bg-gray-50 text-gray-600 hover:bg-gray-100'} disabled:cursor-not-allowed disabled:opacity-60`}
aria-label={`第 ${pageNumber} 页`}
aria-current={pageNumber === automationPage ? 'page' : undefined}
>
@@ -1144,7 +1144,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
</div>
<div className="space-y-3">
{replyRules.map(rule => (
<div key={rule.id} className="flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg transition-all gap-4">
<div key={rule.id} className="flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border border-gray-100 bg-surface-subtle hover:bg-white hover:shadow-lg transition-all gap-4">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-3 mb-2">
<span className="px-3 py-1 bg-black text-white rounded-lg text-xs font-bold">包含匹配</span>
@@ -1187,7 +1187,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
const defaultReply = defaultReplies[account.id];
const enabled = Boolean(defaultReply?.enabled);
return (
<div key={account.id} className={`flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border transition-all gap-4 ${enabled ? 'border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg' : 'border-gray-100 bg-[#F7F8FA] hover:bg-white hover:shadow-lg'}`}>
<div key={account.id} className={`flex flex-col md:flex-row md:items-center justify-between p-5 rounded-2xl border transition-all gap-4 ${enabled ? 'border-purple-100 bg-purple-50/50 hover:bg-white hover:shadow-lg' : 'border-gray-100 bg-surface-subtle hover:bg-white hover:shadow-lg'}`}>
<div className="flex items-center gap-4 min-w-0">
<div className={`w-12 h-12 rounded-2xl flex items-center justify-center ${enabled ? 'bg-purple-600 text-white' : 'bg-gray-200 text-gray-400'}`}>
<Bot className="w-5 h-5" />
@@ -1272,7 +1272,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
}`}
>
<div className="flex items-start gap-3">
<Icon className={`w-5 h-5 mt-0.5 ${selected ? 'text-[#0094f7]' : 'text-white'}`} />
<Icon className={`w-5 h-5 mt-0.5 ${selected ? 'text-brand' : 'text-white'}`} />
<div>
<div className="font-black">{meta.label}</div>
<div className={`text-xs mt-1 leading-5 ${selected ? 'text-gray-500' : 'text-gray-400'}`}>{meta.description}</div>
@@ -1296,11 +1296,11 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
</div>
</aside>
<div className="p-6 overflow-y-auto bg-[#F7F8FA]">
<div className="p-6 overflow-y-auto bg-surface-subtle">
<div className="space-y-5">
<section className="bg-white rounded-3xl border border-gray-100 p-5">
<div className="flex items-center gap-2 mb-4">
<CheckCircle2 className="w-5 h-5 text-[#0094f7]" />
<CheckCircle2 className="w-5 h-5 text-brand" />
<h4 className="font-black text-gray-900">生效范围</h4>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
@@ -1369,7 +1369,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
<div className="flex items-start justify-between gap-4 mb-4">
<div>
<div className="flex items-center gap-2">
<Layers3 className="w-5 h-5 text-[#0094f7]" />
<Layers3 className="w-5 h-5 text-brand" />
<h4 className="font-black text-gray-900">{currentTrigger === 'buyer_reviewed' ? '赠品库存' : '发货库存'}</h4>
</div>
<p className="text-sm text-gray-500 mt-1">
@@ -1446,7 +1446,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
type="checkbox"
checked={variant.delay_override === true}
onChange={event => updateVariant(index, { delay_override: event.target.checked })}
className="accent-[#0094f7]"
className="accent-brand"
/>
覆盖卡密默认延时
</label>
@@ -1738,7 +1738,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
<button
type="button"
onClick={() => setDefaultForm({ ...defaultForm, enabled: !defaultForm.enabled })}
className={`w-14 h-8 rounded-full transition-colors duration-300 relative ${defaultForm.enabled ? 'bg-[#0094f7]' : 'bg-gray-300'}`}
className={`w-14 h-8 rounded-full transition-colors duration-300 relative ${defaultForm.enabled ? 'bg-brand' : 'bg-gray-300'}`}
>
<span className={`absolute top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 block ${defaultForm.enabled ? 'translate-x-7' : 'translate-x-1'}`} />
</button>
+3 -3
View File
@@ -269,7 +269,7 @@ const Settings: React.FC = () => {
{/* AI Configuration */}
<section className="space-y-4">
<h3 className="text-lg font-extrabold text-gray-800 flex items-center gap-2">
<div className="p-1.5 rounded-lg bg-[#0094f7] text-white">
<div className="p-1.5 rounded-lg bg-brand text-white">
<Sparkles className="w-4 h-4" />
</div>
AI 智能回复配置
@@ -346,10 +346,10 @@ const Settings: React.FC = () => {
setSettings({...settings, ai_model: model});
setModelDropdownOpen(false);
}}
className="w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-[#0094f7] flex items-center justify-between gap-3"
className="w-full px-4 py-2.5 text-left text-sm text-gray-700 hover:bg-blue-50 hover:text-brand flex items-center justify-between gap-3"
>
<span className="truncate">{model}</span>
{model === currentModel && <Check className="w-4 h-4 shrink-0 text-[#0094f7]" />}
{model === currentModel && <Check className="w-4 h-4 shrink-0 text-brand" />}
</button>
))
) : (
+2 -2
View File
@@ -30,7 +30,7 @@ const Sidebar: React.FC<SidebarProps> = ({
];
return (
<aside className={`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-[4px_0_24px_rgba(15,23,42,0.035)] backdrop-blur-xl transition-[width] duration-300 ${collapsed ? 'w-16' : 'w-64'}`}>
<aside className={`fixed inset-y-0 left-0 z-20 flex flex-col border-r border-slate-200/80 bg-white/95 shadow-sidebar backdrop-blur-xl transition-[width] duration-300 ${collapsed ? 'w-16' : 'w-64'}`}>
<div className={`flex h-20 items-center border-b border-slate-100 ${collapsed ? 'justify-center px-2' : 'gap-3 px-5'}`}>
<YdisksBrandIcon sizeClass="h-10 w-10" />
{!collapsed && (
@@ -55,7 +55,7 @@ const Sidebar: React.FC<SidebarProps> = ({
onClick={() => onNavigate(item.id)}
className={`group relative flex h-11 w-full items-center rounded-xl transition-colors ${collapsed ? 'justify-center' : 'gap-3 px-3.5'} ${
active
? 'bg-sky-500 text-white shadow-[0_8px_18px_rgba(14,165,233,0.2)]'
? 'bg-brand text-white shadow-brand-active'
: 'text-slate-500 hover:bg-slate-100 hover:text-slate-900'
}`}
>
+2 -2
View File
@@ -27,8 +27,8 @@ export const YdisksBrandIcon: React.FC<YdisksBrandIconProps> = ({
<svg className="absolute inset-0 w-full h-full" viewBox="0 0 120 120" aria-hidden="true">
<defs>
<linearGradient id="login-squircle-gradient" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stopColor="#0094f7" />
<stop offset="100%" stopColor="#287efe" />
<stop offset="0%" stopColor="rgb(var(--color-brand))" />
<stop offset="100%" stopColor="rgb(var(--color-brand-light))" />
</linearGradient>
</defs>
<path d="M 114.00 60.00 L 113.83 71.48 L 113.31 78.16 L 112.44 83.67 L 111.22 88.46 L 109.66 92.71 L 107.75 96.49 L 105.48 99.87 L 102.86 102.86 L 99.87 105.48 L 96.49 107.75 L 92.71 109.66 L 88.46 111.22 L 83.67 112.44 L 78.16 113.31 L 71.48 113.83 L 60.00 114.00 L 48.52 113.83 L 41.84 113.31 L 36.33 112.44 L 31.54 111.22 L 27.29 109.66 L 23.51 107.75 L 20.13 105.48 L 17.14 102.86 L 14.52 99.87 L 12.25 96.49 L 10.34 92.71 L 8.78 88.46 L 7.56 83.67 L 6.69 78.16 L 6.17 71.48 L 6.00 60.00 L 6.17 48.52 L 6.69 41.84 L 7.56 36.33 L 8.78 31.54 L 10.34 27.29 L 12.25 23.51 L 14.52 20.13 L 17.14 17.14 L 20.13 14.52 L 23.51 12.25 L 27.29 10.34 L 31.54 8.78 L 36.33 7.56 L 41.84 6.69 L 48.52 6.17 L 60.00 6.00 L 71.48 6.17 L 78.16 6.69 L 83.67 7.56 L 88.46 8.78 L 92.71 10.34 L 96.49 12.25 L 99.87 14.52 L 102.86 17.14 L 105.48 20.13 L 107.75 23.51 L 109.66 27.29 L 111.22 31.54 L 112.44 36.33 L 113.31 41.84 L 113.83 48.52 Z" fill="url(#login-squircle-gradient)" />
+210 -59
View File
@@ -3,6 +3,157 @@
@tailwind components;
@tailwind utilities;
/*
* 全局颜色令牌:页面组件不得直接写颜色值。
* 颜色使用 RGB 通道存储,Tailwind 和 CSS 可以安全地复用透明度。
*/
:root {
--color-transparent: transparent;
--color-black: 0 0 0;
--color-white: 255 255 255;
--color-brand: 0 148 247;
--color-brand-highlight: 0 113 227;
--color-brand-light: 40 126 254;
--color-ink: 29 29 31;
--color-muted: 134 134 139;
--color-line: 210 210 215;
--color-canvas: 244 245 247;
--color-surface: 255 255 255;
--color-surface-subtle: 247 248 250;
--color-surface-muted: 250 250 250;
--color-neutral-50: 249 250 251;
--color-neutral-100: 243 244 246;
--color-neutral-200: 229 231 235;
--color-neutral-300: 209 213 219;
--color-neutral-400: 156 163 175;
--color-neutral-500: 107 114 128;
--color-neutral-600: 75 85 99;
--color-neutral-700: 55 65 81;
--color-neutral-800: 31 41 55;
--color-neutral-900: 17 24 39;
--color-neutral-950: 3 7 18;
--color-slate-50: 248 250 252;
--color-slate-100: 241 245 249;
--color-slate-200: 226 232 240;
--color-slate-300: 203 213 225;
--color-slate-400: 148 163 184;
--color-slate-500: 100 116 139;
--color-slate-600: 71 85 105;
--color-slate-700: 51 65 85;
--color-slate-800: 30 41 59;
--color-slate-900: 15 23 42;
--color-slate-950: 2 6 23;
/* 主色阶:蓝色只从品牌色体系中取值,避免 blue/sky 各自漂移。 */
--color-brand-50: 239 248 255;
--color-brand-100: 223 241 255;
--color-brand-200: 191 229 255;
--color-brand-300: 143 210 255;
--color-brand-400: 83 184 251;
--color-brand-500: 0 148 247;
--color-brand-600: 0 148 247;
--color-brand-700: 0 113 227;
--color-brand-800: 0 91 181;
--color-brand-900: 0 75 147;
--color-brand-950: 0 53 107;
--color-success-50: 236 253 245;
--color-success-100: 209 250 229;
--color-success-200: 167 243 208;
--color-success-300: 110 231 183;
--color-success-400: 52 211 153;
--color-success-500: 16 185 129;
--color-success-600: 5 150 105;
--color-success-700: 4 120 87;
--color-success-800: 6 95 70;
--color-success-900: 6 78 59;
--color-success-950: 2 44 34;
--color-warning-50: 255 251 235;
--color-warning-100: 254 243 199;
--color-warning-200: 253 230 138;
--color-warning-300: 252 211 77;
--color-warning-400: 251 191 36;
--color-warning-500: 245 158 11;
--color-warning-600: 217 119 6;
--color-warning-700: 180 83 9;
--color-warning-800: 146 64 14;
--color-warning-900: 120 53 15;
--color-warning-950: 69 26 3;
--color-danger-50: 254 242 242;
--color-danger-100: 254 226 226;
--color-danger-200: 254 202 202;
--color-danger-300: 252 165 165;
--color-danger-400: 248 113 113;
--color-danger-500: 239 68 68;
--color-danger-600: 220 38 38;
--color-danger-700: 185 28 28;
--color-danger-800: 153 27 27;
--color-danger-900: 127 29 29;
--color-danger-950: 69 10 10;
--color-info-50: 239 246 255;
--color-info-100: 219 234 254;
--color-info-200: 191 219 254;
--color-info-300: 147 197 253;
--color-info-400: 96 165 250;
--color-info-500: 59 130 246;
--color-info-600: 37 99 235;
--color-info-700: 29 78 216;
--color-info-800: 30 64 175;
--color-info-900: 30 58 138;
--color-info-950: 23 37 84;
/* 非状态性的辅助色只保留一个紫色阶,避免页面出现过多彩色分支。 */
--color-accent-50: 250 245 255;
--color-accent-100: 243 232 255;
--color-accent-200: 233 213 255;
--color-accent-300: 216 180 254;
--color-accent-400: 192 132 252;
--color-accent-500: 168 85 247;
--color-accent-600: 147 51 234;
--color-accent-700: 126 34 206;
--color-accent-800: 107 33 168;
--color-accent-900: 88 28 135;
--color-accent-950: 59 7 100;
--shadow-none: 0 0 0 var(--color-transparent);
--shadow-default: 0 1px 3px 0 rgb(var(--color-black) / 0.1), 0 1px 2px -1px rgb(var(--color-black) / 0.1);
--shadow-sm: 0 1px 2px 0 rgb(var(--color-black) / 0.05);
--shadow-md: 0 4px 6px -1px rgb(var(--color-black) / 0.1), 0 2px 4px -2px rgb(var(--color-black) / 0.1);
--shadow-lg: 0 10px 15px -3px rgb(var(--color-black) / 0.1), 0 4px 6px -4px rgb(var(--color-black) / 0.1);
--shadow-xl: 0 20px 25px -5px rgb(var(--color-black) / 0.1), 0 8px 10px -6px rgb(var(--color-black) / 0.1);
--shadow-2xl: 0 25px 50px -12px rgb(var(--color-black) / 0.25);
--shadow-inner: inset 0 2px 4px 0 rgb(var(--color-black) / 0.05);
--shadow-card: 0 8px 24px rgb(var(--color-black) / 0.04);
--shadow-panel: 0 20px 60px -15px rgb(var(--color-black) / 0.05);
--shadow-modal: 0 25px 50px -12px rgb(var(--color-black) / 0.25);
--shadow-sidebar: 4px 0 24px rgb(var(--color-slate-900) / 0.035);
--shadow-chat: 0 16px 45px rgb(var(--color-slate-900) / 0.06);
--shadow-chat-input: 0 -8px 24px rgb(var(--color-slate-900) / 0.04);
--shadow-chat-active: inset 3px 0 0 rgb(var(--color-brand));
--shadow-brand-soft: 0 2px 8px rgb(var(--color-brand) / 0.2);
--shadow-brand-active: 0 8px 18px rgb(var(--color-brand) / 0.2);
--shadow-brand-strong: 0 8px 20px rgb(var(--color-brand) / 0.3);
}
/* 覆盖 Tailwind 默认的蓝色焦点环和黑色占位阴影,避免预设色偷偷进入页面。 */
*,
::before,
::after {
--tw-ring-offset-color: rgb(var(--color-white));
--tw-ring-color: rgb(var(--color-brand-400) / 0.5);
--tw-ring-offset-shadow: 0 0 0 var(--color-transparent);
--tw-ring-shadow: 0 0 0 var(--color-transparent);
--tw-shadow: 0 0 0 var(--color-transparent);
--tw-shadow-colored: 0 0 0 var(--color-transparent);
}
/* Ydisks 超椭圆 logo 容器:用 squircle mask 实现真超椭圆(比圆角矩形更鼓)。
mask 让容器背景色(蓝)也裁成超椭圆形状。
shadow 改用 filter:drop-shadow,跟随 mask 后的实际形状(box-shadow 会被 mask 裁掉)。 */
@@ -34,23 +185,23 @@ html, body, #root {
body {
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
"Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
background-color: #F4F5F7;
color: #ffffff;
background-color: rgb(var(--color-canvas));
color: rgb(var(--color-ink));
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* 闲鱼风格卡片 */
.ios-card {
background: #FFFFFF;
background: rgb(var(--color-surface));
border-radius: 8px;
border: 1px solid rgba(0, 0, 0, 0.02);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
border: 1px solid rgb(var(--color-black) / 0.02);
box-shadow: var(--shadow-card);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ios-card:hover {
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
box-shadow: 0 12px 32px rgb(var(--color-black) / 0.06);
}
/* 仪表盘饼图是展示型图表,避免 Recharts 的 SVG 焦点框和扇区焦点框形成无意义长条。 */
@@ -78,29 +229,29 @@ body {
/* 闲鱼风格输入框 */
.ios-input {
background: #F7F8FA;
border: 1px solid transparent;
background: rgb(var(--color-surface-subtle));
border: 1px solid var(--color-transparent);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
color: #111;
color: rgb(var(--color-ink));
font-weight: 500;
}
.ios-input:focus {
background: #FFFFFF;
border-color: #0094f7;
box-shadow: 0 0 0 4px rgba(0, 148, 247, 0.3);
background: rgb(var(--color-surface));
border-color: rgb(var(--color-brand));
box-shadow: 0 0 0 4px rgb(var(--color-brand) / 0.3);
outline: none;
}
.ios-input::placeholder {
color: #9CA3AF;
color: rgb(var(--color-neutral-400));
font-weight: 400;
}
/* 主按钮 */
.ios-btn-primary {
background: #0094f7;
color: #ffffff;
background: rgb(var(--color-brand));
color: rgb(var(--color-white));
font-weight: 700;
border: none;
transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
@@ -108,19 +259,19 @@ body {
}
.ios-btn-primary:hover:not(:disabled) {
background: #0071e3;
background: rgb(var(--color-brand-highlight));
transform: translateY(-1px);
box-shadow: 0 8px 20px rgba(0, 148, 247, 0.3);
box-shadow: var(--shadow-brand-strong);
}
.ios-btn-primary:active:not(:disabled) {
transform: translateY(1px);
box-shadow: 0 2px 8px rgba(0, 148, 247, 0.2);
box-shadow: var(--shadow-brand-soft);
}
.ios-btn-primary:disabled {
background: #F0F0F0;
color: #AAAAAA;
background: rgb(var(--color-neutral-100));
color: rgb(var(--color-neutral-400));
box-shadow: none;
transform: none;
cursor: not-allowed;
@@ -128,32 +279,32 @@ body {
/* 次要按钮 */
.ios-btn-secondary {
background: #F7F8FA;
color: #ffffff;
background: rgb(var(--color-surface-subtle));
color: rgb(var(--color-ink));
font-weight: 600;
border: 1px solid transparent;
border: 1px solid var(--color-transparent);
transition: all 0.2s ease;
cursor: pointer;
}
.ios-btn-secondary:hover {
background: #E5E7EB;
border-color: #D1D5DB;
background: rgb(var(--color-neutral-200));
border-color: rgb(var(--color-neutral-300));
}
/* 危险按钮 */
.ios-btn-danger {
background: #FEE2E2;
color: #DC2626;
background: rgb(var(--color-danger-100));
color: rgb(var(--color-danger-600));
font-weight: 600;
border: 1px solid transparent;
border: 1px solid var(--color-transparent);
transition: all 0.2s ease;
cursor: pointer;
}
.ios-btn-danger:hover {
background: #FECACA;
border-color: #FCA5A5;
background: rgb(var(--color-danger-200));
border-color: rgb(var(--color-danger-300));
}
/* 自定义滚动条 */
@@ -163,16 +314,16 @@ body {
}
::-webkit-scrollbar-track {
background: transparent;
background: var(--color-transparent);
}
::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.1);
background: rgb(var(--color-black) / 0.1);
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(0, 0, 0, 0.2);
background: rgb(var(--color-black) / 0.2);
}
/* 动画 */
@@ -234,21 +385,21 @@ body {
/* 文本选择 */
::selection {
background: #0094f7;
color: #fff;
background: rgb(var(--color-brand));
color: rgb(var(--color-white));
}
/* 工具类 */
.text-brand {
color: #0094f7;
color: rgb(var(--color-brand));
}
.bg-brand {
background-color: #0094f7;
background-color: rgb(var(--color-brand));
}
.border-brand {
border-color: #0094f7;
border-color: rgb(var(--color-brand));
}
/* 状态徽章 */
@@ -262,31 +413,31 @@ body {
}
.status-badge-success {
background-color: #D1FAE5;
color: #065F46;
background-color: rgb(var(--color-success-100));
color: rgb(var(--color-success-800));
}
.status-badge-warning {
background-color: #FEF3C7;
color: #92400E;
background-color: rgb(var(--color-warning-100));
color: rgb(var(--color-warning-800));
}
.status-badge-error {
background-color: #FEE2E2;
color: #991B1B;
background-color: rgb(var(--color-danger-100));
color: rgb(var(--color-danger-800));
}
.status-badge-info {
background-color: #DBEAFE;
color: #1E40AF;
background-color: rgb(var(--color-info-100));
color: rgb(var(--color-info-800));
}
/* 加载状态 */
.loading-skeleton {
background: linear-gradient(90deg,
#F3F4F6 0%,
#E5E7EB 50%,
#F3F4F6 100%);
rgb(var(--color-neutral-100)) 0%,
rgb(var(--color-neutral-200)) 50%,
rgb(var(--color-neutral-100)) 100%);
background-size: 200% 100%;
animation: loading 1.5s ease-in-out infinite;
}
@@ -308,7 +459,7 @@ body {
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.4);
background-color: rgb(var(--color-black) / 0.4);
backdrop-filter: blur(8px);
padding: 1rem;
overflow-y: auto;
@@ -322,17 +473,17 @@ body {
margin: auto;
display: flex;
flex-direction: column;
background-color: white;
background-color: rgb(var(--color-white));
border-radius: 10px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
box-shadow: var(--shadow-modal);
overflow: hidden;
}
.modal-header {
flex-shrink: 0;
padding: 2rem 2rem 1.5rem;
border-bottom: 1px solid #F3F4F6;
background-color: white;
border-bottom: 1px solid rgb(var(--color-neutral-100));
background-color: rgb(var(--color-white));
z-index: 10;
}
@@ -346,8 +497,8 @@ body {
.modal-footer {
flex-shrink: 0;
padding: 1.5rem 2rem 2rem;
border-top: 1px solid #F3F4F6;
background-color: white;
border-top: 1px solid rgb(var(--color-neutral-100));
background-color: rgb(var(--color-white));
z-index: 10;
}
@@ -363,7 +514,7 @@ body {
z-index: 9999;
display: flex;
justify-content: center;
background-color: rgba(0, 0, 0, 0.4);
background-color: rgb(var(--color-black) / 0.4);
backdrop-filter: blur(8px);
padding: 1rem;
overflow-y: auto;
@@ -377,9 +528,9 @@ body {
margin: auto 0;
display: flex;
flex-direction: column;
background-color: white;
background-color: rgb(var(--color-white));
border-radius: 10px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
box-shadow: var(--shadow-modal);
overflow: hidden;
}
+17
View File
@@ -0,0 +1,17 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, test } from 'vitest';
const itemList = readFileSync(resolve(__dirname, 'components/ItemList.tsx'), 'utf8');
describe('item list primary action colors', () => {
test('uses the shared primary blue for batch publishing', () => {
expect(itemList).toContain('bg-brand text-white hover:bg-brand-highlight');
expect(itemList).not.toContain('bg-blue-600 text-white hover:bg-blue-700');
});
test('uses the lighter emerald tone for publishing actions', () => {
expect(itemList).toContain('bg-emerald-500 text-white hover:bg-emerald-600');
expect(itemList).not.toContain('bg-emerald-600 text-white hover:bg-emerald-700');
});
});
+7
View File
@@ -26,6 +26,13 @@ describe('frontend navigation routing', () => {
expect([...sidebarIDs].sort()).toEqual([...appRouteIDs].sort());
});
test('active navigation uses the primary action blue', () => {
const sidebar = readFrontendFile('components/Sidebar.tsx');
expect(sidebar).toContain("'bg-brand text-white shadow-brand-active'");
expect(sidebar).not.toContain("'bg-sky-500 text-white'");
});
test('logout button invalidates the backend session before clearing UI state', () => {
const app = readFrontendFile('App.tsx');
+62 -10
View File
@@ -1,3 +1,10 @@
const color = (token) => `rgb(var(--color-${token}) / <alpha-value>)`;
const palette = (name) => Object.fromEntries(
[50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
.map((shade) => [shade, color(`${name}-${shade}`)]),
);
/** @type {import('tailwindcss').Config} */
export default {
content: [
@@ -8,18 +15,40 @@ export default {
theme: {
extend: {
colors: {
// Ydisks 官网配色:Apple 风格蓝色系 + 浅灰背景 + 深色文字。
// 具体色值统一维护在 index.css 的 --color-* 令牌中,组件只使用语义化 Tailwind 类名。
transparent: 'var(--color-transparent)',
current: 'currentColor',
black: color('black'),
white: color('white'),
brand: {
DEFAULT: '#0094f7', // 主品牌蓝(Ydisks logo/按钮色)
dark: '#0071e3', // 深蓝(hover/强调)
light: '#287efe', // 亮蓝(辅助)
DEFAULT: color('brand'),
highlight: color('brand-highlight'),
light: color('brand-light'),
},
// Ydisks 中性色
ink: '#1d1d1f', // 主文字
muted: '#86868b', // 次要文字
line: '#d2d2d7', // 边框/分隔
canvas: '#fbfbfd', // 页面背景
surface: '#f5f5f7', // 卡片背景/区块
ink: color('ink'),
muted: color('muted'),
line: color('line'),
canvas: color('canvas'),
surface: color('surface'),
'surface-subtle': color('surface-subtle'),
'surface-muted': color('surface-muted'),
success: palette('success'),
warning: palette('warning'),
danger: palette('danger'),
info: palette('info'),
// 保留现有 Tailwind 语义类,但统一指向同一套设计令牌。
gray: palette('neutral'),
slate: palette('slate'),
blue: palette('brand'),
sky: palette('brand'),
emerald: palette('success'),
green: palette('success'),
amber: palette('warning'),
orange: palette('warning'),
red: palette('danger'),
yellow: palette('warning'),
purple: palette('accent'),
pink: palette('accent'),
},
// 圆角统一收紧到 5–10px 区间,UI 更紧凑、信息密度更高。
borderRadius: {
@@ -45,6 +74,29 @@ export default {
'sans-serif',
],
},
accentColor: {
brand: color('brand'),
},
boxShadow: {
none: 'var(--shadow-none)',
sm: 'var(--shadow-sm)',
DEFAULT: 'var(--shadow-default)',
md: 'var(--shadow-md)',
lg: 'var(--shadow-lg)',
xl: 'var(--shadow-xl)',
'2xl': 'var(--shadow-2xl)',
inner: 'var(--shadow-inner)',
card: 'var(--shadow-card)',
panel: 'var(--shadow-panel)',
modal: 'var(--shadow-modal)',
sidebar: 'var(--shadow-sidebar)',
chat: 'var(--shadow-chat)',
'chat-input': 'var(--shadow-chat-input)',
'chat-active': 'var(--shadow-chat-active)',
'brand-soft': 'var(--shadow-brand-soft)',
'brand-active': 'var(--shadow-brand-active)',
'brand-strong': 'var(--shadow-brand-strong)',
},
},
},
plugins: [],