更新Company页面的UI为FUI风格

This commit is contained in:
2025-12-22 09:52:02 +08:00
parent 46c7649bf0
commit 2d48e08e43

View File

@@ -1,5 +1,5 @@
// src/views/Community/components/DynamicNews/layouts/MainlineTimelineView.js // src/views/Community/components/DynamicNews/layouts/MainlineTimelineView.js
// 主线时间轴布局组件 - 按 lv2 概念分组展示事件(横向卡片布局) // 主线时间轴布局组件 - 按 lv2 概念分组展示事件(横向滚动布局)
import React, { import React, {
useState, useState,
@@ -22,7 +22,6 @@ import {
IconButton, IconButton,
useColorModeValue, useColorModeValue,
Tooltip, Tooltip,
SimpleGrid,
} from "@chakra-ui/react"; } from "@chakra-ui/react";
import { import {
ChevronDownIcon, ChevronDownIcon,
@@ -38,7 +37,7 @@ import { getApiBase } from "@utils/apiConfig";
* *
* 功能: * 功能:
* 1. 调用 /api/events/mainline 获取预分组数据 * 1. 调用 /api/events/mainline 获取预分组数据
* 2. 按 lv2 概念分组展示,横向卡片布局 * 2. 按 lv2 概念分组展示,横向滚动布局
* 3. 按事件数量从多到少排序 * 3. 按事件数量从多到少排序
* 4. 深色背景风格,与列表模式统一 * 4. 深色背景风格,与列表模式统一
*/ */
@@ -61,20 +60,19 @@ const MainlineTimelineViewComponent = forwardRef(
const [mainlineData, setMainlineData] = useState(null); const [mainlineData, setMainlineData] = useState(null);
const [expandedGroups, setExpandedGroups] = useState({}); const [expandedGroups, setExpandedGroups] = useState({});
// 深色主题颜色 - 与列表模式统一 // 深色主题颜色
const containerBg = useColorModeValue("gray.100", "gray.900"); const containerBg = useColorModeValue("gray.50", "#1a1d24");
const cardBg = useColorModeValue("white", "gray.800"); const cardBg = useColorModeValue("white", "#252a34");
const cardBorderColor = useColorModeValue("gray.200", "gray.700"); const cardBorderColor = useColorModeValue("gray.200", "#3a3f4b");
const headerBg = useColorModeValue("gray.50", "gray.750"); const headerHoverBg = useColorModeValue("gray.100", "#2d323e");
const headerHoverBg = useColorModeValue("gray.100", "gray.700"); const textColor = useColorModeValue("gray.800", "#e2e8f0");
const textColor = useColorModeValue("gray.800", "gray.100"); const secondaryTextColor = useColorModeValue("gray.600", "#a0aec0");
const secondaryTextColor = useColorModeValue("gray.600", "gray.400"); const timelineLineColor = useColorModeValue("blue.300", "#4299e1");
const timelineLineColor = useColorModeValue("blue.300", "blue.500"); const timelineDotBg = useColorModeValue("blue.500", "#63b3ed");
const timelineDotBg = useColorModeValue("blue.500", "blue.400"); const scrollbarTrackBg = useColorModeValue("#e2e8f0", "#1a1d24");
const scrollbarTrackBg = useColorModeValue("#e2e8f0", "#1a202c");
const scrollbarThumbBg = useColorModeValue("#a0aec0", "#4a5568"); const scrollbarThumbBg = useColorModeValue("#a0aec0", "#4a5568");
const scrollbarThumbHoverBg = useColorModeValue("#718096", "#718096"); const scrollbarThumbHoverBg = useColorModeValue("#718096", "#718096");
const statBarBg = useColorModeValue("gray.200", "gray.800"); const statBarBg = useColorModeValue("gray.100", "#252a34");
// 根据主线类型获取配色 // 根据主线类型获取配色
const getColorScheme = useCallback((lv2Name) => { const getColorScheme = useCallback((lv2Name) => {
@@ -191,7 +189,7 @@ const MainlineTimelineViewComponent = forwardRef(
mainlines: sortedMainlines, mainlines: sortedMainlines,
}); });
// 初始化展开状态(默认全部折叠,方便一目了然对比 // 初始化展开状态(默认全部折叠)
const initialExpanded = {}; const initialExpanded = {};
sortedMainlines.forEach((mainline) => { sortedMainlines.forEach((mainline) => {
initialExpanded[mainline.lv2_id] = false; initialExpanded[mainline.lv2_id] = false;
@@ -304,24 +302,10 @@ const MainlineTimelineViewComponent = forwardRef(
return ( return (
<Box <Box
display={display} display={display}
overflowY="auto"
h="100%" h="100%"
w="100%" w="100%"
bg={containerBg} bg={containerBg}
css={{ overflow="hidden"
"&::-webkit-scrollbar": { width: "8px" },
"&::-webkit-scrollbar-track": {
background: scrollbarTrackBg,
},
"&::-webkit-scrollbar-thumb": {
background: scrollbarThumbBg,
borderRadius: "4px",
},
"&::-webkit-scrollbar-thumb:hover": {
background: scrollbarThumbHoverBg,
},
scrollBehavior: "smooth",
}}
> >
{/* 顶部统计栏 */} {/* 顶部统计栏 */}
<Flex <Flex
@@ -332,9 +316,6 @@ const MainlineTimelineViewComponent = forwardRef(
bg={statBarBg} bg={statBarBg}
borderBottomWidth="1px" borderBottomWidth="1px"
borderBottomColor={cardBorderColor} borderBottomColor={cardBorderColor}
position="sticky"
top={0}
zIndex={10}
> >
<HStack spacing={4}> <HStack spacing={4}>
<HStack spacing={2}> <HStack spacing={2}>
@@ -387,9 +368,32 @@ const MainlineTimelineViewComponent = forwardRef(
</HStack> </HStack>
</Flex> </Flex>
{/* 主线卡片网格 - 横向布局 */} {/* 主线卡片横向滚动容器 */}
<Box p={3}> <Box
<SimpleGrid columns={{ base: 1, md: 2, lg: 3, xl: 4 }} spacing={3}> overflowX="auto"
overflowY="hidden"
h="calc(100% - 44px)"
css={{
"&::-webkit-scrollbar": { height: "8px" },
"&::-webkit-scrollbar-track": {
background: scrollbarTrackBg,
},
"&::-webkit-scrollbar-thumb": {
background: scrollbarThumbBg,
borderRadius: "4px",
},
"&::-webkit-scrollbar-thumb:hover": {
background: scrollbarThumbHoverBg,
},
}}
>
<HStack
spacing={3}
p={3}
align="stretch"
h="100%"
minW="max-content"
>
{mainlines.map((mainline) => { {mainlines.map((mainline) => {
const colorScheme = getColorScheme(mainline.lv2_name); const colorScheme = getColorScheme(mainline.lv2_name);
const isExpanded = expandedGroups[mainline.lv2_id]; const isExpanded = expandedGroups[mainline.lv2_id];
@@ -401,13 +405,17 @@ const MainlineTimelineViewComponent = forwardRef(
borderRadius="lg" borderRadius="lg"
borderWidth="1px" borderWidth="1px"
borderColor={cardBorderColor} borderColor={cardBorderColor}
borderLeftWidth="4px" borderTopWidth="3px"
borderLeftColor={`${colorScheme}.500`} borderTopColor={`${colorScheme}.500`}
overflow="hidden" minW={isExpanded ? "320px" : "200px"}
transition="all 0.2s" maxW={isExpanded ? "380px" : "240px"}
h="100%"
display="flex"
flexDirection="column"
transition="all 0.3s ease"
flexShrink={0}
_hover={{ _hover={{
borderColor: `${colorScheme}.400`, borderColor: `${colorScheme}.400`,
transform: "translateY(-1px)",
boxShadow: "lg" boxShadow: "lg"
}} }}
> >
@@ -421,6 +429,9 @@ const MainlineTimelineViewComponent = forwardRef(
onClick={() => toggleGroup(mainline.lv2_id)} onClick={() => toggleGroup(mainline.lv2_id)}
_hover={{ bg: headerHoverBg }} _hover={{ bg: headerHoverBg }}
transition="all 0.15s" transition="all 0.15s"
borderBottomWidth="1px"
borderBottomColor={cardBorderColor}
flexShrink={0}
> >
<VStack align="start" spacing={0} flex={1} minW={0}> <VStack align="start" spacing={0} flex={1} minW={0}>
<HStack spacing={2} w="100%"> <HStack spacing={2} w="100%">
@@ -458,14 +469,12 @@ const MainlineTimelineViewComponent = forwardRef(
/> />
</Flex> </Flex>
{/* 展开的事件列表 */} {/* 事件列表 - 可滚动到底 */}
<Collapse in={isExpanded} animateOpacity> <Collapse in={isExpanded} animateOpacity style={{ flex: 1, overflow: 'hidden' }}>
<Box <Box
px={3} px={3}
py={2} py={2}
borderTopWidth="1px" h="100%"
borderTopColor={cardBorderColor}
maxH="400px"
overflowY="auto" overflowY="auto"
position="relative" position="relative"
css={{ css={{
@@ -499,8 +508,7 @@ const MainlineTimelineViewComponent = forwardRef(
<Box <Box
position="absolute" position="absolute"
left="-19px" left="-19px"
top="50%" top="12px"
transform="translateY(-50%)"
w="8px" w="8px"
h="8px" h="8px"
borderRadius="full" borderRadius="full"
@@ -539,10 +547,39 @@ const MainlineTimelineViewComponent = forwardRef(
</VStack> </VStack>
</Box> </Box>
</Collapse> </Collapse>
{/* 折叠时显示简要信息 */}
{!isExpanded && (
<Box px={3} py={2} flex={1} overflow="hidden">
<VStack spacing={1} align="stretch">
{mainline.events.slice(0, 3).map((event) => (
<Text
key={event.id}
fontSize="xs"
color={secondaryTextColor}
noOfLines={1}
cursor="pointer"
_hover={{ color: textColor }}
onClick={(e) => {
e.stopPropagation();
onEventSelect?.(event);
}}
>
{event.title}
</Text>
))}
{mainline.events.length > 3 && (
<Text fontSize="xs" color={secondaryTextColor}>
... 还有 {mainline.events.length - 3}
</Text>
)}
</VStack>
</Box>
)}
</Box> </Box>
); );
})} })}
</SimpleGrid> </HStack>
</Box> </Box>
</Box> </Box>
); );