wht | 6a1b678 | 2025-06-06 19:14:59 +0800 | [diff] [blame] | 1 | import React from "react"; |
| 2 | import { useNavigate } from "react-router-dom"; |
| 3 | |
| 4 | // 示例数据 |
| 5 | const posts = [ |
| 6 | { |
| 7 | post_id: "1", |
| 8 | title: "欢迎来到G10论坛", |
| 9 | content: "这里是G10 PT站的官方论坛,欢迎大家发帖交流!", |
| 10 | author_id: "u1", |
| 11 | author_name: "Alice", |
| 12 | created_at: "2024-06-01 12:00", |
| 13 | reply_count: 3, |
| 14 | view_count: 120, |
| 15 | }, |
| 16 | { |
| 17 | post_id: "2", |
| 18 | title: "经典电影合集", |
| 19 | content: "90年代经典电影大家有什么推荐吗?", |
| 20 | author_id: "u2", |
| 21 | author_name: "Bob", |
| 22 | created_at: "2024-06-02 09:30", |
| 23 | reply_count: 1, |
| 24 | view_count: 45, |
| 25 | }, |
| 26 | ]; |
| 27 | |
| 28 | export default function ForumPage() { |
| 29 | const navigate = useNavigate(); |
| 30 | return ( |
| 31 | <div style={{ maxWidth: 700, margin: "40px auto" }}> |
| 32 | <div style={{ display: "flex", alignItems: "center", marginBottom: 24 }}> |
| 33 | <h2 style={{ color: "#1a237e", margin: 0, marginRight: 24 }}>G10 论坛</h2> |
| 34 | <input |
| 35 | type="text" |
| 36 | placeholder="搜索帖子内容" |
| 37 | style={{ |
| 38 | flex: 1, |
| 39 | fontSize: 16, |
| 40 | padding: "8px 14px", |
| 41 | border: "1px solid #bfcfff", |
| 42 | borderRadius: 8, |
| 43 | outline: "none", |
| 44 | minWidth: 0, |
| 45 | }} |
| 46 | /> |
| 47 | <button |
| 48 | style={{ |
| 49 | marginLeft: 8, |
| 50 | fontSize: 16, |
| 51 | padding: "8px 18px", |
| 52 | border: "1px solid #bfcfff", |
| 53 | background: "#e0e7ff", |
| 54 | borderRadius: 8, |
| 55 | cursor: "pointer", |
| 56 | }} |
| 57 | > |
| 58 | 🔍 |
| 59 | </button> |
| 60 | </div> |
| 61 | {posts.map(post => ( |
| 62 | <div |
| 63 | key={post.post_id} |
| 64 | style={{ |
| 65 | background: "#fff", |
| 66 | borderRadius: 12, |
| 67 | boxShadow: "0 2px 8px #e0e7ff", |
| 68 | padding: 24, |
| 69 | marginBottom: 24, |
| 70 | cursor: "pointer", |
| 71 | transition: "box-shadow 0.2s", |
| 72 | }} |
| 73 | onClick={() => navigate(`/forum/${post.post_id}`)} |
| 74 | > |
| 75 | <div style={{ fontSize: 15, color: "#1976d2", marginBottom: 6 }}> |
| 76 | {post.author_name} · {post.created_at} |
| 77 | </div> |
| 78 | <div style={{ fontWeight: 600, fontSize: 20, marginBottom: 8, color: "#222" }}> |
| 79 | {post.title} |
| 80 | </div> |
| 81 | <div style={{ fontSize: 16, color: "#444", marginBottom: 18 }}> |
| 82 | {post.content} |
| 83 | </div> |
| 84 | <div style={{ display: "flex", justifyContent: "flex-start", gap: 32, fontSize: 14, color: "#888" }}> |
| 85 | <span>回复数: {post.reply_count}</span> |
| 86 | <span>观看数: {post.view_count}</span> |
| 87 | </div> |
| 88 | </div> |
| 89 | ))} |
| 90 | </div> |
| 91 | ); |
| 92 | } |