- 初始化项目
- 添加登录注册功能
Change-Id: I4ceb5400dca3042f2f31232eaf246df83d57b9be
登录注册
Change-Id: Iee4aca2a0871ab46a95208ece13053e92b615b2e
init main page
Change-Id: I6c59617a37bbe71f115a43beb884c8596fb29c39
init main page, fix bug
Change-Id: I3eba8d45f017bbf303eb7462f305b5ca5661342f
首页
Change-Id: I7f6798780864af433b54f1c73721f631900d87f5
首页
Change-Id: I8368ab349bfa014ab306d0bf4bd4ced0e361cdd5
diff --git a/src/pages/MainPage/MainPage.css b/src/pages/MainPage/MainPage.css
new file mode 100644
index 0000000..60f2956
--- /dev/null
+++ b/src/pages/MainPage/MainPage.css
@@ -0,0 +1,88 @@
+.main-page {
+ background-color: #5c3f31;
+ color: white;
+ }
+ .header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 10px;
+ }
+ .logo-and-name {
+ display: flex;
+ align-items: center;
+ }
+ .logo {
+ height: 30px;
+ margin-right: 10px;
+ }
+ .site-name {
+ font-size: 24px;
+ }
+ .user-and-message {
+ display: flex;
+ align-items: center;
+ }
+ .user-avatar {
+ height: 40px;
+ margin-right: 10px;
+ }
+ .message-center {
+ font-size: 16px;
+ }
+ .nav {
+ background-color: #b38867;
+ display: flex;
+ justify-content: center;
+ }
+ .nav-item {
+ color: white;
+ text-decoration: none;
+ padding: 10px 20px;
+ }
+ .active {
+ background-color: #996633;
+ }
+ .content {
+ padding: 20px;
+ }
+ .user-post {
+ border-bottom: 1px solid white;
+ margin-bottom: 20px;
+ padding-bottom: 20px;
+ }
+ .user-info {
+ display: flex;
+ align-items: center;
+ margin-bottom: 10px;
+ }
+ .user-avatar-small {
+ height: 30px;
+ margin-right: 10px;
+ }
+ .username {
+ font-size: 16px;
+ }
+ .post-content {
+ margin-bottom: 10px;
+ }
+ .post-actions {
+ display: flex;
+ align-items: center;
+ margin-bottom: 10px;
+ }
+ .like-icon,
+ .comment-icon {
+ margin-right: 5px;
+ }
+ .like-count,
+ .comment-count {
+ margin-left: 5px;
+ }
+ .post-image {
+ float: right;
+ width: 150px;
+ height: 150px;
+ background-color: #ddd;
+ margin-left: 10px;
+ }
\ No newline at end of file
diff --git a/src/pages/MainPage/MainPage.jsx b/src/pages/MainPage/MainPage.jsx
new file mode 100644
index 0000000..1dad401
--- /dev/null
+++ b/src/pages/MainPage/MainPage.jsx
@@ -0,0 +1,55 @@
+import React from 'react';
+import './MainPage.css'; // 可创建对应样式文件来完善样式
+import { Link } from 'wouter'; // Use wouter's Link component
+// import '@icon-park/react/styles/index.css';
+// import { GoodTwo, Comment } from '@icon-park/react';
+
+const MainPage = () => {
+ return (
+ <div className="main-page">
+ {/* 顶部栏 */}
+ <header className="header">
+ {/* 左侧logo和网站名称 */}
+ <div className="logo-and-name">
+ <img src="logo.png" alt="网站logo" className="logo" />
+ <span className="site-name">Echo</span>
+ </div>
+ {/* 右侧用户头像和消息中心 */}
+ <div className="user-and-message">
+ <img src="user-avatar.png" alt="用户头像" className="user-avatar" />
+ <span className="message-center">消息</span>
+ </div>
+ </header>
+ {/* 导航栏 */}
+ <nav className="nav">
+ <Link to="/friend-moments" className="nav-item active">好友动态</Link>
+ <Link to="/forum" className="nav-item">论坛</Link>
+ <Link to="/interest-groups" className="nav-item">兴趣小组</Link>
+ <Link to="/seed-list" className="nav-item">种子列表</Link>
+ <Link to="/publish-seed" className="nav-item">发布种子</Link>
+ </nav>
+ {/* 好友动态内容区域 */}
+ <div className="content">
+ {/* 用户动态示例,可从后端获取数据循环展示 */}
+ <div className="user-post">
+ <div className="user-info">
+ <img src="user1-avatar.png" alt="用户头像" className="user-avatar-small" />
+ <span className="username">user1</span>
+ </div>
+ <div className="post-content">
+ <p>动态内容...</p>
+ </div>
+ <div className="post-actions">
+ {/* <GoodTwo theme="outline" size="24" fill="#fff" /> */}
+ <span className="like-count">21</span>
+ {/* <Comment theme="outline" size="24" fill="#fff"/> */}
+ <span className="comment-count">2</span>
+ </div>
+ <img src="image1.png" alt="动态图片" className="post-image" />
+ </div>
+ </div>
+ </div>
+ );
+};
+
+export default MainPage;
diff --git a/src/pages/MainPage/MainPage.test.js b/src/pages/MainPage/MainPage.test.js
new file mode 100644
index 0000000..651f9c6
--- /dev/null
+++ b/src/pages/MainPage/MainPage.test.js
@@ -0,0 +1,42 @@
+import { render, screen } from '@testing-library/react';
+import { Router } from 'wouter'; // 使用 wouter 的 Router
+import MainPage from './MainPage'; // 导入 MainPage 组件
+
+test('renders MainPage with logo, navigation links, and user post', () => {
+ render(
+ <Router>
+ <MainPage />
+ </Router>
+ );
+
+ // 检查页面中是否有 Echo 站点名称
+ const siteNameElement = screen.getByText(/Echo/i);
+ expect(siteNameElement).toBeInTheDocument();
+
+ // 检查页面中是否有导航栏中的链接
+ const friendMomentsLink = screen.getByText(/好友动态/i);
+ const forumLink = screen.getByText(/论坛/i);
+ const interestGroupsLink = screen.getByText(/兴趣小组/i);
+ const seedListLink = screen.getByText(/种子列表/i);
+ const publishSeedLink = screen.getByText(/发布种子/i);
+
+ expect(friendMomentsLink).toBeInTheDocument();
+ expect(forumLink).toBeInTheDocument();
+ expect(interestGroupsLink).toBeInTheDocument();
+ expect(seedListLink).toBeInTheDocument();
+ expect(publishSeedLink).toBeInTheDocument();
+
+ // 检查页面中是否有用户动态信息
+ const usernameElement = screen.getByText(/user1/i);
+ expect(usernameElement).toBeInTheDocument();
+
+ const postContentElement = screen.getByText(/动态内容.../i);
+ expect(postContentElement).toBeInTheDocument();
+
+ // 使用更精确的查询来获取喜欢数和评论数
+ const likeCountElement = screen.getByText('21');
+ const commentCountElement = screen.getByText('2');
+
+ expect(likeCountElement).toBeInTheDocument();
+ expect(commentCountElement).toBeInTheDocument();
+});