feat: add fixed server list

This commit is contained in:
moonrailgun 2024-09-25 00:15:03 +08:00
parent cdc3ce1223
commit 4f2c1129a0

View File

@ -4,7 +4,7 @@ import { useTranslation } from '@i18next-toolkit/react';
import { useIntervalUpdate } from '@/hooks/useIntervalUpdate'; import { useIntervalUpdate } from '@/hooks/useIntervalUpdate';
import { useServerMap } from './useServerMap'; import { useServerMap } from './useServerMap';
import { isServerOnline } from '@tianji/shared'; import { isServerOnline } from '@tianji/shared';
import { max } from 'lodash-es'; import { max, orderBy } from 'lodash-es';
import { ServerStatusInfo } from '../../../types'; import { ServerStatusInfo } from '../../../types';
import { Badge } from 'antd'; import { Badge } from 'antd';
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'; import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip';
@ -30,15 +30,13 @@ export const ServerList: React.FC<ServerListProps> = React.memo((props) => {
const dataSource = useMemo( const dataSource = useMemo(
() => () =>
Object.values(serverMap) orderBy(Object.values(serverMap), 'name', 'asc').filter((info) => {
.sort((info) => (isServerOnline(info) ? -1 : 1)) if (hideOfflineServer) {
.filter((info) => { return isServerOnline(info);
if (hideOfflineServer) { }
return isServerOnline(info);
}
return true; return true;
}), // make online server is up and offline is down }), // make online server is up and offline is down
[serverMap, inc, hideOfflineServer] [serverMap, inc, hideOfflineServer]
); );
const lastUpdatedAt = max(dataSource.map((d) => d.updatedAt)); const lastUpdatedAt = max(dataSource.map((d) => d.updatedAt));