import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { motion } from 'framer-motion'; import { Button, Typography, Spin, Row, Col, Empty, Tag } from 'antd'; import { ReadOutlined, ClockCircleOutlined, UserOutlined, BookOutlined } from '@ant-design/icons'; import { getVCCourses } from '../api'; const { Title, Paragraph } = Typography; const VCCourses = () => { const [courses, setCourses] = useState([]); const [loading, setLoading] = useState(true); const navigate = useNavigate(); useEffect(() => { const fetchCourses = async () => { try { const res = await getVCCourses(); setCourses(res.data); } catch (error) { console.error("Failed to fetch VC Courses:", error); } finally { setLoading(false); } } fetchCourses(); }, []); if (loading) return
; return (
VC <span style={{ color: '#00f0ff' }}>CODING COURSES</span> 探索 VC Coding 软件与硬件课程,开启您的编程之旅。
{courses.length === 0 ? (
暂无课程内容} />
) : ( {courses.map((item, index) => ( navigate(`/courses/${item.id}`)} style={{ cursor: 'pointer' }} >
{item.display_cover_image ? ( {item.title} ) : ( )}
{item.tag && ( {item.tag} )} {item.course_type_display || (item.course_type === 'hardware' ? '硬件课程' : '软件课程')}

{item.title}

{item.instructor} {item.duration} {item.lesson_count} 课时

{item.description}

))}
)} {/* 装饰性背景 */}
); }; export default VCCourses;