style(HotEvents): 优化热点事件卡片 UI 和交互体验

- 触控板滑动优化:添加 swipeToSlide 等配置,滑动更流畅
- 布局调整:涨幅标签从标题移到底部,去掉作者显示
- 重要度徽章优化:长方形圆角样式,S/A红色系、B/C橙色系

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-15 15:58:03 +08:00
parent b7315bbdb4
commit 4a5e18a90d
2 changed files with 48 additions and 33 deletions

View File

@@ -121,13 +121,38 @@
display: block; display: block;
} }
/* 重要度徽章 - 长方形圆角 */
.importance-badge { .importance-badge {
position: absolute; position: absolute;
top: 8px; top: 8px;
left: 8px; left: 8px;
padding: 3px 10px;
border-radius: 10px;
font-size: 12px; font-size: 12px;
padding: 2px 6px; font-weight: 600;
border-radius: 4px; color: #fff;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
/* S级 - 深红 */
.importance-s {
background: #c0392b;
}
/* A级 - 浅红 */
.importance-a {
background: #e74c3c;
}
/* B级 - 深橙 */
.importance-b {
background: #d35400;
}
/* C级 - 浅橙 */
.importance-c {
background: #f39c12;
} }
/* Card content */ /* Card content */
@@ -144,26 +169,18 @@
word-break: break-word; word-break: break-word;
} }
/* 标题文字 - inline显示可以换行 */ /* 标题文字 */
.event-title { .event-title {
cursor: pointer; cursor: pointer;
} }
/* 标签紧跟标题后面 */ /* 涨幅标签 - 底部显示 */
.event-tag {
display: inline;
margin-left: 4px;
white-space: nowrap;
vertical-align: baseline;
}
.event-tag .ant-tag { .event-tag .ant-tag {
font-size: 11px; font-size: 12px;
padding: 0 6px; padding: 0 8px;
height: 18px; height: 20px;
line-height: 18px; line-height: 20px;
transform: scale(0.9); margin: 0;
vertical-align: middle;
} }
/* 详情描述 - 三行省略 */ /* 详情描述 - 三行省略 */
@@ -184,18 +201,12 @@
.event-footer { .event-footer {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
font-size: 12px; font-size: 12px;
color: #8c8c8c; color: #8c8c8c;
margin-top: 8px; margin-top: 8px;
} }
.creator {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 60%;
}
/* 时间样式 - 年月日高亮 */ /* 时间样式 - 年月日高亮 */
.time { .time {
white-space: nowrap; white-space: nowrap;

View File

@@ -90,6 +90,13 @@ const HotEvents = ({ events, onPageChange, onEventClick }) => {
prevArrow: <CustomArrow direction="left" />, prevArrow: <CustomArrow direction="left" />,
nextArrow: <CustomArrow direction="right" />, nextArrow: <CustomArrow direction="right" />,
autoplay: false, autoplay: false,
// 触控板/触摸优化
swipeToSlide: true, // 允许滑动到任意位置
touchThreshold: 10, // 滑动灵敏度
swipe: true, // 启用滑动
draggable: true, // PC 端拖拽支持
useCSS: true, // CSS 动画更流畅
cssEase: 'ease-out', // 滑动缓动效果
beforeChange: (_current, next) => { beforeChange: (_current, next) => {
// 计算实际页码(考虑无限循环) // 计算实际页码(考虑无限循环)
const actualPage = next % totalPages; const actualPage = next % totalPages;
@@ -145,11 +152,9 @@ const HotEvents = ({ events, onPageChange, onEventClick }) => {
}} }}
/> />
{event.importance && ( {event.importance && (
<Badge <span className={`importance-badge importance-${event.importance.toLowerCase()}`}>
className="importance-badge" {event.importance}
color={getImportanceColor(event.importance)} </span>
text={`${event.importance}`}
/>
)} )}
</div> </div>
} }
@@ -167,9 +172,6 @@ const HotEvents = ({ events, onPageChange, onEventClick }) => {
</span> </span>
</Tooltip> </Tooltip>
)} )}
<span className="event-tag">
{renderPriceChange(event.related_avg_chg)}
</span>
</div> </div>
{isMobile ? ( {isMobile ? (
@@ -185,7 +187,9 @@ const HotEvents = ({ events, onPageChange, onEventClick }) => {
)} )}
<div className="event-footer"> <div className="event-footer">
<span className="creator">{event.creator?.username || 'Anonymous'}</span> <span className="event-tag">
{renderPriceChange(event.related_avg_chg)}
</span>
<span className="time"> <span className="time">
<span className="time-date">{dayjs(event.created_at).format('YYYY-MM-DD')}</span> <span className="time-date">{dayjs(event.created_at).format('YYYY-MM-DD')}</span>
{' '} {' '}