From cb9970c29eae947d85e2ba196f92db360fd5add9 Mon Sep 17 00:00:00 2001 From: Zephyruso <127948745+Zephyruso@users.noreply.github.com> Date: Thu, 31 Aug 2023 22:49:34 +0800 Subject: [PATCH] feat: columns hide --- src/components/ConnectionsModal.tsx | 46 +++++++++++++++++++ src/components/ProxyNodeCard.tsx | 6 +-- src/config/connection.ts | 15 +++++++ src/pages/Connections.tsx | 70 ++++++++++++++++++++--------- src/pages/Proxies.tsx | 48 +++++++++++--------- 5 files changed, 140 insertions(+), 45 deletions(-) create mode 100644 src/components/ConnectionsModal.tsx create mode 100644 src/config/connection.ts diff --git a/src/components/ConnectionsModal.tsx b/src/components/ConnectionsModal.tsx new file mode 100644 index 0000000..7bdd4ae --- /dev/null +++ b/src/components/ConnectionsModal.tsx @@ -0,0 +1,46 @@ +import { For } from 'solid-js' +import { AccessorKey } from '~/config/connection' + +type ColumnVisibility = Partial> + +export default (props: { + data: ColumnVisibility + onChange: (value: ColumnVisibility) => void +}) => { + const { onChange } = props + + return ( + <> + + + + ) +} diff --git a/src/components/ProxyNodeCard.tsx b/src/components/ProxyNodeCard.tsx index 25bd983..331d395 100644 --- a/src/components/ProxyNodeCard.tsx +++ b/src/components/ProxyNodeCard.tsx @@ -32,8 +32,8 @@ export default (props: { const formatProxyType = (type: string) => { const t = type.toLowerCase() - if (t === 'shadowsocks') { - return 'ss' + if (t.includes('shadowsocks')) { + return t.replace('shadowsocks', 'ss') } return t @@ -42,7 +42,7 @@ export default (props: { return (
> + +const initColumnVisibility = { + ...Object.fromEntries(Object.values(AccessorKey).map((i) => [i, true])), + [AccessorKey.ID]: false, +} + export default () => { + const [columnVisibility, setColumnVisibility] = makePersisted( + createSignal(initColumnVisibility), + { + name: 'columnVisibility', + storage: localStorage, + }, + ) + const request = useRequest() const [search, setSearch] = createSignal('') @@ -80,7 +99,7 @@ export default () => { const columns: ColumnDef[] = [ { - id: 'close', + accessorKey: AccessorKey.Close, header: () => (