feat: 提取VerticalModeLayout - 提升可读性,但耦合度中等
This commit is contained in:
@@ -5,19 +5,13 @@ import React, { useRef } from 'react';
|
|||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Flex,
|
Flex,
|
||||||
Grid,
|
|
||||||
GridItem,
|
|
||||||
Center,
|
|
||||||
VStack,
|
|
||||||
Text,
|
|
||||||
useColorModeValue
|
useColorModeValue
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import HorizontalDynamicNewsEventCard from '../EventCard/HorizontalDynamicNewsEventCard';
|
|
||||||
import DynamicNewsDetailPanel from '../DynamicNewsDetail';
|
|
||||||
import PaginationControl from './PaginationControl';
|
import PaginationControl from './PaginationControl';
|
||||||
import VirtualizedFourRowGrid from './VirtualizedFourRowGrid';
|
import VirtualizedFourRowGrid from './VirtualizedFourRowGrid';
|
||||||
import PageNavigationButton from './PageNavigationButton';
|
import PageNavigationButton from './PageNavigationButton';
|
||||||
import ModeToggleButtons from './ModeToggleButtons';
|
import ModeToggleButtons from './ModeToggleButtons';
|
||||||
|
import VerticalModeLayout from './VerticalModeLayout';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 事件列表组件 - 支持纵向和平铺两种展示模式
|
* 事件列表组件 - 支持纵向和平铺两种展示模式
|
||||||
@@ -166,68 +160,25 @@ const EventScrollList = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 模式4: 纵向分栏模式 - 横向布局(时间在左,卡片在右) */}
|
{/* 纵向分栏模式 */}
|
||||||
{mode === 'vertical' && (
|
{mode === 'vertical' && (
|
||||||
<Grid templateColumns="1fr 2fr" gap={6} h="800px">
|
<VerticalModeLayout
|
||||||
{/* 左侧:事件列表 (33.3%) - 使用虚拟滚动 + 双向无限滚动 */}
|
displayEvents={displayEvents}
|
||||||
<GridItem>
|
events={events}
|
||||||
<VirtualizedFourRowGrid
|
selectedEvent={selectedEvent}
|
||||||
events={displayEvents || events} // 使用累积列表
|
onEventSelect={onEventSelect}
|
||||||
columnsPerRow={1} // 单列布局
|
eventFollowStatus={eventFollowStatus}
|
||||||
CardComponent={HorizontalDynamicNewsEventCard} // 使用横向卡片
|
onToggleFollow={onToggleFollow}
|
||||||
selectedEvent={selectedEvent}
|
getTimelineBoxStyle={getTimelineBoxStyle}
|
||||||
onEventSelect={onEventSelect}
|
borderColor={borderColor}
|
||||||
eventFollowStatus={eventFollowStatus}
|
loadNextPage={loadNextPage}
|
||||||
onToggleFollow={onToggleFollow}
|
loadPrevPage={loadPrevPage}
|
||||||
getTimelineBoxStyle={getTimelineBoxStyle}
|
hasMore={hasMore}
|
||||||
borderColor={borderColor}
|
loading={loading}
|
||||||
loadNextPage={loadNextPage} // 支持向下无限滚动
|
scrollbarTrackBg={scrollbarTrackBg}
|
||||||
loadPrevPage={loadPrevPage} // 支持向上无限滚动(双向滚动)
|
scrollbarThumbBg={scrollbarThumbBg}
|
||||||
hasMore={hasMore}
|
scrollbarThumbHoverBg={scrollbarThumbHoverBg}
|
||||||
loading={loading}
|
/>
|
||||||
/>
|
|
||||||
</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>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user