import * as React from 'react'; import { ArrowDown, Pause, Play, Trash2 } from '~/components/shared/FeatherIcons'; import { useTranslation } from 'react-i18next'; import ContentHeader from '~/components/ContentHeader'; import LogSearch from '~/components/LogSearch'; import Select from '~/components/shared/Select'; import { useStoreActions } from '~/components/StateProvider'; import SvgYacd from '~/components/SvgYacd'; import useRemainingViewPortHeight from '~/hooks/useRemainingViewPortHeight'; import { useLogsPage } from '~/modules/logs/hooks'; import { LOG_LEVEL_OPTIONS } from '~/modules/config/utils'; import { LOG_TYPES, LOGS_HEIGHT_RATIO } from '~/modules/logs/utils'; import { updateConfigs } from '~/store/configs'; import { clearLogs } from '~/store/logs'; import { DispatchFn, Log } from '~/store/types'; import { ClashAPIConfig } from '~/types'; import s from './Logs.module.scss'; import { Fab, position as fabPosition } from './shared/Fab'; type LogLineProps = Partial; function LogLine({ time, payload, type }: LogLineProps) { return (
{time} {LOG_TYPES[type]}
{payload}
); } type Props = { dispatch: DispatchFn; logLevel: string; apiConfig: ClashAPIConfig; logs: Log[]; logStreamingPaused: boolean; }; export default function Logs({ dispatch, logLevel, apiConfig, logs, logStreamingPaused }: Props) { const actions = useStoreActions(); const { toggleIsRefreshPaused, scrollRef, isAtBottom, scrollToBottom, onScroll } = useLogsPage({ dispatch, logLevel, apiConfig, logs, logStreamingPaused, updateAppConfig: actions.app.updateAppConfig, }); const [refLogsContainer, containerHeight] = useRemainingViewPortHeight(); const { t } = useTranslation(); return (