新增路由管理

Change-Id: I8139fd09f135c42944f60ca473ee208e69549dc2
diff --git a/Merge/front/src/api/posts_wzy.js b/Merge/front/src/api/posts_wzy.js
index b449c43..d901500 100644
--- a/Merge/front/src/api/posts_wzy.js
+++ b/Merge/front/src/api/posts_wzy.js
@@ -1,15 +1,25 @@
 // src/api/posts.js
-const BASE = 'http://10.126.59.25:5714/'  // 如果有代理可以留空,否则填完整域名,如 'http://localhost:3000'
+const BASE = 'http://10.126.59.25:5714'  // 如果有代理可以留空,否则填完整域名,如 'http://localhost:3000'
 
 /**
- * 获取所有已发布的帖子列表
- * GET /posts
+ * 获取帖子列表
+ * - GET /posts
+ * - GET /posts?user_id=123
+ *
+ * @param {number?} userId 可选,传了就加 ?user_id= 用户 ID
+ * @returns Promise<[{ id, title, status, heat, created_at }, …]>
  */
-export async function fetchPosts() {
-  const res = await fetch(`${BASE}/posts`)
-  if (!res.ok) throw new Error(`fetchPosts: ${res.status}`)
-  console.log('fetchPosts response:', res)  // debug: inspect response
-  return res.json()  // 返回 [ { id, title, heat, created_at }, … ]
+export async function fetchPosts(userId) {
+  // 自动拼接 query
+  const url = userId != null
+    ? `${BASE}/posts?user_id=${encodeURIComponent(userId)}`
+    : `${BASE}/posts`
+
+  const res = await fetch(url)
+  if (!res.ok) {
+    throw new Error(`fetchPosts${userId != null ? `(user ${userId})` : ''}: ${res.status}`)
+  }
+  return res.json()
 }
 
 /**