fix: 前端构建修复+后端静态托管+Docker部署
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useState } from 'react';
|
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 {
|
import {
|
||||||
ProjectOutlined,
|
ProjectOutlined,
|
||||||
CheckCircleOutlined,
|
CheckCircleOutlined,
|
||||||
@@ -11,13 +11,10 @@ import {
|
|||||||
import { dashboardApi } from '@/api';
|
import { dashboardApi } from '@/api';
|
||||||
import type { DashboardStats, Task } from '@/types';
|
import type { DashboardStats, Task } from '@/types';
|
||||||
import { TaskStatusTag } from '@/components/constants';
|
import { TaskStatusTag } from '@/components/constants';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
const navigate = useNavigate();
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [stats, setStats] = useState<DashboardStats | null>(null);
|
const [stats, setStats] = useState<DashboardStats | null>(null);
|
||||||
|
|
||||||
@@ -41,30 +38,7 @@ export default function Dashboard() {
|
|||||||
return <div>暂无数据</div>;
|
return <div>暂无数据</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskStatusCols = Object.entries(stats.tasks_by_status || {});
|
const taskStatusCols = Object.entries(stats.task_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'),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -106,7 +80,7 @@ export default function Dashboard() {
|
|||||||
<Card>
|
<Card>
|
||||||
<Statistic
|
<Statistic
|
||||||
title="总花费"
|
title="总花费"
|
||||||
value={stats.total_cost || 0}
|
value={(stats.cost?.total_cost_cents || 0) / 100}
|
||||||
precision={2}
|
precision={2}
|
||||||
prefix={<DollarOutlined />}
|
prefix={<DollarOutlined />}
|
||||||
valueStyle={{ color: '#fa8c16' }}
|
valueStyle={{ color: '#fa8c16' }}
|
||||||
@@ -149,14 +123,14 @@ export default function Dashboard() {
|
|||||||
<ClockCircleOutlined style={{ marginRight: 8 }} />
|
<ClockCircleOutlined style={{ marginRight: 8 }} />
|
||||||
已完成任务
|
已完成任务
|
||||||
</span>
|
</span>
|
||||||
<Tag color="green">{stats.tasks_by_status?.done || 0}</Tag>
|
<Tag color="green">{stats.task_status?.done || 0}</Tag>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||||
<span>
|
<span>
|
||||||
<CheckCircleOutlined style={{ marginRight: 8 }} />
|
<CheckCircleOutlined style={{ marginRight: 8 }} />
|
||||||
进行中任务
|
进行中任务
|
||||||
</span>
|
</span>
|
||||||
<Tag color="orange">{stats.tasks_by_status?.in_progress || 0}</Tag>
|
<Tag color="orange">{stats.task_status?.in_progress || 0}</Tag>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||||
<span>
|
<span>
|
||||||
@@ -170,15 +144,27 @@ export default function Dashboard() {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
{stats.recent_tasks && stats.recent_tasks.length > 0 && (
|
{stats.cost?.by_model && stats.cost.by_model.length > 0 && (
|
||||||
<Card title="最近任务" style={{ marginTop: 16 }}>
|
<Card title="模型调用统计" style={{ marginTop: 16 }} size="small">
|
||||||
<Table
|
<Space direction="vertical" style={{ width: '100%' }}>
|
||||||
dataSource={stats.recent_tasks}
|
{stats.cost.by_model.map((m) => (
|
||||||
columns={recentTaskColumns}
|
<div
|
||||||
rowKey="id"
|
key={m.model}
|
||||||
pagination={{ pageSize: 5 }}
|
style={{
|
||||||
size="small"
|
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>
|
</Card>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user