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>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
// src/views/Community/components/EventCard/atoms/KeywordsCarousel.js
|
||||
// Keywords标签组件(点击切换)
|
||||
import React, { useState } from 'react';
|
||||
import { Box, Text, Tooltip } from '@chakra-ui/react';
|
||||
import { PROFESSIONAL_COLORS } from '@constants/professionalTheme';
|
||||
|
||||
/**
|
||||
* Keywords标签组件(点击切换下一个)
|
||||
* @param {Array} keywords - 关键词数组
|
||||
* @param {Function} onKeywordClick - 关键词点击回调
|
||||
*/
|
||||
const KeywordsCarousel = ({
|
||||
keywords = [],
|
||||
onKeywordClick
|
||||
}) => {
|
||||
const [currentIndex, setCurrentIndex] = useState(0);
|
||||
|
||||
// 如果没有keywords,不渲染
|
||||
if (!keywords || keywords.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentKeyword = keywords[currentIndex];
|
||||
|
||||
// 点击切换到下一个关键词
|
||||
const handleClick = (e) => {
|
||||
e.stopPropagation();
|
||||
|
||||
// 切换到下一个
|
||||
const nextIndex = (currentIndex + 1) % keywords.length;
|
||||
setCurrentIndex(nextIndex);
|
||||
|
||||
// 触发回调
|
||||
if (onKeywordClick) {
|
||||
onKeywordClick(keywords[nextIndex]);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
label={keywords.length > 1
|
||||
? `点击切换下一个标签 (${currentIndex + 1}/${keywords.length})`
|
||||
: '事件标签'}
|
||||
placement="top"
|
||||
hasArrow
|
||||
bg="rgba(20, 20, 20, 0.95)"
|
||||
color={PROFESSIONAL_COLORS.gold[500]}
|
||||
fontSize="sm"
|
||||
>
|
||||
<Box
|
||||
position="absolute"
|
||||
right={4}
|
||||
top="50%"
|
||||
transform="translateY(-50%)"
|
||||
pointerEvents="auto"
|
||||
zIndex={1}
|
||||
cursor={keywords.length > 1 ? "pointer" : "default"}
|
||||
onClick={keywords.length > 1 ? handleClick : undefined}
|
||||
px={3}
|
||||
py={1.5}
|
||||
borderRadius="full"
|
||||
bg="transparent"
|
||||
transition="all 0.3s ease"
|
||||
_hover={keywords.length > 1 ? {
|
||||
bg: 'rgba(255, 195, 0, 0.15)',
|
||||
transform: 'translateY(-50%) scale(1.05)',
|
||||
} : {}}
|
||||
>
|
||||
<Text
|
||||
color={PROFESSIONAL_COLORS.gold[500]}
|
||||
fontSize="md"
|
||||
fontWeight="bold"
|
||||
letterSpacing="wide"
|
||||
whiteSpace="nowrap"
|
||||
textShadow="0 0 20px rgba(255, 195, 0, 0.3)"
|
||||
>
|
||||
{typeof currentKeyword === 'string'
|
||||
? currentKeyword
|
||||
: currentKeyword?.concept || '未知标签'}
|
||||
</Text>
|
||||
</Box>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
export default KeywordsCarousel;
|
||||
Reference in New Issue
Block a user