diff --git a/src/components/ConnectionsModal.tsx b/src/components/ConnectionsModal.tsx index 10f3116..5d3bb89 100644 --- a/src/components/ConnectionsModal.tsx +++ b/src/components/ConnectionsModal.tsx @@ -14,7 +14,11 @@ import { useDragDropContext, } from '@thisbeyond/solid-dnd' import { For, Show, createSignal } from 'solid-js' -import { AccessorKey } from '~/config/enum' +import { + AccessorKey, + initColumnOrder, + initColumnVisibility, +} from '~/config/enum' type ColumnVisibility = Partial> type ColumnOrder = AccessorKey[] @@ -107,7 +111,10 @@ export default (props: { diff --git a/src/config/enum.ts b/src/config/enum.ts index 5c9a59c..22033b3 100644 --- a/src/config/enum.ts +++ b/src/config/enum.ts @@ -40,3 +40,9 @@ export enum LANG { EN = 'en-US', ZH = 'zh-CN', } + +export const initColumnOrder = Object.values(AccessorKey) +export const initColumnVisibility = { + ...Object.fromEntries(initColumnOrder.map((i) => [i, true])), + [AccessorKey.ID]: false, +} diff --git a/src/pages/Connections.tsx b/src/pages/Connections.tsx index 4d67758..97c1cfc 100644 --- a/src/pages/Connections.tsx +++ b/src/pages/Connections.tsx @@ -21,7 +21,11 @@ import { isIPv6 } from 'is-ip' import { For, createEffect, createSignal } from 'solid-js' import { twMerge } from 'tailwind-merge' import ConnectionsModal from '~/components/ConnectionsModal' -import { AccessorKey } from '~/config/enum' +import { + AccessorKey, + initColumnOrder, + initColumnVisibility, +} from '~/config/enum' import { secret, useRequest, wsEndpointURL } from '~/signals' import type { Connection } from '~/types' @@ -33,12 +37,6 @@ type ConnectionWithSpeed = Connection & { type ColumnVisibility = Partial> type ColumnOrder = AccessorKey[] -const initColumnOrder = Object.values(AccessorKey) -const initColumnVisibility = { - ...Object.fromEntries(initColumnOrder.map((i) => [i, true])), - [AccessorKey.ID]: false, -} - export default () => { const [t] = useI18n() const [columnVisibility, setColumnVisibility] = makePersisted(