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