diff --git a/web/frontend/src/pages/AccountsPage.tsx b/web/frontend/src/pages/AccountsPage.tsx index 2842ac6..9241bb9 100644 --- a/web/frontend/src/pages/AccountsPage.tsx +++ b/web/frontend/src/pages/AccountsPage.tsx @@ -1,12 +1,12 @@ -import { useEffect, useState, useMemo, useCallback } from 'react'; +import { useEffect, useState, useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import { - Alert, Table, Button, Modal, Input, Select, Popconfirm, Typography, Tag, Space, - Row, Col, Card, Statistic, App, Tooltip, + Table, Button, Modal, Input, Select, Popconfirm, Typography, Tag, Space, + Row, Col, Card, Statistic, Tooltip, } from 'antd'; import { message } from '../utils/antdMessage'; import type { TableProps } from 'antd'; -import { ImportOutlined, DeleteOutlined, TagOutlined, FilterOutlined, EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'; +import { ImportOutlined, DeleteOutlined, FilterOutlined } from '@ant-design/icons'; import { accountApi, userApi, type AccountItem, type BasicSummary, type UserInfo } from '../api/modules'; import { usePermissions } from '../hooks/usePermissions'; import { formatTime } from '../utils/time'; @@ -15,9 +15,6 @@ import { getErrorMessage } from '../utils/error'; const { TextArea } = Input; const { Text } = Typography; -const TAG_COLORS = [ - 'blue', 'green', 'cyan', 'geekblue', 'purple', 'orange', 'magenta', 'volcano', -]; /** * 生命周期状态 → 展示色。 @@ -73,8 +70,6 @@ function BindChip({ scope, status }: { scope: string; status?: string }) { export default function AccountsPage() { const navigate = useNavigate(); - // App.useApp() 的 modal 实例继承主题,静态 Modal.confirm 在暗色模式下是白底 - const { modal } = App.useApp(); const [accounts, setAccounts] = useState([]); const [users, setUsers] = useState([]); const [tags, setTags] = useState([]); @@ -88,11 +83,6 @@ export default function AccountsPage() { const [ckFilter, setCkFilter] = useState(''); const [bindFilter, setBindFilter] = useState(''); const [searchText, setSearchText] = useState(''); - const [selectedRowKeys, setSelectedRowKeys] = useState([]); - const [selectedAllMatching, setSelectedAllMatching] = useState(false); - const [batchTagInput, setBatchTagInput] = useState(''); - const [batchTagVisible, setBatchTagVisible] = useState(false); - const [sensitiveVisible, setSensitiveVisible] = useState(false); const [total, setTotal] = useState(0); const [summary, setSummary] = useState({ total: 0, assigned_count: 0, unassigned_count: 0, tag_count: 0 }); const [pageSize, setPageSize] = useState(() => { @@ -102,12 +92,9 @@ export default function AccountsPage() { const [currentPage, setCurrentPage] = useState(1); const { can } = usePermissions(); - const canViewFull = can('account:view_full'); const canImport = can('account:import'); - const canTag = can('account:tag') || canImport; const canAssign = can('account:assign'); const canDelete = can('account:delete'); - const canSelectRows = canTag || canDelete || canAssign; const loadAccounts = useCallback(async () => { setLoading(true); @@ -122,7 +109,6 @@ export default function AccountsPage() { page: currentPage, page_size: pageSize, search: searchText.trim() || undefined, - include_sensitive: canViewFull && sensitiveVisible, }); setAccounts(data.items); setTotal(data.total); @@ -131,7 +117,7 @@ export default function AccountsPage() { } finally { setLoading(false); } - }, [canViewFull, currentPage, pageSize, searchText, sensitiveVisible, tagFilter, statusFilter, ckFilter, bindFilter]); + }, [currentPage, pageSize, searchText, tagFilter, statusFilter, ckFilter, bindFilter]); const loadSummary = useCallback(async () => { try { @@ -170,31 +156,6 @@ export default function AccountsPage() { loadSummary(); }, [canAssign, loadUsers, loadTags, loadSummary]); - const tagColorMap = useMemo(() => { - const map: Record = {}; - tags.forEach((t, i) => { - map[t] = TAG_COLORS[i % TAG_COLORS.length]; - }); - return map; - }, [tags]); - - const selectedCount = selectedAllMatching ? total : selectedRowKeys.length; - const selectionPayload = useMemo(() => ({ - account_ids: selectedAllMatching ? [] : selectedRowKeys.map((key) => Number(key)), - all_matching: selectedAllMatching, - search: searchText.trim(), - tag: tagFilter, - }), [searchText, selectedAllMatching, selectedRowKeys, tagFilter]); - - const clearSelection = () => { - setSelectedRowKeys([]); - setSelectedAllMatching(false); - }; - - useEffect(() => { - clearSelection(); - }, [searchText, tagFilter]); - const handleImport = async () => { if (!importText.trim()) { message.warning('请输入账号数据'); @@ -227,42 +188,10 @@ export default function AccountsPage() { } }; - const handleSetTag = async (accountId: number, tag: string) => { - try { - await accountApi.setTag(accountId, tag); - message.success('标签已更新'); - loadAccounts(); - loadTags(); - } catch (e: unknown) { - message.error(getErrorMessage(e)); - } - }; - - const handleBatchTag = async () => { - if (selectedCount === 0) { - message.warning('请先选择账号'); - return; - } - try { - const result = await accountApi.batchTagSelection({ ...selectionPayload, tag_value: batchTagInput }); - message.success(result.message); - setBatchTagVisible(false); - setBatchTagInput(''); - clearSelection(); - loadAccounts(); - loadTags(); - loadSummary(); - } catch (e: unknown) { - message.error(getErrorMessage(e)); - } - }; - const handleDelete = async (id: number) => { try { await accountApi.delete(id); message.success('已删除'); - setSelectedRowKeys((prev) => prev.filter((k) => k !== id)); - setSelectedAllMatching(false); loadAccounts(); loadTags(); loadSummary(); @@ -271,44 +200,6 @@ export default function AccountsPage() { } }; - const handleBatchDelete = async () => { - if (selectedCount === 0) { - message.warning('请先选择账号'); - return; - } - try { - const result = await accountApi.batchDeleteSelection(selectionPayload); - message.success(result.message); - clearSelection(); - loadAccounts(); - loadTags(); - loadSummary(); - } catch (e: unknown) { - message.error(getErrorMessage(e)); - } - }; - - const handleSensitiveVisibility = () => { - if (sensitiveVisible) { - // 立即清除已加载的敏感内容,再由 effect 重新获取脱敏列表。 - setAccounts((previous) => previous.map((account) => ({ - ...account, - password: undefined, - email: undefined, - email_password: undefined, - }))); - setSensitiveVisible(false); - return; - } - modal.confirm({ - title: '显示账号凭据?', - content: '密码、邮箱和邮箱密码将临时显示在当前页面。关闭或刷新页面后会恢复脱敏。', - okText: '显示', - cancelText: '取消', - onOk: () => setSensitiveVisible(true), - }); - }; - const columns: TableProps['columns'] = [ { // ID 不再单独占一列(客服不看),降到用户名下面做小字 —— 报障时还能念出来。 @@ -395,53 +286,8 @@ export default function AccountsPage() { ), }, - { - title: '标签', - dataIndex: 'tag', - width: 170, - render: (tag: string, record: AccountItem) => { - if (canTag) { - return ( - setBatchTagInput(vals.length > 0 ? vals[vals.length - 1] : '')} - options={tags.map((t) => ({ value: t, label: t }))} - /> - ); }