feat: 提取VerticalModeLayout - 提升可读性,但耦合度中等
This commit is contained in:
@@ -5,19 +5,13 @@ import React, { useRef } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Flex,
|
||||
Grid,
|
||||
GridItem,
|
||||
Center,
|
||||
VStack,
|
||||
Text,
|
||||
useColorModeValue
|
||||
} from '@chakra-ui/react';
|
||||
import HorizontalDynamicNewsEventCard from '../EventCard/HorizontalDynamicNewsEventCard';
|
||||
import DynamicNewsDetailPanel from '../DynamicNewsDetail';
|
||||
import PaginationControl from './PaginationControl';
|
||||
import VirtualizedFourRowGrid from './VirtualizedFourRowGrid';
|
||||
import PageNavigationButton from './PageNavigationButton';
|
||||
import ModeToggleButtons from './ModeToggleButtons';
|
||||
import VerticalModeLayout from './VerticalModeLayout';
|
||||
|
||||
/**
|
||||
* 事件列表组件 - 支持纵向和平铺两种展示模式
|
||||
@@ -166,68 +160,25 @@ const EventScrollList = ({
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 模式4: 纵向分栏模式 - 横向布局(时间在左,卡片在右) */}
|
||||
{/* 纵向分栏模式 */}
|
||||
{mode === 'vertical' && (
|
||||
<Grid templateColumns="1fr 2fr" gap={6} h="800px">
|
||||
{/* 左侧:事件列表 (33.3%) - 使用虚拟滚动 + 双向无限滚动 */}
|
||||
<GridItem>
|
||||
<VirtualizedFourRowGrid
|
||||
events={displayEvents || events} // 使用累积列表
|
||||
columnsPerRow={1} // 单列布局
|
||||
CardComponent={HorizontalDynamicNewsEventCard} // 使用横向卡片
|
||||
<VerticalModeLayout
|
||||
displayEvents={displayEvents}
|
||||
events={events}
|
||||
selectedEvent={selectedEvent}
|
||||
onEventSelect={onEventSelect}
|
||||
eventFollowStatus={eventFollowStatus}
|
||||
onToggleFollow={onToggleFollow}
|
||||
getTimelineBoxStyle={getTimelineBoxStyle}
|
||||
borderColor={borderColor}
|
||||
loadNextPage={loadNextPage} // 支持向下无限滚动
|
||||
loadPrevPage={loadPrevPage} // 支持向上无限滚动(双向滚动)
|
||||
loadNextPage={loadNextPage}
|
||||
loadPrevPage={loadPrevPage}
|
||||
hasMore={hasMore}
|
||||
loading={loading}
|
||||
scrollbarTrackBg={scrollbarTrackBg}
|
||||
scrollbarThumbBg={scrollbarThumbBg}
|
||||
scrollbarThumbHoverBg={scrollbarThumbHoverBg}
|
||||
/>
|
||||
</GridItem>
|
||||
|
||||
{/* 右侧:事件详情 (66.7%) */}
|
||||
<GridItem h="100%">
|
||||
<Box
|
||||
pl={2}
|
||||
position="relative"
|
||||
sx={{
|
||||
height: '100% !important',
|
||||
maxHeight: '800px !important',
|
||||
overflowY: 'scroll !important',
|
||||
overflowX: 'hidden !important',
|
||||
'&::-webkit-scrollbar': {
|
||||
width: '3px',
|
||||
},
|
||||
'&::-webkit-scrollbar-track': {
|
||||
background: scrollbarTrackBg,
|
||||
borderRadius: '10px',
|
||||
},
|
||||
'&::-webkit-scrollbar-thumb': {
|
||||
background: scrollbarThumbBg,
|
||||
borderRadius: '10px',
|
||||
},
|
||||
'&::-webkit-scrollbar-thumb:hover': {
|
||||
background: scrollbarThumbHoverBg,
|
||||
},
|
||||
}}
|
||||
>
|
||||
{selectedEvent ? (
|
||||
<DynamicNewsDetailPanel event={selectedEvent} />
|
||||
) : (
|
||||
<Center h="100%" minH="400px">
|
||||
<VStack spacing={4}>
|
||||
<Text fontSize="lg" color="gray.500">
|
||||
请选择左侧事件查看详情
|
||||
</Text>
|
||||
</VStack>
|
||||
</Center>
|
||||
)}
|
||||
</Box>
|
||||
</GridItem>
|
||||
</Grid>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user