diff --git a/web/frontend/src/pages/AccountsPage.tsx b/web/frontend/src/pages/AccountsPage.tsx index 0a492e8..d710720 100644 --- a/web/frontend/src/pages/AccountsPage.tsx +++ b/web/frontend/src/pages/AccountsPage.tsx @@ -12,6 +12,10 @@ import { usePermissions } from '../hooks/usePermissions'; import { formatTime } from '../utils/time'; import { getErrorMessage } from '../utils/error'; +const TAG_COLORS = [ + 'blue', 'green', 'cyan', 'geekblue', 'purple', 'orange', 'magenta', 'volcano', +]; + const { TextArea } = Input; const { Text } = Typography; @@ -194,6 +198,14 @@ export default function AccountsPage() { } }; + const tagColorMap = useMemo(() => { + const map: Record = {}; + tags.forEach((tg, i) => { + map[tg] = TAG_COLORS[i % TAG_COLORS.length]; + }); + return map; + }, [tags]); + const handleBatchTag = async () => { if (selectedCount === 0) { message.warning('请先选择账号'); @@ -213,6 +225,17 @@ 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 handleDelete = async (id: number) => { try { await accountApi.delete(id); @@ -351,6 +374,35 @@ export default function AccountsPage() { ), }, + { + title: '标签', + dataIndex: 'tag', + width: 170, + render: (tag: string, record: AccountItem) => { + // 有权限时直接就地改(Select 输入新标签即保存);无权限则只读展示。 + if (canTag) { + return ( +