Files
vf_react/src/views/Community/components/EventCard/atoms/EventDescription.js
zdl 44fcef5eae refactor: Community 目录结构重组 + 修复导入路径 + 添加 Mock 数据
## 目录重构
- DynamicNewsCard/ → DynamicNews/(含 layouts/, hooks/ 子目录)
- EventCard 原子组件 → EventCard/atoms/
- EventDetailModal 独立目录化
- HotEvents 独立目录化(含 CSS)
- SearchFilters 独立目录化(CompactSearchBox, TradingTimeFilter)

## 导入路径修复
- EventCard/*.js: 统一使用 @constants/, @utils/, @components/ 别名
- atoms/*.js: 修复移动后的相对路径问题
- DynamicNewsCard.js: 更新 contexts, store, constants 导入
- EventHeaderInfo.js, CompactMetaBar.js: 修复 EventFollowButton 导入

## Mock Handler 添加
- /api/events/:eventId/expectation-score - 事件超预期得分
- /api/index/:indexCode/realtime - 指数实时行情

## 警告修复
- CitationMark.js: overlayInnerStyle → styles (Antd 5.x)
- CitedContent.js: 移除不支持的 jsx 属性

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-09 13:16:43 +08:00

57 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// src/views/Community/components/EventCard/EventDescription.js
import React, { useState } from 'react';
import { Box, Text, Button } from '@chakra-ui/react';
/**
* 事件描述组件(支持展开/收起)
* @param {Object} props
* @param {string} props.description - 描述文本
* @param {string} props.textColor - 文字颜色
* @param {number} props.minLength - 触发展开/收起的最小长度(默认 120
* @param {number} props.noOfLines - 未展开时显示的行数(默认 3
*/
const EventDescription = ({
description,
textColor,
minLength = 120,
noOfLines = 3
}) => {
const [isExpanded, setIsExpanded] = useState(false);
// 如果没有描述,不渲染
if (!description) {
return null;
}
const handleToggle = (e) => {
e.stopPropagation();
setIsExpanded(!isExpanded);
};
return (
<Box>
<Text
color={textColor}
fontSize="sm"
lineHeight="tall"
noOfLines={isExpanded ? undefined : noOfLines}
>
{description}
</Text>
{description.length > minLength && (
<Button
variant="link"
size="xs"
colorScheme="blue"
onClick={handleToggle}
mt={1}
>
{isExpanded ? '收起' : '...展开'}
</Button>
)}
</Box>
);
};
export default EventDescription;