From 3f4d4cf6096eeec4309441d4ba77901624d55d5b Mon Sep 17 00:00:00 2001 From: Monster <389264167@qq.com> Date: Fri, 18 Jul 2025 19:05:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/api/types.ts | 4 +++ ui/src/pages/chat/index.tsx | 59 ++++++++++++++++++++++++++++++-- ui/src/pages/user/chat/index.tsx | 1 + 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/ui/src/api/types.ts b/ui/src/api/types.ts index 0a4e9c4..9b40a6a 100644 --- a/ui/src/api/types.ts +++ b/ui/src/api/types.ts @@ -767,6 +767,8 @@ export interface GetListChatRecordParams { page?: number; /** 每页多少条记录 */ size?: number; + /** 工作模式 */ + work_mode?: string; } export interface GetCompletionInfoParams { @@ -787,6 +789,8 @@ export interface GetListCompletionRecordParams { page?: number; /** 每页多少条记录 */ size?: number; + /** 工作模式 */ + work_mode?: string; } export interface GetCategoryStatDashboardParams { diff --git a/ui/src/pages/chat/index.tsx b/ui/src/pages/chat/index.tsx index d1759f1..d54b46f 100644 --- a/ui/src/pages/chat/index.tsx +++ b/ui/src/pages/chat/index.tsx @@ -4,7 +4,7 @@ import { getListChatRecord } from '@/api/Billing'; import dayjs from 'dayjs'; import Card from '@/components/card'; -import { Box } from '@mui/material'; +import { Autocomplete, Box, FormControl, InputLabel, MenuItem, Select, Stack, TextField } from '@mui/material'; import StyledLabel from '@/components/label'; import ChatDetailModal from './chatDetailModal'; @@ -12,6 +12,9 @@ import { ColumnsType } from '@c-x/ui/dist/Table'; import { DomainChatRecord, DomainUser } from '@/api/types'; import { addCommasToNumber } from '@/utils'; import User from '@/components/user'; +import { useRequest } from 'ahooks'; +import { getListUser } from '@/api/User'; +import { set } from 'react-hook-form'; const Chat = () => { const [page, setPage] = useState(1); @@ -22,11 +25,25 @@ const Chat = () => { const [chatDetailModal, setChatDetailModal] = useState< DomainChatRecord | undefined >(); + const [filterUser, setFilterUser] = useState(''); + const [filterMode, setfilterMode] = useState< + 'code' | 'architect' | 'ask' | 'debug' | 'orchestrator' + >(); + + const { data: userOptions = { users: [] } } = useRequest(() => + getListUser({ + page: 1, + size: 9999, + }) + ); + const fetchData = async () => { setLoading(true); const res = await getListChatRecord({ page: page, size: size, + work_mode: filterMode, + author: filterUser, }); setLoading(false); setTotal(res?.total_count || 0); @@ -34,9 +51,10 @@ const Chat = () => { }; useEffect(() => { + setPage(1); fetchData(); // eslint-disable-next-line - }, [page, size]); + }, [page, size, filterMode, filterUser]); const columns: ColumnsType = [ { @@ -137,6 +155,43 @@ const Chat = () => { ]; return ( + + option.username || ''} + value={ + userOptions.users?.find((item) => item.username === filterUser) || + null + } + onChange={(_, newValue) => + setFilterUser(newValue ? newValue.username! : '') + } + isOptionEqualToValue={(option, value) => + option.username === value.username + } + renderInput={(params) => } + clearOnEscape + /> + + 工作模式 + + + { }; useEffect(() => { + setPage(1); // 筛选变化时重置页码 fetchData(); // eslint-disable-next-line }, [page, size]);