Skip to content

Commit

Permalink
feat: add course requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Okabe-Rintarou-0 committed Aug 2, 2024
1 parent c05d4a3 commit 250613e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
Binary file added public/requirements.pdf
Binary file not shown.
6 changes: 5 additions & 1 deletion src/components/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link, useNavigate } from "react-router-dom";
import { useEffect, useState } from "react";
import { getMe } from "../service/user";
import { UserContext } from "../lib/context";
import useMessage from "antd/es/message/useMessage";

export function BasicLayout({ children }) {
return (
Expand All @@ -26,12 +27,14 @@ export function BasicLayout({ children }) {
export function PrivateLayout({ children }) {
const [user, setUser] = useState(null);
const navigate = useNavigate();
const [messageApi, contextHolder] = useMessage();

useEffect(() => {
const checkLogin = async () => {
let me = await getMe();
if (!me) {
navigate("/login");
messageApi.error("无权访问当前页面,请先登录!", 0.6)
.then(() => navigate("/login"));
} else {
setUser(me);
}
Expand All @@ -41,6 +44,7 @@ export function PrivateLayout({ children }) {

return (
<Layout className="basic-layout">
{contextHolder}
<Header className="header"><NavBar user={user} /></Header>
<Content>
<UserContext.Provider value={{ user, setUser }}>{user && children}</UserContext.Provider>
Expand Down
3 changes: 2 additions & 1 deletion src/components/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default function NavBar({ user }) {
{ label: "购物车", value: "/cart" },
{ label: "订单", value: "/order" },
{ label: "排行", value: "/rank" },
{ label: "后端 API 文档", value: "/api-docs" }
{ label: "后端 API 文档", value: "/api-docs" },
{ label: "课程", value: "/course" }
];
const navMenuItems = navItems.map(item => ({
key: item.value,
Expand Down
2 changes: 2 additions & 0 deletions src/components/router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import RankPage from "../page/rank";
import ApiPage from "../page/api";
import ProfilePage from "../page/profile";
import OtherUserProfilePage from "../page/other_profile";
import CoursePage from "../page/course";

export default function AppRouter() {
return <BrowserRouter>
Expand All @@ -18,6 +19,7 @@ export default function AppRouter() {
<Route path="/cart" element={<CartPage />} />
<Route path="/order" element={<OrderPage />} />
<Route path="/rank" element={<RankPage />} />
<Route path="/course" element={<CoursePage />} />
<Route path="/profile" element={<ProfilePage />} />
<Route path="/profile/:id" element={<OtherUserProfilePage />} />
<Route path="/api-docs" element={<ApiPage />} />
Expand Down
25 changes: 25 additions & 0 deletions src/page/course.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Card, Space } from "antd";
import { BasicLayout } from "../components/layout";

export default function CoursePage() {
return <BasicLayout>
<Card className="card-container">
<Space direction="vertical" style={{ width: "100%" }} size={2}>
<h3>技术栈</h3>
<ul>
<li>
前端:React, HTML, Javascript/Typescript, CSS
</li>
<li>
后端:Java, Spring Boot
</li>
<li>
数据库:MySQL, MongoDB, Neo4j
</li>
</ul>
<h3>课程要求</h3>
<iframe src="requirements.pdf" width="100%" height="600px" />
</Space>
</Card >
</BasicLayout >
}

0 comments on commit 250613e

Please sign in to comment.