From 4f2c1129a0421934b43d3b6e02b17d629d275614 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Wed, 25 Sep 2024 00:15:03 +0800 Subject: [PATCH] feat: add fixed server list --- src/client/components/server/ServerList.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/client/components/server/ServerList.tsx b/src/client/components/server/ServerList.tsx index 418dbda..3555a4d 100644 --- a/src/client/components/server/ServerList.tsx +++ b/src/client/components/server/ServerList.tsx @@ -4,7 +4,7 @@ import { useTranslation } from '@i18next-toolkit/react'; import { useIntervalUpdate } from '@/hooks/useIntervalUpdate'; import { useServerMap } from './useServerMap'; import { isServerOnline } from '@tianji/shared'; -import { max } from 'lodash-es'; +import { max, orderBy } from 'lodash-es'; import { ServerStatusInfo } from '../../../types'; import { Badge } from 'antd'; import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'; @@ -30,15 +30,13 @@ export const ServerList: React.FC = React.memo((props) => { const dataSource = useMemo( () => - Object.values(serverMap) - .sort((info) => (isServerOnline(info) ? -1 : 1)) - .filter((info) => { - if (hideOfflineServer) { - return isServerOnline(info); - } + orderBy(Object.values(serverMap), 'name', 'asc').filter((info) => { + if (hideOfflineServer) { + return isServerOnline(info); + } - return true; - }), // make online server is up and offline is down + return true; + }), // make online server is up and offline is down [serverMap, inc, hideOfflineServer] ); const lastUpdatedAt = max(dataSource.map((d) => d.updatedAt));