- 初始化项目
- 添加登录注册功能
Change-Id: I4ceb5400dca3042f2f31232eaf246df83d57b9be
登录注册
Change-Id: Ibd4868d02f2f2b51b9cf645c5b56cb31adae6a1d
登录注册
Change-Id: Iee4aca2a0871ab46a95208ece13053e92b615b2e
login and register
Change-Id: Idb1ca43081e39c982a508b36ab1d80907b63a412
diff --git a/src/pages/AuthPage.jsx b/src/pages/AuthPage.jsx
new file mode 100644
index 0000000..e5effe1
--- /dev/null
+++ b/src/pages/AuthPage.jsx
@@ -0,0 +1,19 @@
+import React, { useState } from 'react';
+import Login from '../components/Auth/Login';
+import Register from '../components/Auth/Register';
+
+const AuthPage = () => {
+ const [isRegister, setIsRegister] = useState(false);
+
+ return (
+ <div>
+ {isRegister ? (
+ <Register onLoginClick={() => setIsRegister(false)} />
+ ) : (
+ <Login onRegisterClick={() => setIsRegister(true)} />
+ )}
+ </div>
+ );
+};
+
+export default AuthPage;
\ No newline at end of file
diff --git a/src/pages/AuthPage.test.jsx b/src/pages/AuthPage.test.jsx
new file mode 100644
index 0000000..e398536
--- /dev/null
+++ b/src/pages/AuthPage.test.jsx
@@ -0,0 +1,31 @@
+import React from 'react';
+import { render, screen, fireEvent } from '@testing-library/react';
+import AuthPage from './AuthPage';
+
+describe('AuthPage component', () => {
+ test('switches between login and register forms', () => {
+ render(<AuthPage />);
+
+ const registerButton = screen.getByText('点击注册');
+ fireEvent.click(registerButton);
+
+ const usernameInput = screen.getByPlaceholderText('请输入用户名');
+ const passwordInput = screen.getByPlaceholderText('请输入密码');
+ const emailInput = screen.getByPlaceholderText('请输入邮箱');
+
+ expect(usernameInput).toBeInTheDocument();
+ expect(passwordInput).toBeInTheDocument();
+ expect(emailInput).toBeInTheDocument();
+
+ const loginButton = screen.getByText('点击登录');
+ fireEvent.click(loginButton);
+
+ const loginUsernameInput = screen.getByPlaceholderText('请输入用户名');
+ const loginPasswordInput = screen.getByPlaceholderText('请输入密码');
+ const loginSubmitButton = screen.getByText('登录');
+
+ expect(loginUsernameInput).toBeInTheDocument();
+ expect(loginPasswordInput).toBeInTheDocument();
+ expect(loginSubmitButton).toBeInTheDocument();
+ });
+});
\ No newline at end of file
diff --git a/src/pages/ForumPage.css b/src/pages/ForumPage.css
new file mode 100644
index 0000000..af6bd75
--- /dev/null
+++ b/src/pages/ForumPage.css
@@ -0,0 +1,28 @@
+.forum-container {
+ padding: 20px;
+ background-color: #c13a3a;
+ }
+
+ .forum-post {
+ margin-bottom: 20px;
+ padding: 15px;
+ background-color: #06e7b6;
+ border: 1px solid #a70dc2;
+ border-radius: 5px;
+ }
+
+ .forum-post h2 {
+ margin: 0 0 10px;
+ }
+
+ .forum-post img {
+ max-width: 100%;
+ height: auto;
+ margin-top: 10px;
+ }
+
+ .forum-comment {
+ padding: 10px;
+ background-color: #9ae815;
+ border-radius: 5px;
+ }
\ No newline at end of file
diff --git a/src/pages/ForumPage.jsx b/src/pages/ForumPage.jsx
new file mode 100644
index 0000000..9734ab5
--- /dev/null
+++ b/src/pages/ForumPage.jsx
@@ -0,0 +1,19 @@
+import React from 'react';
+import './ForumPage.css';
+
+const ForumPage = () => {
+ return (
+ <div className="forum-container">
+ <h1>论坛</h1>
+ <div className="forum-post">
+ <h2>示例帖子标题</h2>
+ <p>这是一个示例帖子内容,用于测试论坛页面的显示效果。</p>
+ </div>
+ <div className="forum-comment">
+ <p>示例评论内容:这是一条测试评论。</p>
+ </div>
+ </div>
+ );
+};
+
+export default ForumPage;
\ No newline at end of file
diff --git a/src/pages/HomePage.jsx b/src/pages/HomePage.jsx
new file mode 100644
index 0000000..9f3b9ef
--- /dev/null
+++ b/src/pages/HomePage.jsx
@@ -0,0 +1,12 @@
+// src/pages/HomePage.jsx
+import React from 'react';
+
+const HomePage = () => {
+ return (
+ <div>
+ <h1>主页</h1>
+ </div>
+ );
+};
+
+export default HomePage;
\ No newline at end of file