事件中心的涨停原因里面和事件相关
This commit is contained in:
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -189,7 +189,7 @@ def init_prediction_api(db, beijing_now):
|
||||
def get_prediction_topics():
|
||||
"""获取预测话题列表"""
|
||||
try:
|
||||
status = request.args.get('status', 'active')
|
||||
status = request.args.get('status', '') # 默认为空,表示全部状态
|
||||
category = request.args.get('category')
|
||||
sort_by = request.args.get('sort_by', 'created_at')
|
||||
page = request.args.get('page', 1, type=int)
|
||||
@@ -198,7 +198,8 @@ def init_prediction_api(db, beijing_now):
|
||||
# 构建查询
|
||||
query = PredictionTopic.query
|
||||
|
||||
if status:
|
||||
# status 为空、'all' 或 'all_status' 时不过滤,返回全部
|
||||
if status and status not in ('all', 'all_status', ''):
|
||||
query = query.filter_by(status=status)
|
||||
if category:
|
||||
query = query.filter_by(category=category)
|
||||
|
||||
@@ -51,6 +51,7 @@ const ValueForum = () => {
|
||||
const [total, setTotal] = useState(0);
|
||||
const [hasMore, setHasMore] = useState(true);
|
||||
const [activeTab, setActiveTab] = useState(0);
|
||||
const [predictionStatus, setPredictionStatus] = useState(''); // 预测市场状态筛选,空字符串表示全部
|
||||
|
||||
const { isOpen: isPostModalOpen, onOpen: onPostModalOpen, onClose: onPostModalClose } = useDisclosure();
|
||||
const { isOpen: isPredictionModalOpen, onOpen: onPredictionModalOpen, onClose: onPredictionModalClose } = useDisclosure();
|
||||
@@ -92,10 +93,10 @@ const ValueForum = () => {
|
||||
};
|
||||
|
||||
// 获取预测话题列表
|
||||
const fetchPredictionTopics = async () => {
|
||||
const fetchPredictionTopics = async (statusFilter = predictionStatus) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await getTopics({ status: 'active', sort_by: sortBy });
|
||||
const response = await getTopics({ status: statusFilter, sort_by: sortBy });
|
||||
if (response.success) {
|
||||
// 支持两种返回格式:直接数组或带分页的对象
|
||||
const topicsData = Array.isArray(response.data)
|
||||
@@ -118,7 +119,7 @@ const ValueForum = () => {
|
||||
} else {
|
||||
fetchPredictionTopics();
|
||||
}
|
||||
}, [sortBy, activeTab]);
|
||||
}, [sortBy, activeTab, predictionStatus]);
|
||||
|
||||
// 搜索处理
|
||||
const handleSearch = () => {
|
||||
@@ -151,6 +152,13 @@ const ValueForum = () => {
|
||||
{ value: 'views_count', label: '最多浏览', icon: TrendingUp },
|
||||
];
|
||||
|
||||
// 预测市场状态筛选选项
|
||||
const predictionStatusOptions = [
|
||||
{ value: '', label: '全部状态' },
|
||||
{ value: 'active', label: '交易中' },
|
||||
{ value: 'settled', label: '已结算' },
|
||||
];
|
||||
|
||||
return (
|
||||
<Box
|
||||
minH="100vh"
|
||||
@@ -414,6 +422,27 @@ const ValueForum = () => {
|
||||
|
||||
{/* 预测市场标签页 */}
|
||||
<TabPanel p="0">
|
||||
{/* 状态筛选 */}
|
||||
<HStack spacing="3" mb="6" flexWrap="wrap">
|
||||
{predictionStatusOptions.map((option) => (
|
||||
<Button
|
||||
key={option.value}
|
||||
size="sm"
|
||||
variant={predictionStatus === option.value ? 'solid' : 'outline'}
|
||||
bg={predictionStatus === option.value ? forumColors.gradients.goldPrimary : 'transparent'}
|
||||
color={predictionStatus === option.value ? forumColors.background.main : forumColors.text.secondary}
|
||||
borderColor={forumColors.border.default}
|
||||
onClick={() => setPredictionStatus(option.value)}
|
||||
_hover={{
|
||||
bg: predictionStatus === option.value ? forumColors.gradients.goldPrimary : forumColors.background.hover,
|
||||
borderColor: forumColors.border.gold,
|
||||
}}
|
||||
>
|
||||
{option.label}
|
||||
</Button>
|
||||
))}
|
||||
</HStack>
|
||||
|
||||
{loading ? (
|
||||
<PageLoader inline />
|
||||
) : predictionTopics.length === 0 ? (
|
||||
@@ -421,17 +450,21 @@ const ValueForum = () => {
|
||||
<VStack spacing="4">
|
||||
<Icon as={Zap} boxSize="48px" color={forumColors.text.tertiary} />
|
||||
<Text color={forumColors.text.secondary} fontSize="lg">
|
||||
暂无预测话题,快来发起第一个吧!
|
||||
{predictionStatus === '' ? '暂无预测话题,快来发起第一个吧!' :
|
||||
predictionStatus === 'active' ? '暂无交易中的话题' :
|
||||
'暂无已结算的话题'}
|
||||
</Text>
|
||||
<Button
|
||||
leftIcon={<Zap size={18} />}
|
||||
bg={forumColors.gradients.goldPrimary}
|
||||
color={forumColors.background.main}
|
||||
onClick={onPredictionModalOpen}
|
||||
_hover={{ opacity: 0.9 }}
|
||||
>
|
||||
发起预测
|
||||
</Button>
|
||||
{predictionStatus === '' && (
|
||||
<Button
|
||||
leftIcon={<Zap size={18} />}
|
||||
bg={forumColors.gradients.goldPrimary}
|
||||
color={forumColors.background.main}
|
||||
onClick={onPredictionModalOpen}
|
||||
_hover={{ opacity: 0.9 }}
|
||||
>
|
||||
发起预测
|
||||
</Button>
|
||||
)}
|
||||
</VStack>
|
||||
</Center>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user