import React, { useState, useEffect } from 'react'; import { Card, List, Tag, Space, Input, Button, Select, Badge, Avatar } from 'antd'; import { history } from '@umijs/max'; import { PlusOutlined, EyeOutlined, MessageOutlined, LikeOutlined, } from '@ant-design/icons'; import styles from './index.less'; import { listAllPostsUsingGet } from '@/services/hebi/postController'; import dayjs from 'dayjs'; const { Search } = Input; const ForumList: React.FC = () => { const [loading, setLoading] = useState(false); const [filter, setFilter] = useState('all'); const [postList, setPostList] = useState([]); // 拉取帖子数据 useEffect(() => { const fetchPosts = async () => { setLoading(true); try { const res = await listAllPostsUsingGet(); if (res && res.code === 0 && Array.isArray(res.data)) { setPostList(res.data); } else { setPostList([]); } } catch (e) { setPostList([]); } setLoading(false); }; fetchPosts(); }, []); const categories = [ { value: 'all', label: '全部' }, { value: 'tech', label: '技术讨论' }, { value: 'share', label: '经验分享' }, { value: 'question', label: '问题求助' }, ]; const handleSearch = (value: string) => { // 可根据 value 进行前端过滤或请求接口 console.log('搜索:', value); }; // 分类过滤 const filteredPosts = filter === 'all' ? postList : postList.filter(item => item.tagList && item.tagList.includes(filter)); return (