diff --git a/src/app/page.tsx b/src/app/page.tsx index c3ce6df..2f16162 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -14,7 +14,14 @@ import { Checkbox, AutoComplete, } from "antd"; -import { SearchOutlined, SettingOutlined, HolderOutlined, ClockCircleOutlined, DownloadOutlined } from "@ant-design/icons"; +import { + SearchOutlined, + SettingOutlined, + HolderOutlined, + ClockCircleOutlined, + DownloadOutlined, + FilterOutlined, +} from "@ant-design/icons"; import type { ColumnsType } from "antd/es/table"; import { DndContext, @@ -38,6 +45,7 @@ const { Title, Text } = Typography; interface ColumnConfig { key: string; visible: boolean; + filterable: boolean; } const COLUMN_DEFS: { key: string; width: number }[] = [ @@ -102,6 +110,7 @@ const COLUMN_DEFS: { key: string; width: number }[] = [ const DEFAULT_CONFIG: ColumnConfig[] = COLUMN_DEFS.map((d) => ({ key: d.key, visible: true, + filterable: false, })); const STORAGE_KEY = "web-table-column-config"; @@ -110,9 +119,15 @@ function loadConfig(): ColumnConfig[] { try { const saved = localStorage.getItem(STORAGE_KEY); if (saved) { - const parsed: ColumnConfig[] = JSON.parse(saved); + const parsed = JSON.parse(saved) as Partial[]; const savedKeys = new Set(parsed.map((c) => c.key)); - if (COLUMN_DEFS.every((d) => savedKeys.has(d.key))) return parsed; + if (COLUMN_DEFS.every((d) => savedKeys.has(d.key))) { + return parsed.map((c) => ({ + key: c.key!, + visible: !!c.visible, + filterable: !!c.filterable, // 旧配置缺该字段时按 false + })); + } } } catch { /* ignore */ @@ -151,12 +166,16 @@ function SortableRow({ id, label, visible, + filterable, onToggle, + onToggleFilter, }: { id: string; label: string; visible: boolean; + filterable: boolean; onToggle: () => void; + onToggleFilter: () => void; }) { const { attributes, @@ -188,6 +207,14 @@ function SortableRow({ +