diff --git a/web/backend/routers/cookies.py b/web/backend/routers/cookies.py index dbeb7d6..dc95617 100644 --- a/web/backend/routers/cookies.py +++ b/web/backend/routers/cookies.py @@ -37,6 +37,8 @@ def list_cookies( "batch_id": t.batch_id, "account_id": t.account_id, "account_username": acc.username if acc else "", + "assigned_to": acc.assigned_to, + "assigned_username": acc.assigned_user.username if acc and acc.assigned_user else None, "created_at": t.finished_at.isoformat() if t.finished_at else None, } # 只有有 cookie:view 权限才返回 cookie 内容 diff --git a/web/frontend/src/pages/CookiePage.tsx b/web/frontend/src/pages/CookiePage.tsx index d85abee..f5fb3f5 100644 --- a/web/frontend/src/pages/CookiePage.tsx +++ b/web/frontend/src/pages/CookiePage.tsx @@ -1,13 +1,16 @@ import { useEffect, useState } from 'react'; -import { Table, Button, Card, Row, Col, Statistic, message, Tag, Popconfirm, Space } from 'antd'; -import { DownloadOutlined, DeleteOutlined, CopyOutlined } from '@ant-design/icons'; +import { Table, Button, Card, Row, Col, Statistic, message, Tag, Popconfirm, Space, Typography, Input } from 'antd'; +import { DownloadOutlined, DeleteOutlined, CopyOutlined, SearchOutlined } from '@ant-design/icons'; import { cookieApi } from '../api/modules'; import { getUser, hasPerm } from '../store/auth'; +const { Text } = Typography; + export default function CookiePage() { const [cookies, setCookies] = useState([]); const [loading, setLoading] = useState(false); const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const [searchText, setSearchText] = useState(''); const user = getUser(); const canView = hasPerm(user, 'cookie:view'); @@ -83,9 +86,32 @@ export default function CookiePage() { } }; + // 筛选 + const filteredCookies = cookies.filter((c) => { + if (!searchText) return true; + const s = searchText.toLowerCase(); + return ( + c.account_username?.toLowerCase().includes(s) || + c.assigned_username?.toLowerCase().includes(s) + ); + }); + const columns: any[] = [ - { title: 'ID', dataIndex: 'id', width: 60 }, - { title: '账号', dataIndex: 'account_username' }, + { title: 'ID', dataIndex: 'id', width: 60, align: 'center' }, + { + title: '账号', + dataIndex: 'account_username', + width: 140, + ellipsis: true, + }, + { + title: '分配', + dataIndex: 'assigned_username', + width: 100, + align: 'center', + render: (name: string | null) => + name ? {name} : 未分配, + }, { title: 'Cookie', dataIndex: 'cookie_preview', @@ -95,10 +121,18 @@ export default function CookiePage() { return {val}; }, }, - { title: '时间', dataIndex: 'created_at', width: 170 }, + { + title: '时间', + dataIndex: 'created_at', + width: 180, + align: 'center', + render: (val: string) => val ? val.replace('T', ' ').slice(0, 19) : '-', + }, { title: '操作', - width: 160, + width: 130, + align: 'center', + fixed: 'right', render: (_: any, record: any) => (