blob: 85b7707988cc114d062f7a1243958129a923fd3e [file] [log] [blame]
wht6a1b6782025-06-06 19:14:59 +08001import React from "react";
2import { useParams } from "react-router-dom";
3
4// 示例数据
5const post = {
6 post_id: "1",
7 title: "欢迎来到G10论坛",
8 content: "这里是G10 PT站的官方论坛,欢迎大家发帖交流!",
9 author_id: "u1",
10 author_name: "Alice",
11 created_at: "2024-06-01 12:00",
12 reply_count: 3,
13 view_count: 120,
14};
15
16const replies = [
17 {
18 reply_id: "r1",
19 post_id: "1",
20 content: "支持一下!",
21 author_id: "u2",
22 author_name: "Bob",
23 created_at: "2024-06-01 13:00",
24 },
25 {
26 reply_id: "r2",
27 post_id: "1",
28 content: "论坛终于上线了!",
29 author_id: "u3",
30 author_name: "Carol",
31 created_at: "2024-06-01 14:20",
32 },
33];
34
35export default function PostDetailPage() {
36 const { postId } = useParams();
37 // 这里只展示post和replies的静态内容
38 return (
39 <div style={{ maxWidth: 700, margin: "40px auto" }}>
40 {/* 原帖 */}
41 <div style={{
42 background: "#fff",
43 borderRadius: 12,
44 boxShadow: "0 2px 8px #e0e7ff",
45 padding: 24,
46 marginBottom: 32,
47 }}>
48 <div style={{ fontSize: 15, color: "#1976d2", marginBottom: 6 }}>
49 {post.author_name} · {post.created_at}
50 </div>
51 <div style={{ fontWeight: 600, fontSize: 20, marginBottom: 8, color: "#222" }}>
52 {post.title}
53 </div>
54 <div style={{ fontSize: 16, color: "#444", marginBottom: 18 }}>
55 {post.content}
56 </div>
57 <div style={{ display: "flex", justifyContent: "flex-start", gap: 32, fontSize: 14, color: "#888" }}>
58 <span>回复数: {post.reply_count}</span>
59 <span>观看数: {post.view_count}</span>
60 </div>
61 </div>
62 {/* 评论区 */}
63 <div>
64 {replies.map(reply => (
65 <div key={reply.reply_id} style={{
66 display: "flex",
67 alignItems: "center",
68 background: "#f8faff",
69 borderRadius: 8,
70 padding: "12px 18px",
71 marginBottom: 16,
72 fontSize: 15,
73 }}>
74 <span style={{ color: "#1976d2", fontWeight: 500, minWidth: 80 }}>{reply.author_name}</span>
75 <span style={{ flex: 1, marginLeft: 18 }}>{reply.content}</span>
76 <span style={{ color: "#888", fontSize: 13, marginLeft: 18 }}>{reply.created_at}</span>
77 </div>
78 ))}
79 </div>
80 {/* 回复框 */}
81 <div style={{
82 marginTop: 32,
83 background: "#fff",
84 borderRadius: 8,
85 boxShadow: "0 2px 8px #e0e7ff",
86 padding: 18,
87 display: "flex",
88 gap: 12,
89 alignItems: "center"
90 }}>
91 <input
92 type="text"
93 placeholder="写下你的回复..."
94 style={{
95 flex: 1,
96 border: "1px solid #bfcfff",
97 borderRadius: 6,
98 padding: "8px 12px",
99 fontSize: 15,
100 }}
101 />
102 <button style={{
103 background: "#1976d2",
104 color: "#fff",
105 border: "none",
106 borderRadius: 6,
107 padding: "8px 24px",
108 fontSize: 15,
109 cursor: "pointer"
110 }}>回复</button>
111 </div>
112 </div>
113 );
114}