调试兴趣小组封面图
Change-Id: I757ff42431a7f7c280444bec03a4fc965416aa2d
diff --git a/src/pages/InterestGroup/GroupItem.jsx b/src/pages/InterestGroup/GroupItem.jsx
index 4f76bac..8fdc640 100644
--- a/src/pages/InterestGroup/GroupItem.jsx
+++ b/src/pages/InterestGroup/GroupItem.jsx
@@ -1,59 +1,3 @@
-// import React, { useState } from 'react';
-// import { useGroupStore } from '../../context/useGroupStore';
-// import { useUser } from '../../context/UserContext'; // ✅ 新增:引入 UserContext
-// import CreatePostForm from './CreatePostForm';
-
-// const GroupItem = ({ group }) => {
-// const { handleJoinGroup, joinStatus } = useGroupStore();
-// const { user } = useUser(); // ✅ 获取 user
-// const userId = user?.userId; // ✅ 安全获取 userId
-// const [showCreatePost, setShowCreatePost] = useState(false);
-
-// return (
-// <div className="group-item">
-// <div className="group-content">
-// <img
-// style={{ width: '40%', height: '40%' }}
-// src={group.cover_image || 'https://picsum.photos/200/200'}
-// alt={group.groupName || group.name}
-// className="group-cover"
-// />
-// <div className="group-info-right">
-// <h3>{group.groupName || group.name}</h3>
-// <p style={{ color: '#BA929A' }}>{group.memberCount || 0}人加入了小组</p>
-// <button
-// onClick={() => handleJoinGroup(group.group_id, userId)}
-// disabled={joinStatus[group.group_id] === '加入成功' || !userId}
-// >
-// {joinStatus[group.group_id] === '加入成功' ? '已加入' : userId ? '+加入小组' : '请登录'}
-// </button>
-
-// {userId && joinStatus[group.group_id] === '加入成功' && (
-// <button onClick={() => setShowCreatePost(!showCreatePost)}>
-// +发布帖子
-// </button>
-// )}
-// </div>
-// </div>
-
-// <div className="group-description">
-// <p>{group.description}</p>
-// </div>
-// <p>分类:{group.category}</p>
-
-// {showCreatePost && (
-// <CreatePostForm
-// groupId={group.group_id}
-// onClose={() => setShowCreatePost(false)}
-// />
-// )}
-// </div>
-// );
-// };
-
-// export default GroupItem;
-
-
import React, { useState } from 'react';
import { useGroupStore } from '../../context/useGroupStore';
import { useUser } from '../../context/UserContext';
@@ -76,7 +20,7 @@
<div className="group-content">
<img
style={{ width: '40%', height: '40%' }}
- src={group.cover_image || 'https://picsum.photos/200/200'}
+ src={group.coverImage || 'https://picsum.photos/200/200'}
alt={group.groupName}
className="group-cover"
/>
@@ -115,64 +59,4 @@
);
};
-export default GroupItem;
-
-
-// import React, { useState } from 'react';
-// import { useGroupStore } from '../../context/useGroupStore';
-// import { useUser } from '../../context/UserContext';
-// import CreatePostForm from './CreatePostForm';
-
-// const GroupItem = ({ group }) => {
-// console.log('group:', group);
-
-// const { handleJoinGroup, joinStatus } = useGroupStore();
-// const { user } = useUser();
-// const userId = user?.userId; // 确保使用正确的字段名(取自 localStorage 的结构)
-// const [showCreatePost, setShowCreatePost] = useState(false);
-
-// return (
-// <div className="group-item">
-// <div className="group-content">
-// <img
-// style={{ width: '40%', height: '40%' }}
-// src={group.cover_image || 'https://picsum.photos/200/200'}
-// alt={group.name}
-// className="group-cover"
-// />
-// <div className="group-info-right">
-// <h3>{group.name}</h3>
-// <p style={{ color: '#BA929A' }}>{group.member_count || 0}人加入了小组</p>
-
-// <button
-// onClick={() => handleJoinGroup(group.group_id, userId)}
-// disabled={joinStatus[group.group_id] === '加入成功' || !userId}
-// >
-// {joinStatus[group.group_id] === '加入成功' ? '已加入' : userId ? '+加入小组' : '请登录'}
-// </button>
-
-// {userId && joinStatus[group.group_id] === '加入成功' && (
-// <button onClick={() => setShowCreatePost(!showCreatePost)}>
-// +发布帖子
-// </button>
-// )}
-// </div>
-// </div>
-
-// <div className="group-description">
-// <p>{group.description}</p>
-// </div>
-// <p>分类:{group.category}</p>
-
-// {showCreatePost && (
-// <CreatePostForm
-// groupId={group.group_id}
-// onClose={() => setShowCreatePost(false)}
-// />
-// )}
-// </div>
-// );
-// };
-
-// export default GroupItem;
-
+export default GroupItem;
\ No newline at end of file