fix: 前端构建修复+后端静态托管+Docker部署

This commit is contained in:
2026-08-12 17:05:32 +08:00
parent ddbc3f59c7
commit 899fe76080
+26 -40
View File
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { Row, Col, Card, Statistic, Table, Tag, Space, Spin, Typography } from 'antd';
import { Row, Col, Card, Statistic, Space, Spin, Typography, Tag } from 'antd';
import {
ProjectOutlined,
CheckCircleOutlined,
@@ -11,13 +11,10 @@ import {
import { dashboardApi } from '@/api';
import type { DashboardStats, Task } from '@/types';
import { TaskStatusTag } from '@/components/constants';
import { useNavigate } from 'react-router-dom';
import dayjs from 'dayjs';
const { Title } = Typography;
export default function Dashboard() {
const navigate = useNavigate();
const [loading, setLoading] = useState(true);
const [stats, setStats] = useState<DashboardStats | null>(null);
@@ -41,30 +38,7 @@ export default function Dashboard() {
return <div></div>;
}
const taskStatusCols = Object.entries(stats.tasks_by_status || {});
const recentTaskColumns = [
{
title: '任务名称',
dataIndex: 'title',
key: 'title',
render: (text: string, record: Task) => (
<a onClick={() => navigate('/tasks')}>{text || record.id.slice(0, 8)}</a>
),
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
render: (status: Task['status']) => <TaskStatusTag status={status} />,
},
{
title: '创建时间',
dataIndex: 'created_at',
key: 'created_at',
render: (t: string) => dayjs(t).format('YYYY-MM-DD HH:mm'),
},
];
const taskStatusCols = Object.entries(stats.task_status || {});
return (
<div>
@@ -106,7 +80,7 @@ export default function Dashboard() {
<Card>
<Statistic
title="总花费"
value={stats.total_cost || 0}
value={(stats.cost?.total_cost_cents || 0) / 100}
precision={2}
prefix={<DollarOutlined />}
valueStyle={{ color: '#fa8c16' }}
@@ -149,14 +123,14 @@ export default function Dashboard() {
<ClockCircleOutlined style={{ marginRight: 8 }} />
</span>
<Tag color="green">{stats.tasks_by_status?.done || 0}</Tag>
<Tag color="green">{stats.task_status?.done || 0}</Tag>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>
<CheckCircleOutlined style={{ marginRight: 8 }} />
</span>
<Tag color="orange">{stats.tasks_by_status?.in_progress || 0}</Tag>
<Tag color="orange">{stats.task_status?.in_progress || 0}</Tag>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>
@@ -170,15 +144,27 @@ export default function Dashboard() {
</Col>
</Row>
{stats.recent_tasks && stats.recent_tasks.length > 0 && (
<Card title="最近任务" style={{ marginTop: 16 }}>
<Table
dataSource={stats.recent_tasks}
columns={recentTaskColumns}
rowKey="id"
pagination={{ pageSize: 5 }}
size="small"
/>
{stats.cost?.by_model && stats.cost.by_model.length > 0 && (
<Card title="模型调用统计" style={{ marginTop: 16 }} size="small">
<Space direction="vertical" style={{ width: '100%' }}>
{stats.cost.by_model.map((m) => (
<div
key={m.model}
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
padding: '4px 0',
}}
>
<span style={{ fontWeight: 600 }}>{m.model}</span>
<Space>
<Tag>{m.calls} </Tag>
<Tag color="orange">¥{(m.cost_cents / 100).toFixed(2)}</Tag>
</Space>
</div>
))}
</Space>
</Card>
)}
</div>