feat: 为CK页面增加标签筛选

This commit is contained in:
yml2213
2026-08-13 16:24:35 +08:00
parent 47ded2bc3e
commit a223cb726d
6 changed files with 157 additions and 23 deletions
+28 -6
View File
@@ -1,8 +1,8 @@
import { useEffect, useState, useCallback } from 'react';
import { Table, Button, Card, Row, Col, Statistic, Tag, Popconfirm, Space, Typography, Input, theme, Dropdown, Tooltip, Modal, Alert, Empty } from 'antd';
import { Table, Button, Card, Row, Col, Statistic, Tag, Popconfirm, Space, Typography, Input, Select, theme, Dropdown, Tooltip, Modal, Alert, Empty } from 'antd';
import { message } from '../utils/antdMessage';
import { DownloadOutlined, DeleteOutlined, CopyOutlined, SearchOutlined, LoadingOutlined, ReloadOutlined, FilterOutlined, ScanOutlined } from '@ant-design/icons';
import { cookieApi, type BasicSummary, type CookieCheckResult, type CookieDuplicateGroup, type CookieDuplicateResponse, type CookieItem } from '../api/modules';
import { accountApi, cookieApi, type BasicSummary, type CookieCheckResult, type CookieDuplicateGroup, type CookieDuplicateResponse, type CookieItem } from '../api/modules';
import { usePermissions } from '../hooks/usePermissions';
import { formatTime } from '../utils/time';
import { getErrorMessage } from '../utils/error';
@@ -53,6 +53,8 @@ export default function CookiePage() {
const [loading, setLoading] = useState(false);
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const [searchText, setSearchText] = useState('');
const [tagFilter, setTagFilter] = useState('');
const [tags, setTags] = useState<string[]>([]);
const [customNamesText, setCustomNamesText] = useState('');
const [customAccountNames, setCustomAccountNames] = useState<string[]>([]);
const [total, setTotal] = useState(0);
@@ -181,6 +183,7 @@ export default function CookiePage() {
page: currentPage,
page_size: pageSize,
search: searchText.trim() || undefined,
tag: tagFilter || undefined,
account_names: customAccountNames.length > 0 ? customAccountNames.join('\n') : undefined,
include_cookie: false,
});
@@ -208,7 +211,7 @@ export default function CookiePage() {
} finally {
setLoading(false);
}
}, [currentPage, pageSize, searchText, customAccountNames]);
}, [currentPage, pageSize, searchText, tagFilter, customAccountNames]);
const loadSummary = useCallback(async () => {
try {
@@ -227,6 +230,12 @@ export default function CookiePage() {
loadSummary();
}, [loadSummary]);
useEffect(() => {
accountApi.listTags().then(setTags).catch(() => {
// 标签加载失败不影响 Cookie 管理。
});
}, []);
const handleExport = async (format: string = 'csv') => {
try {
const blob = await cookieApi.exportCsv(
@@ -626,9 +635,22 @@ export default function CookiePage() {
</Space>
</Space>
</Card>
<div style={{ marginBottom: 12 }}>
<Space wrap style={{ marginBottom: 12 }}>
<Select
allowClear
showSearch
placeholder="按标签筛选"
style={{ width: 160 }}
value={tagFilter || undefined}
onChange={(value) => {
setTagFilter(value || '');
setCurrentPage(1);
setSelectedRowKeys([]);
}}
options={tags.map((tag) => ({ value: tag, label: tag }))}
/>
<Input.Search
placeholder="搜索账号或分配客服"
placeholder="搜索账号、标签或分配客服"
allowClear
value={searchText}
onChange={(e) => {
@@ -639,7 +661,7 @@ export default function CookiePage() {
size="small"
prefix={<SearchOutlined />}
/>
</div>
</Space>
<Table
rowSelection={{
selectedRowKeys,