blob: 4862449146f6447ff13cff96c077c6904772680e [file] [log] [blame]
whtb1e79592025-06-07 16:03:09 +08001import React, { useState } from "react";
2import { useNavigate } from "react-router-dom";
3
4// 示例数据
5const initialConfig = {
6 FarmNumber: 3,
7 FakeTime: 3,
8 BegVote: 3,
9 CheatTime: 5,
10};
11
12const cheatUsers = [
13 { user_id: "u001", email: "cheat1@example.com", username: "cheater1", account_status: 1 },
14 { user_id: "u002", email: "cheat2@example.com", username: "cheater2", account_status: 0 },
15];
16
17const suspiciousUsers = [
18 { user_id: "u101", email: "suspect1@example.com", username: "suspect1", account_status: 0 },
19 { user_id: "u102", email: "suspect2@example.com", username: "suspect2", account_status: 0 },
20];
21
22export default function AdminPage() {
23 const navigate = useNavigate();
24 const [config, setConfig] = useState(initialConfig);
25
26 const handleConfigChange = (e) => {
27 const { name, value } = e.target;
28 setConfig({ ...config, [name]: value });
29 };
30
31 const handleBan = (user) => {
32 alert(`已封禁用户:${user.username}`);
33 };
34
35 return (
36 <div style={{ padding: 40, maxWidth: 900, margin: "0 auto" }}>
37 <h1 style={{ textAlign: "center", marginBottom: 32 }}>管理员页面</h1>
38 {/* 参数设置 */}
39 <div style={{ marginBottom: 32, padding: 18, background: "#f7faff", borderRadius: 12, display: "flex", gap: 24, alignItems: "center" }}>
40 <b>系统参数:</b>
41 <label>
42 FarmNumber:
43 <input type="number" name="FarmNumber" value={config.FarmNumber} onChange={handleConfigChange} style={{ width: 60, margin: "0 12px" }} />
44 </label>
45 <label>
46 FakeTime:
47 <input type="number" name="FakeTime" value={config.FakeTime} onChange={handleConfigChange} style={{ width: 60, margin: "0 12px" }} />
48 </label>
49 <label>
50 BegVote:
51 <input type="number" name="BegVote" value={config.BegVote} onChange={handleConfigChange} style={{ width: 60, margin: "0 12px" }} />
52 </label>
53 <label>
54 CheatTime:
55 <input type="number" name="CheatTime" value={config.CheatTime} onChange={handleConfigChange} style={{ width: 60, margin: "0 12px" }} />
56 </label>
57 </div>
58 {/* 作弊用户 */}
59 <div style={{ marginBottom: 32 }}>
60 <h2 style={{ color: "#e53935" }}>作弊用户</h2>
61 <table style={{ width: "100%", background: "#fff", borderRadius: 10, boxShadow: "0 2px 8px #e0e7ff", marginBottom: 18 }}>
62 <thead>
63 <tr style={{ background: "#f5f5f5" }}>
64 <th>user_id</th>
65 <th>email</th>
66 <th>username</th>
67 <th>account_status</th>
68 <th>操作</th>
69 </tr>
70 </thead>
71 <tbody>
72 {cheatUsers.map((u) => (
73 <tr key={u.user_id}>
74 <td>{u.user_id}</td>
75 <td>{u.email}</td>
76 <td>{u.username}</td>
77 <td style={{ color: u.account_status === 1 ? "#e53935" : "#43a047" }}>
78 {u.account_status === 1 ? "封禁" : "正常"}
79 </td>
80 <td>
81 <button
82 style={{ background: "#e53935", color: "#fff", border: "none", borderRadius: 6, padding: "4px 14px", cursor: "pointer" }}
83 onClick={() => handleBan(u)}
84 >
85 封禁
86 </button>
87 </td>
88 </tr>
89 ))}
90 </tbody>
91 </table>
92 </div>
93 {/* 可疑用户 */}
94 <div style={{ marginBottom: 32 }}>
95 <h2 style={{ color: "#ff9800" }}>可疑用户</h2>
96 <table style={{ width: "100%", background: "#fff", borderRadius: 10, boxShadow: "0 2px 8px #e0e7ff" }}>
97 <thead>
98 <tr style={{ background: "#f5f5f5" }}>
99 <th>user_id</th>
100 <th>email</th>
101 <th>username</th>
102 <th>account_status</th>
103 <th>操作</th>
104 </tr>
105 </thead>
106 <tbody>
107 {suspiciousUsers.map((u) => (
108 <tr key={u.user_id}>
109 <td>{u.user_id}</td>
110 <td>{u.email}</td>
111 <td>{u.username}</td>
112 <td style={{ color: u.account_status === 1 ? "#e53935" : "#43a047" }}>
113 {u.account_status === 1 ? "封禁" : "正常"}
114 </td>
115 <td>
116 <button
117 style={{ background: "#e53935", color: "#fff", border: "none", borderRadius: 6, padding: "4px 14px", cursor: "pointer" }}
118 onClick={() => handleBan(u)}
119 >
120 封禁
121 </button>
122 </td>
123 </tr>
124 ))}
125 </tbody>
126 </table>
127 </div>
128 {/* 跳转按钮 */}
129 <div style={{ display: "flex", gap: 24, justifyContent: "center" }}>
130 <button
131 style={{ background: "#1976d2", color: "#fff", border: "none", borderRadius: 8, padding: "10px 28px", fontWeight: 600, fontSize: 16, cursor: "pointer" }}
132 onClick={() => navigate("/appeal-review")}
133 >
134 用户申诉
135 </button>
136 <button
137 style={{ background: "#43a047", color: "#fff", border: "none", borderRadius: 8, padding: "10px 28px", fontWeight: 600, fontSize: 16, cursor: "pointer" }}
138 onClick={() => navigate("/migration-review")}
139 >
140 用户迁移
141 </button>
142 </div>
143 </div>
144 );
145}