feat: 完善聊天识别与规则页面响应式布局
- 按闲鱼协议字段识别官方系统消息、交易卡片和闲小蜜,清理空会话壳并补齐历史消息校正\n- 同步 README、项目展示页和 GitHub Wiki,补充在线聊天、账号自动评价与每日擦亮说明\n- 优化自动化规则页面的中等宽度布局,补充前端类型、响应式测试和嵌入资源
This commit is contained in:
1 parent
4d1f58c5ec
commit
fe3f715cdc
27 files changed
+336
-32
No files matched your search
+1
-1
@@ -302,7 +302,7 @@ const App: React.FC = () => {
|
||||
onLogout={handleLogout}
|
||||
/>
|
||||
|
||||
<main className={`h-screen flex-1 overflow-y-auto scroll-smooth transition-[margin] duration-300 ${sidebarCollapsed ? 'ml-16' : 'ml-64'} ${activeTab === 'chat' ? 'p-4 md:p-6' : 'p-8 md:p-12'}`}>
|
||||
<main className={`h-screen min-w-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth transition-[margin] duration-300 ${sidebarCollapsed ? 'ml-16' : 'ml-64'} ${activeTab === 'chat' ? 'p-4 md:p-6' : 'p-8 md:p-12'}`}>
|
||||
{/* Subtle background decoration */}
|
||||
<div className="fixed top-0 right-0 w-[800px] h-[800px] bg-gradient-to-bl from-blue-50 to-transparent rounded-full blur-[120px] pointer-events-none -z-10 opacity-60"></div>
|
||||
|
||||
|
||||
+3
-1
@@ -45,7 +45,9 @@ Dashboard 的营收趋势柱状图使用统一的品牌蓝 `#0094f7` 表示同
|
||||
|
||||
## 路由
|
||||
|
||||
应用使用 `window.history.pushState` 做 tab 导航,路径形如 `/app/dashboard`、`/app/rules`、`/app/settings`。
|
||||
应用使用 `window.history.pushState` 做 tab 导航,路径包括 `/app/dashboard`、`/app/accounts`、
|
||||
`/app/chat`、`/app/cards`、`/app/items`、`/app/orders`、`/app/rules`、
|
||||
`/app/notifications` 和管理员可见的 `/app/settings`。
|
||||
未登录时显示登录表单(客户端状态,非独立路由)。后端 SPA catch-all 对非 API 的 GET 请求返回 `index.html`,支持深链刷新。
|
||||
|
||||
## 测试
|
||||
|
||||
@@ -37,6 +37,12 @@ describe('online chat UI contract', () => {
|
||||
expect(chat).toContain('sendChatImage');
|
||||
});
|
||||
|
||||
test('renders official notices as neutral system messages', () => {
|
||||
const chat = source('components/Chat.tsx');
|
||||
expect(chat).toContain("message.message_type === 'system'");
|
||||
expect(chat).toContain('justify-center py-1');
|
||||
});
|
||||
|
||||
test('sidebar exposes collapse control and chat primary navigation', () => {
|
||||
const sidebar = source('components/Sidebar.tsx');
|
||||
expect(sidebar).toContain("id: 'chat'");
|
||||
|
||||
@@ -449,6 +449,17 @@ const Chat: React.FC = () => {
|
||||
</div>}
|
||||
{messages.map(message => {
|
||||
const outgoing = message.direction === 'outgoing';
|
||||
const system = message.message_type === 'system';
|
||||
if (system) {
|
||||
return (
|
||||
<div key={message.message_key} className="flex justify-center py-1">
|
||||
<div className="max-w-[82%] rounded-xl border border-slate-200 bg-slate-100 px-4 py-2 text-center text-xs leading-5 text-slate-500">
|
||||
{renderXianyuText(message.content)}
|
||||
<div className="mt-1 text-[10px] text-slate-400">{messageTime(message.sent_at)}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div key={message.message_key} className={`flex items-end gap-2.5 ${outgoing ? 'justify-end' : 'justify-start'}`}>
|
||||
{!outgoing && <div className="h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white">
|
||||
|
||||
@@ -801,7 +801,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
|
||||
: '编辑默认回复';
|
||||
|
||||
return (
|
||||
<div className="space-y-8 animate-fade-in">
|
||||
<div className="min-w-0 space-y-8 animate-fade-in">
|
||||
<div className="flex flex-col xl:flex-row justify-between xl:items-end gap-4">
|
||||
<div>
|
||||
<h2 className="text-4xl font-extrabold text-gray-900 tracking-tight">自动化规则</h2>
|
||||
@@ -814,7 +814,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
|
||||
setSelectedAccountId(event.target.value);
|
||||
setAutomationPage(1);
|
||||
}}
|
||||
className="ios-input px-4 py-3 rounded-2xl text-sm min-w-64"
|
||||
className="ios-input w-full px-4 py-3 rounded-2xl text-sm sm:w-64"
|
||||
>
|
||||
<option value="">全部账号</option>
|
||||
{accounts.map(account => (
|
||||
@@ -904,8 +904,8 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
|
||||
)}
|
||||
|
||||
{activeTab === 'automation' && (
|
||||
<div className="grid grid-cols-1 2xl:grid-cols-[360px_1fr] gap-6">
|
||||
<aside className="space-y-4">
|
||||
<div className="grid min-w-0 grid-cols-1 gap-6 xl:grid-cols-[minmax(270px,0.72fr)_minmax(0,1.28fr)]">
|
||||
<aside className="min-w-0 space-y-4">
|
||||
<div className="bg-white rounded-xl p-5 border border-gray-100 shadow-sm">
|
||||
<h3 className="font-black text-gray-900 mb-1">新建规则</h3>
|
||||
<p className="text-sm text-gray-500 mb-4">先选自动化类型,再配置对应动作。</p>
|
||||
@@ -958,7 +958,7 @@ const Rules: React.FC<RulesProps> = ({ initialDeliveryTarget, onDeliveryTargetHa
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section className="space-y-4">
|
||||
<section className="min-w-0 space-y-4">
|
||||
<div className="rounded-xl border border-gray-100 bg-[#FAFAFA] 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">
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
const source = (path: string) => readFileSync(resolve(__dirname, path), 'utf8');
|
||||
|
||||
describe('responsive rules layout', () => {
|
||||
test('allows the rules page to shrink inside the sidebar layout', () => {
|
||||
const app = source('App.tsx');
|
||||
const rules = source('components/Rules.tsx');
|
||||
expect(app).toContain('h-screen min-w-0 flex-1 overflow-x-hidden');
|
||||
expect(rules).toContain('min-w-0 space-y-8');
|
||||
expect(rules).toContain('xl:grid-cols-[minmax(270px,0.72fr)_minmax(0,1.28fr)]');
|
||||
expect(rules).not.toContain('2xl:grid-cols-[360px_1fr]');
|
||||
});
|
||||
});
|
||||
+2
-1
@@ -106,7 +106,8 @@ export interface ChatMessage {
|
||||
direction: 'incoming' | 'outgoing';
|
||||
sender_id: string;
|
||||
sender_name: string;
|
||||
message_type: 'text' | 'image' | 'video';
|
||||
/** text/image/video are peer messages; system is an official platform notice or trade card. */
|
||||
message_type: 'text' | 'image' | 'video' | 'system';
|
||||
content: string;
|
||||
status: 'received' | 'sending' | 'sent' | 'failed';
|
||||
sent_at: number;
|
||||
|
||||
Reference in new issue
Block a user