修复heropanel无法下拉背景页面
This commit is contained in:
@@ -43,6 +43,8 @@ import { PROFESSIONAL_COLORS } from '@constants/professionalTheme';
|
|||||||
import { debounce } from '@utils/debounce';
|
import { debounce } from '@utils/debounce';
|
||||||
import { useDevice } from '@hooks/useDevice';
|
import { useDevice } from '@hooks/useDevice';
|
||||||
import { eventService } from '@services/eventService';
|
import { eventService } from '@services/eventService';
|
||||||
|
import { getApiBase } from '@utils/apiConfig';
|
||||||
|
import { useAuth } from '@contexts/AuthContext';
|
||||||
|
|
||||||
// 🔍 调试:渲染计数器
|
// 🔍 调试:渲染计数器
|
||||||
let dynamicNewsCardRenderCount = 0;
|
let dynamicNewsCardRenderCount = 0;
|
||||||
@@ -74,6 +76,7 @@ const DynamicNewsCardComponent = forwardRef(({
|
|||||||
}, ref) => {
|
}, ref) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
const { isAuthenticated: isLoggedIn } = useAuth();
|
||||||
const cardBg = PROFESSIONAL_COLORS.background.card;
|
const cardBg = PROFESSIONAL_COLORS.background.card;
|
||||||
const borderColor = PROFESSIONAL_COLORS.border.default;
|
const borderColor = PROFESSIONAL_COLORS.border.default;
|
||||||
|
|
||||||
@@ -220,6 +223,54 @@ const [currentMode, setCurrentMode] = useState('vertical');
|
|||||||
setCurrentMode(mode);
|
setCurrentMode(mode);
|
||||||
}, [mode]);
|
}, [mode]);
|
||||||
|
|
||||||
|
// 看涨看跌投票处理
|
||||||
|
const handleVoteChange = useCallback(async ({ eventId, voteType }) => {
|
||||||
|
if (!isLoggedIn) {
|
||||||
|
toast({
|
||||||
|
title: '请先登录',
|
||||||
|
description: '登录后才能参与投票',
|
||||||
|
status: 'warning',
|
||||||
|
duration: 2000,
|
||||||
|
isClosable: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${getApiBase()}/api/events/${eventId}/sentiment-vote`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ vote_type: voteType }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok || !data.success) {
|
||||||
|
throw new Error(data.error || '投票失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: voteType === 'bullish' ? '已看涨' : '已看跌',
|
||||||
|
status: 'success',
|
||||||
|
duration: 1500,
|
||||||
|
isClosable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 刷新当前页数据以更新投票计数
|
||||||
|
handlePageChange(currentPage, true);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('投票失败:', error);
|
||||||
|
toast({
|
||||||
|
title: '投票失败',
|
||||||
|
description: error.message,
|
||||||
|
status: 'error',
|
||||||
|
duration: 2000,
|
||||||
|
isClosable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [isLoggedIn, toast, handlePageChange, currentPage]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ⚡【核心逻辑】执行刷新的回调函数(包含原有的智能刷新逻辑)
|
* ⚡【核心逻辑】执行刷新的回调函数(包含原有的智能刷新逻辑)
|
||||||
*
|
*
|
||||||
@@ -757,6 +808,7 @@ const [currentMode, setCurrentMode] = useState('vertical');
|
|||||||
mode={mode}
|
mode={mode}
|
||||||
eventFollowStatus={eventFollowStatus}
|
eventFollowStatus={eventFollowStatus}
|
||||||
onToggleFollow={handleToggleFollow}
|
onToggleFollow={handleToggleFollow}
|
||||||
|
onVoteChange={handleVoteChange}
|
||||||
mainlineRef={mainlineRef}
|
mainlineRef={mainlineRef}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import VerticalModeLayout from "./layouts/VerticalModeLayout";
|
|||||||
* @param {string} mode - 展示模式:'vertical'(纵向分栏)| 'mainline'(主线时间轴)
|
* @param {string} mode - 展示模式:'vertical'(纵向分栏)| 'mainline'(主线时间轴)
|
||||||
* @param {Object} eventFollowStatus - 事件关注状态 { [eventId]: { isFollowing, followerCount } }
|
* @param {Object} eventFollowStatus - 事件关注状态 { [eventId]: { isFollowing, followerCount } }
|
||||||
* @param {Function} onToggleFollow - 关注按钮回调
|
* @param {Function} onToggleFollow - 关注按钮回调
|
||||||
|
* @param {Function} onVoteChange - 投票变化回调 { eventId, voteType: 'bullish' | 'bearish' }
|
||||||
* @param {React.Ref} mainlineRef - MainlineTimelineView 的 ref
|
* @param {React.Ref} mainlineRef - MainlineTimelineView 的 ref
|
||||||
*/
|
*/
|
||||||
const EventScrollList = React.memo(
|
const EventScrollList = React.memo(
|
||||||
@@ -40,6 +41,7 @@ const EventScrollList = React.memo(
|
|||||||
mode = "vertical",
|
mode = "vertical",
|
||||||
eventFollowStatus = {},
|
eventFollowStatus = {},
|
||||||
onToggleFollow,
|
onToggleFollow,
|
||||||
|
onVoteChange,
|
||||||
mainlineRef,
|
mainlineRef,
|
||||||
}) => {
|
}) => {
|
||||||
const scrollContainerRef = useRef(null);
|
const scrollContainerRef = useRef(null);
|
||||||
@@ -90,6 +92,7 @@ const EventScrollList = React.memo(
|
|||||||
onEventSelect={onEventSelect}
|
onEventSelect={onEventSelect}
|
||||||
eventFollowStatus={eventFollowStatus}
|
eventFollowStatus={eventFollowStatus}
|
||||||
onToggleFollow={onToggleFollow}
|
onToggleFollow={onToggleFollow}
|
||||||
|
onVoteChange={onVoteChange}
|
||||||
getTimelineBoxStyle={getTimelineBoxStyle}
|
getTimelineBoxStyle={getTimelineBoxStyle}
|
||||||
borderColor={borderColor}
|
borderColor={borderColor}
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import PaginationControl from '../PaginationControl';
|
|||||||
* @param {Function} onEventSelect - 事件选择回调
|
* @param {Function} onEventSelect - 事件选择回调
|
||||||
* @param {Object} eventFollowStatus - 事件关注状态
|
* @param {Object} eventFollowStatus - 事件关注状态
|
||||||
* @param {Function} onToggleFollow - 关注按钮回调
|
* @param {Function} onToggleFollow - 关注按钮回调
|
||||||
|
* @param {Function} onVoteChange - 投票变化回调 { eventId, voteType: 'bullish' | 'bearish' }
|
||||||
* @param {Function} getTimelineBoxStyle - 时间线样式获取函数
|
* @param {Function} getTimelineBoxStyle - 时间线样式获取函数
|
||||||
* @param {string} borderColor - 边框颜色
|
* @param {string} borderColor - 边框颜色
|
||||||
* @param {number} currentPage - 当前页码
|
* @param {number} currentPage - 当前页码
|
||||||
@@ -40,6 +41,7 @@ const VerticalModeLayout = React.memo(({
|
|||||||
onEventSelect,
|
onEventSelect,
|
||||||
eventFollowStatus,
|
eventFollowStatus,
|
||||||
onToggleFollow,
|
onToggleFollow,
|
||||||
|
onVoteChange,
|
||||||
getTimelineBoxStyle,
|
getTimelineBoxStyle,
|
||||||
borderColor,
|
borderColor,
|
||||||
currentPage = 1,
|
currentPage = 1,
|
||||||
@@ -124,6 +126,7 @@ const VerticalModeLayout = React.memo(({
|
|||||||
isFollowing={eventFollowStatus[event.id]?.isFollowing}
|
isFollowing={eventFollowStatus[event.id]?.isFollowing}
|
||||||
followerCount={eventFollowStatus[event.id]?.followerCount}
|
followerCount={eventFollowStatus[event.id]?.followerCount}
|
||||||
onToggleFollow={onToggleFollow}
|
onToggleFollow={onToggleFollow}
|
||||||
|
onVoteChange={onVoteChange}
|
||||||
timelineStyle={getTimelineBoxStyle()}
|
timelineStyle={getTimelineBoxStyle()}
|
||||||
borderColor={borderColor}
|
borderColor={borderColor}
|
||||||
indicatorSize="default"
|
indicatorSize="default"
|
||||||
|
|||||||
Reference in New Issue
Block a user