新增管理员页面和用户申诉、迁移审核页面,推荐系统

Change-Id: Ief5646321feb98fadb17da4b4e91caeaacdbacc5
diff --git a/front/src/AdminPage.js b/front/src/AdminPage.js
new file mode 100644
index 0000000..4862449
--- /dev/null
+++ b/front/src/AdminPage.js
@@ -0,0 +1,145 @@
+import React, { useState } from "react";
+import { useNavigate } from "react-router-dom";
+
+// 示例数据
+const initialConfig = {
+    FarmNumber: 3,
+    FakeTime: 3,
+    BegVote: 3,
+    CheatTime: 5,
+};
+
+const cheatUsers = [
+    { user_id: "u001", email: "cheat1@example.com", username: "cheater1", account_status: 1 },
+    { user_id: "u002", email: "cheat2@example.com", username: "cheater2", account_status: 0 },
+];
+
+const suspiciousUsers = [
+    { user_id: "u101", email: "suspect1@example.com", username: "suspect1", account_status: 0 },
+    { user_id: "u102", email: "suspect2@example.com", username: "suspect2", account_status: 0 },
+];
+
+export default function AdminPage() {
+    const navigate = useNavigate();
+    const [config, setConfig] = useState(initialConfig);
+
+    const handleConfigChange = (e) => {
+        const { name, value } = e.target;
+        setConfig({ ...config, [name]: value });
+    };
+
+    const handleBan = (user) => {
+        alert(`已封禁用户:${user.username}`);
+    };
+
+    return (
+        <div style={{ padding: 40, maxWidth: 900, margin: "0 auto" }}>
+            <h1 style={{ textAlign: "center", marginBottom: 32 }}>管理员页面</h1>
+            {/* 参数设置 */}
+            <div style={{ marginBottom: 32, padding: 18, background: "#f7faff", borderRadius: 12, display: "flex", gap: 24, alignItems: "center" }}>
+                <b>系统参数:</b>
+                <label>
+                    FarmNumber:
+                    <input type="number" name="FarmNumber" value={config.FarmNumber} onChange={handleConfigChange} style={{ width: 60, margin: "0 12px" }} />
+                </label>
+                <label>
+                    FakeTime:
+                    <input type="number" name="FakeTime" value={config.FakeTime} onChange={handleConfigChange} style={{ width: 60, margin: "0 12px" }} />
+                </label>
+                <label>
+                    BegVote:
+                    <input type="number" name="BegVote" value={config.BegVote} onChange={handleConfigChange} style={{ width: 60, margin: "0 12px" }} />
+                </label>
+                <label>
+                    CheatTime:
+                    <input type="number" name="CheatTime" value={config.CheatTime} onChange={handleConfigChange} style={{ width: 60, margin: "0 12px" }} />
+                </label>
+            </div>
+            {/* 作弊用户 */}
+            <div style={{ marginBottom: 32 }}>
+                <h2 style={{ color: "#e53935" }}>作弊用户</h2>
+                <table style={{ width: "100%", background: "#fff", borderRadius: 10, boxShadow: "0 2px 8px #e0e7ff", marginBottom: 18 }}>
+                    <thead>
+                        <tr style={{ background: "#f5f5f5" }}>
+                            <th>user_id</th>
+                            <th>email</th>
+                            <th>username</th>
+                            <th>account_status</th>
+                            <th>操作</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        {cheatUsers.map((u) => (
+                            <tr key={u.user_id}>
+                                <td>{u.user_id}</td>
+                                <td>{u.email}</td>
+                                <td>{u.username}</td>
+                                <td style={{ color: u.account_status === 1 ? "#e53935" : "#43a047" }}>
+                                    {u.account_status === 1 ? "封禁" : "正常"}
+                                </td>
+                                <td>
+                                    <button
+                                        style={{ background: "#e53935", color: "#fff", border: "none", borderRadius: 6, padding: "4px 14px", cursor: "pointer" }}
+                                        onClick={() => handleBan(u)}
+                                    >
+                                        封禁
+                                    </button>
+                                </td>
+                            </tr>
+                        ))}
+                    </tbody>
+                </table>
+            </div>
+            {/* 可疑用户 */}
+            <div style={{ marginBottom: 32 }}>
+                <h2 style={{ color: "#ff9800" }}>可疑用户</h2>
+                <table style={{ width: "100%", background: "#fff", borderRadius: 10, boxShadow: "0 2px 8px #e0e7ff" }}>
+                    <thead>
+                        <tr style={{ background: "#f5f5f5" }}>
+                            <th>user_id</th>
+                            <th>email</th>
+                            <th>username</th>
+                            <th>account_status</th>
+                            <th>操作</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        {suspiciousUsers.map((u) => (
+                            <tr key={u.user_id}>
+                                <td>{u.user_id}</td>
+                                <td>{u.email}</td>
+                                <td>{u.username}</td>
+                                <td style={{ color: u.account_status === 1 ? "#e53935" : "#43a047" }}>
+                                    {u.account_status === 1 ? "封禁" : "正常"}
+                                </td>
+                                <td>
+                                    <button
+                                        style={{ background: "#e53935", color: "#fff", border: "none", borderRadius: 6, padding: "4px 14px", cursor: "pointer" }}
+                                        onClick={() => handleBan(u)}
+                                    >
+                                        封禁
+                                    </button>
+                                </td>
+                            </tr>
+                        ))}
+                    </tbody>
+                </table>
+            </div>
+            {/* 跳转按钮 */}
+            <div style={{ display: "flex", gap: 24, justifyContent: "center" }}>
+                <button
+                    style={{ background: "#1976d2", color: "#fff", border: "none", borderRadius: 8, padding: "10px 28px", fontWeight: 600, fontSize: 16, cursor: "pointer" }}
+                    onClick={() => navigate("/appeal-review")}
+                >
+                    用户申诉
+                </button>
+                <button
+                    style={{ background: "#43a047", color: "#fff", border: "none", borderRadius: 8, padding: "10px 28px", fontWeight: 600, fontSize: 16, cursor: "pointer" }}
+                    onClick={() => navigate("/migration-review")}
+                >
+                    用户迁移
+                </button>
+            </div>
+        </div>
+    );
+}
\ No newline at end of file
diff --git a/front/src/App.js b/front/src/App.js
index 2f85943..372fa62 100644
--- a/front/src/App.js
+++ b/front/src/App.js
@@ -25,6 +25,10 @@
 import LoginPage from './LoginPage';
 import RegisterPage from './RegisterPage';
 import RequireAuth from './RequireAuth';
+import AdminPage from './AdminPage';
+import AppealPage from './AppealPage';
+import MigrationPage from './MigrationPage';
+
 
 const navItems = [
   { label: "电影", icon: <MovieIcon />, path: "/movie" },
@@ -164,6 +168,9 @@
           <Route path="/user" element={<UserProfile />} />
           <Route path="/publish" element={<PublishPage />} />
           <Route path="/torrent/:torrentId" element={<TorrentDetailPage />} />
+          <Route path="/admin" element={<AdminPage />} />
+          <Route path="/appeal-review" element={<AppealPage />} />
+          <Route path="/migration-review" element={<MigrationPage />} />
         </Route>
       </Routes>
     </Router>
diff --git a/front/src/AppealPage.js b/front/src/AppealPage.js
new file mode 100644
index 0000000..a0314c4
--- /dev/null
+++ b/front/src/AppealPage.js
@@ -0,0 +1,141 @@
+import React, { useState } from "react";
+
+// 示例申诉数据
+const appeals = [
+    {
+        appeal_id: "a001",
+        user_id: "u001",
+        content: "我没有作弊,请审核我的账号。",
+        file_url: "http://sse.bjtu.edu.cn/media/attachments/2024/10/20241012160658.pdf",
+        status: 0,
+    },
+    {
+        appeal_id: "a002",
+        user_id: "u002",
+        content: "误封申诉,详见附件。",
+        file_url: "http://sse.bjtu.edu.cn/media/attachments/2024/10/20241012160658.pdf",
+        status: 1,
+    },
+];
+
+// 简单PDF预览组件
+function FileViewer({ url }) {
+    if (!url) return <div>无附件</div>;
+    if (url.endsWith(".pdf")) {
+        return (
+            <iframe
+                src={url}
+                title="PDF预览"
+                width="100%"
+                height="400px"
+                style={{ border: "1px solid #ccc", borderRadius: 8 }}
+            />
+        );
+    }
+    // 这里只做PDF示例,实际可扩展为DOC等
+    return <a href={url} target="_blank" rel="noopener noreferrer">下载附件</a>;
+}
+
+export default function AppealPage() {
+    const [selectedId, setSelectedId] = useState(appeals[0].appeal_id);
+    const selectedAppeal = appeals.find(a => a.appeal_id === selectedId);
+
+    const handleApprove = () => {
+        alert("已通过申诉(示例,无实际状态变更)");
+    };
+    const handleReject = () => {
+        alert("已拒绝申诉(示例,无实际状态变更)");
+    };
+
+    return (
+        <div style={{ display: "flex", minHeight: "100vh", background: "#f7faff" }}>
+            {/* 侧栏 */}
+            <div style={{ width: 180, background: "#fff", borderRight: "1px solid #e0e7ff", padding: 0 }}>
+                <h3 style={{ textAlign: "center", padding: "18px 0 0 0", color: "#1976d2" }}>申诉列表</h3>
+                <div style={{ display: "flex", flexDirection: "column", gap: 12, marginTop: 18 }}>
+                    {appeals.map(a => (
+                        <div
+                            key={a.appeal_id}
+                            onClick={() => setSelectedId(a.appeal_id)}
+                            style={{
+                                margin: "0 12px",
+                                padding: "16px 10px",
+                                borderRadius: 8,
+                                background: selectedId === a.appeal_id ? "#e3f2fd" : "#fff",
+                                border: `2px solid ${a.status === 1 ? "#43a047" : "#e53935"}`,
+                                color: a.status === 1 ? "#43a047" : "#e53935",
+                                fontWeight: 600,
+                                cursor: "pointer",
+                                boxShadow: selectedId === a.appeal_id ? "0 2px 8px #b2d8ea" : "none",
+                                transition: "all 0.2s"
+                            }}
+                        >
+                            {a.appeal_id}
+                            <span style={{
+                                float: "right",
+                                fontSize: 12,
+                                color: a.status === 1 ? "#43a047" : "#e53935"
+                            }}>
+                                {a.status === 1 ? "已审核" : "未审核"}
+                            </span>
+                        </div>
+                    ))}
+                </div>
+            </div>
+            {/* 申诉详情 */}
+            <div style={{ flex: 1, padding: "40px 48px" }}>
+                <h2 style={{ marginBottom: 24, color: "#1976d2" }}>申诉详情</h2>
+                <div style={{ background: "#fff", borderRadius: 12, padding: 32, boxShadow: "0 2px 8px #e0e7ff", marginBottom: 32 }}>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>申诉ID:</b>{selectedAppeal.appeal_id}
+                    </div>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>用户ID:</b>{selectedAppeal.user_id}
+                    </div>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>申诉内容:</b>{selectedAppeal.content}
+                    </div>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>申诉文件:</b>
+                        <FileViewer url={selectedAppeal.file_url} />
+                    </div>
+                </div>
+                {/* 审核按钮 */}
+                <div style={{ display: "flex", gap: 32, justifyContent: "center" }}>
+                    <button
+                        style={{
+                            background: selectedAppeal.status === 1 ? "#bdbdbd" : "#43a047",
+                            color: "#fff",
+                            border: "none",
+                            borderRadius: 8,
+                            padding: "10px 38px",
+                            fontWeight: 600,
+                            fontSize: 18,
+                            cursor: selectedAppeal.status === 1 ? "not-allowed" : "pointer"
+                        }}
+                        disabled={selectedAppeal.status === 1}
+                        onClick={handleApprove}
+                    >
+                        通过
+                    </button>
+                    <button
+                        style={{
+                            background: selectedAppeal.status === 1 ? "#bdbdbd" : "#e53935",
+                            color: "#fff",
+                            border: "none",
+                            borderRadius: 8,
+                            padding: "10px 38px",
+                            fontWeight: 600,
+                            fontSize: 18,
+                            cursor: selectedAppeal.status === 1 ? "not-allowed" : "pointer"
+                        }}
+                        disabled={selectedAppeal.status === 1}
+                        onClick={handleReject}
+                    >
+                        不通过
+                    </button>
+                </div>
+            </div>
+        </div>
+    );
+}
\ No newline at end of file
diff --git a/front/src/LoginPage.js b/front/src/LoginPage.js
index 5bb3603..890b690 100644
--- a/front/src/LoginPage.js
+++ b/front/src/LoginPage.js
@@ -15,6 +15,12 @@
   };

 

   const handleLogin = async () => {

+    // 进入管理员页面

+    if (formData.username === "admin" && formData.password === "admin123") {

+      navigate('/admin');

+      return;

+    }

+

     if (formData.password.length < 8) {

       setErrorMessage('密码必须至少包含八位字符!');

       return;

@@ -60,7 +66,7 @@
         const { username, password } = JSON.parse(regUser);

         setFormData({ username, password });

         sessionStorage.removeItem('registeredUser');

-      } catch {}

+      } catch { }

     }

   }, []);

 

diff --git a/front/src/MigrationPage.js b/front/src/MigrationPage.js
new file mode 100644
index 0000000..ed88a55
--- /dev/null
+++ b/front/src/MigrationPage.js
@@ -0,0 +1,152 @@
+import React, { useState } from "react";
+
+// 示例迁移数据
+const migrations = [
+    {
+        migration_id: "m001",
+        user_id: "u001",
+        application_url: "http://sse.bjtu.edu.cn/media/attachments/2024/10/20241012160658.pdf",
+        approved: 0,
+        pending_magic: 10,
+        granted_magic: 0,
+        pending_uploaded: 1000,
+        granted_uploaded: 0,
+    },
+    {
+        migration_id: "m002",
+        user_id: "u002",
+        application_url: "http://sse.bjtu.edu.cn/media/attachments/2024/10/20241012160658.pdf",
+        approved: 1,
+        pending_magic: 20,
+        granted_magic: 20,
+        pending_uploaded: 2000,
+        granted_uploaded: 2000,
+    },
+];
+
+// 简单PDF预览组件
+function FileViewer({ url }) {
+    if (!url) return <div>无附件</div>;
+    if (url.endsWith(".pdf")) {
+        return (
+            <iframe
+                src={url}
+                title="PDF预览"
+                width="100%"
+                height="400px"
+                style={{ border: "1px solid #ccc", borderRadius: 8 }}
+            />
+        );
+    }
+    // 这里只做PDF示例,实际可扩展为DOC等
+    return <a href={url} target="_blank" rel="noopener noreferrer">下载附件</a>;
+}
+
+export default function MigrationPage() {
+    const [selectedId, setSelectedId] = useState(migrations[0].migration_id);
+    const selectedMigration = migrations.find(m => m.migration_id === selectedId);
+
+    const handleApprove = () => {
+        alert("已通过迁移(示例,无实际状态变更)");
+    };
+    const handleReject = () => {
+        alert("已拒绝迁移(示例,无实际状态变更)");
+    };
+
+    return (
+        <div style={{ display: "flex", minHeight: "100vh", background: "#f7faff" }}>
+            {/* 侧栏 */}
+            <div style={{ width: 180, background: "#fff", borderRight: "1px solid #e0e7ff", padding: 0 }}>
+                <h3 style={{ textAlign: "center", padding: "18px 0 0 0", color: "#1976d2" }}>迁移列表</h3>
+                <div style={{ display: "flex", flexDirection: "column", gap: 12, marginTop: 18 }}>
+                    {migrations.map(m => (
+                        <div
+                            key={m.migration_id}
+                            onClick={() => setSelectedId(m.migration_id)}
+                            style={{
+                                margin: "0 12px",
+                                padding: "16px 10px",
+                                borderRadius: 8,
+                                background: selectedId === m.migration_id ? "#e3f2fd" : "#fff",
+                                border: `2px solid ${m.approved === 1 ? "#43a047" : "#e53935"}`,
+                                color: m.approved === 1 ? "#43a047" : "#e53935",
+                                fontWeight: 600,
+                                cursor: "pointer",
+                                boxShadow: selectedId === m.migration_id ? "0 2px 8px #b2d8ea" : "none",
+                                transition: "all 0.2s"
+                            }}
+                        >
+                            {m.migration_id}
+                            <span style={{
+                                float: "right",
+                                fontSize: 12,
+                                color: m.approved === 1 ? "#43a047" : "#e53935"
+                            }}>
+                                {m.approved === 1 ? "已审核" : "未审核"}
+                            </span>
+                        </div>
+                    ))}
+                </div>
+            </div>
+            {/* 迁移详情 */}
+            <div style={{ flex: 1, padding: "40px 48px" }}>
+                <h2 style={{ marginBottom: 24, color: "#1976d2" }}>迁移详情</h2>
+                <div style={{ background: "#fff", borderRadius: 12, padding: 32, boxShadow: "0 2px 8px #e0e7ff", marginBottom: 32 }}>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>迁移ID:</b>{selectedMigration.migration_id}
+                    </div>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>用户ID:</b>{selectedMigration.user_id}
+                    </div>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>申请文件:</b>
+                        <FileViewer url={selectedMigration.application_url} />
+                    </div>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>待迁移魔法值:</b>{selectedMigration.pending_magic},
+                        <b>已迁移魔法值:</b>{selectedMigration.granted_magic}
+                    </div>
+                    <div style={{ marginBottom: 18 }}>
+                        <b>待迁移上传量:</b>{selectedMigration.pending_uploaded},
+                        <b>已迁移上传量:</b>{selectedMigration.granted_uploaded}
+                    </div>
+                </div>
+                {/* 审核按钮 */}
+                <div style={{ display: "flex", gap: 32, justifyContent: "center" }}>
+                    <button
+                        style={{
+                            background: selectedMigration.approved === 1 ? "#bdbdbd" : "#43a047",
+                            color: "#fff",
+                            border: "none",
+                            borderRadius: 8,
+                            padding: "10px 38px",
+                            fontWeight: 600,
+                            fontSize: 18,
+                            cursor: selectedMigration.approved === 1 ? "not-allowed" : "pointer"
+                        }}
+                        disabled={selectedMigration.approved === 1}
+                        onClick={handleApprove}
+                    >
+                        通过
+                    </button>
+                    <button
+                        style={{
+                            background: selectedMigration.approved === 1 ? "#bdbdbd" : "#e53935",
+                            color: "#fff",
+                            border: "none",
+                            borderRadius: 8,
+                            padding: "10px 38px",
+                            fontWeight: 600,
+                            fontSize: 18,
+                            cursor: selectedMigration.approved === 1 ? "not-allowed" : "pointer"
+                        }}
+                        disabled={selectedMigration.approved === 1}
+                        onClick={handleReject}
+                    >
+                        不通过
+                    </button>
+                </div>
+            </div>
+        </div>
+    );
+}
\ No newline at end of file
diff --git a/front/src/UserProfile.js b/front/src/UserProfile.js
index 753e901..16fdcd2 100644
--- a/front/src/UserProfile.js
+++ b/front/src/UserProfile.js
@@ -33,7 +33,7 @@
       if (!userid) return;

       try {

         const res = await fetch(`${API_BASE_URL}/api/user-profile?userid=${userid}`);

-        

+

         if (res.ok) {

           const data = await res.json();

           setUserInfo(data);

@@ -91,9 +91,9 @@
   };

 

   const handleSave = async () => {

-    if (tempUserInfo.gender === "男性"){

+    if (tempUserInfo.gender === "男性") {

       tempUserInfo.gender = "m";

-    }else if (tempUserInfo.gender === "女性"){

+    } else if (tempUserInfo.gender === "女性") {

       tempUserInfo.gender = "f";

     }

     setUserInfo({ ...tempUserInfo });

@@ -222,7 +222,7 @@
               >

                 {tempUserInfo.gender === 'm' ? '男性'

                   : tempUserInfo.gender === 'f' ? '女性'

-                  : '性别'}

+                    : '性别'}

               </button>

               {tempUserInfo.showGenderOptions && (

                 <ul

@@ -307,7 +307,7 @@
                       // const userid = localStorage.getItem("userid");

                       // const userid = "550e8400-e29b-41d4-a716-446655440000"; // 示例userid

                       try {

-                        

+

                         const res = await fetch(`${API_BASE_URL}/api/delete-seed`, {

                           method: 'POST',

                           headers: { 'Content-Type': 'application/json' },