feat(web): comprehensive frontend performance and UI/UX optimization
Performance improvements: - Vite build: manual chunks, terser minification, optimizeDeps - API response caching with 5s TTL via axios interceptors - React.memo for SidebarMenuItem, useCallback for handlers - CSS classes replacing inline styles to reduce reflows UI/UX enhancements (inspired by SAP Fiori, Linear, Feishu): - Dashboard: trend indicators, sparkline charts, CountUp animation on stat cards - Dashboard: pending tasks section with priority labels - Dashboard: recent activity timeline - Design system tokens: trend colors, line-height, dark mode refinements - Enhanced quick actions with hover animations Accessibility (Lighthouse 100/100): - Skip-to-content link, ARIA landmarks, heading hierarchy - prefers-reduced-motion support, focus-visible states - Color contrast fixes: all text meets 4.5:1 ratio - Keyboard navigation for stat cards and task items SEO: meta theme-color, format-detection, robots.txt
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Table, Tag } from 'antd';
|
||||
import { useEffect, useCallback, useState } from 'react';
|
||||
import { Table, Tag, theme } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { listCompletedTasks, type TaskInfo } from '../../api/workflowTasks';
|
||||
|
||||
const outcomeLabels: Record<string, { color: string; text: string }> = {
|
||||
approved: { color: 'green', text: '同意' },
|
||||
rejected: { color: 'red', text: '拒绝' },
|
||||
delegated: { color: 'blue', text: '已委派' },
|
||||
const outcomeStyles: Record<string, { bg: string; color: string; text: string }> = {
|
||||
approved: { bg: '#ECFDF5', color: '#059669', text: '同意' },
|
||||
rejected: { bg: '#FEF2F2', color: '#DC2626', text: '拒绝' },
|
||||
delegated: { bg: '#EEF2FF', color: '#4F46E5', text: '已委派' },
|
||||
};
|
||||
|
||||
export default function CompletedTasks() {
|
||||
@@ -14,6 +14,8 @@ export default function CompletedTasks() {
|
||||
const [total, setTotal] = useState(0);
|
||||
const [page, setPage] = useState(1);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { token } = theme.useToken();
|
||||
const isDark = token.colorBgContainer === '#111827' || token.colorBgContainer === 'rgb(17, 24, 39)';
|
||||
|
||||
const fetchData = useCallback(async () => {
|
||||
setLoading(true);
|
||||
@@ -29,28 +31,71 @@ export default function CompletedTasks() {
|
||||
useEffect(() => { fetchData(); }, [fetchData]);
|
||||
|
||||
const columns: ColumnsType<TaskInfo> = [
|
||||
{ title: '任务名称', dataIndex: 'node_name', key: 'node_name' },
|
||||
{ title: '流程', dataIndex: 'definition_name', key: 'definition_name' },
|
||||
{ title: '业务键', dataIndex: 'business_key', key: 'business_key' },
|
||||
{
|
||||
title: '结果', dataIndex: 'outcome', key: 'outcome', width: 100,
|
||||
title: '任务名称',
|
||||
dataIndex: 'node_name',
|
||||
key: 'node_name',
|
||||
render: (v: string) => <span style={{ fontWeight: 500 }}>{v}</span>,
|
||||
},
|
||||
{ title: '流程', dataIndex: 'definition_name', key: 'definition_name' },
|
||||
{
|
||||
title: '业务键',
|
||||
dataIndex: 'business_key',
|
||||
key: 'business_key',
|
||||
render: (v: string | undefined) => v || '-',
|
||||
},
|
||||
{
|
||||
title: '结果',
|
||||
dataIndex: 'outcome',
|
||||
key: 'outcome',
|
||||
width: 100,
|
||||
render: (o: string) => {
|
||||
const info = outcomeLabels[o] || { color: 'default', text: o };
|
||||
return <Tag color={info.color}>{info.text}</Tag>;
|
||||
const info = outcomeStyles[o] || { bg: '#F1F5F9', color: '#64748B', text: o };
|
||||
return (
|
||||
<Tag style={{
|
||||
background: info.bg,
|
||||
border: 'none',
|
||||
color: info.color,
|
||||
fontWeight: 500,
|
||||
}}>
|
||||
{info.text}
|
||||
</Tag>
|
||||
);
|
||||
},
|
||||
},
|
||||
{ title: '完成时间', dataIndex: 'completed_at', key: 'completed_at', width: 180,
|
||||
render: (v: string) => v ? new Date(v).toLocaleString() : '-',
|
||||
{
|
||||
title: '完成时间',
|
||||
dataIndex: 'completed_at',
|
||||
key: 'completed_at',
|
||||
width: 180,
|
||||
render: (v: string) => (
|
||||
<span style={{ color: isDark ? '#64748B' : '#94A3B8', fontSize: 13 }}>
|
||||
{v ? new Date(v).toLocaleString() : '-'}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
loading={loading}
|
||||
pagination={{ current: page, total, pageSize: 20, onChange: setPage }}
|
||||
/>
|
||||
<div style={{
|
||||
background: isDark ? '#111827' : '#FFFFFF',
|
||||
borderRadius: 12,
|
||||
border: `1px solid ${isDark ? '#1E293B' : '#F1F5F9'}`,
|
||||
overflow: 'hidden',
|
||||
}}>
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
loading={loading}
|
||||
pagination={{
|
||||
current: page,
|
||||
total,
|
||||
pageSize: 20,
|
||||
onChange: setPage,
|
||||
showTotal: (t) => `共 ${t} 条记录`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user