修改注册登录界面,新增路由保护

Change-Id: I6c665d9e92813506158113fe97c1119d7ad09d92
diff --git a/front/src/ForumPage.js b/front/src/ForumPage.js
index ed94e0f..abcba7d 100644
--- a/front/src/ForumPage.js
+++ b/front/src/ForumPage.js
@@ -1,5 +1,6 @@
-import React from "react";
+import React, { useState, useEffect } from "react";
 import { useNavigate } from "react-router-dom";
+import { API_BASE_URL } from "./config";
 
 // 示例数据
 const posts = [
@@ -27,6 +28,20 @@
 
 export default function ForumPage() {
     const navigate = useNavigate();
+    const [posts, setPosts] = useState([]);
+
+    useEffect(() => {
+        // get userId from cookie
+        const match = document.cookie.match('(^|;)\\s*userId=([^;]+)');
+        const userId = match ? match[2] : null;
+        console.log("User ID from cookie:", userId);
+        if (!userId) return;
+        fetch(`${API_BASE_URL}/api/forum`)
+            .then(res => res.json())
+            .then(data => setPosts(data))
+            .catch(() => setPosts([]));
+    }, []);
+
     return (
         <div style={{ maxWidth: 700, margin: "40px auto" }}>
             <div style={{ display: "flex", alignItems: "center", marginBottom: 24 }}>