帖子分类

Change-Id: I17bafbfe3c1c8fd26c1e12499cb3c17cd1738e23
diff --git a/src/components/navbar/navbar.tsx b/src/components/navbar/navbar.tsx
index a6c1fe7..a305521 100644
--- a/src/components/navbar/navbar.tsx
+++ b/src/components/navbar/navbar.tsx
@@ -1,4 +1,4 @@
-import React, { use } from "react";
+import React, { use, useEffect } from "react";
 import Icon, {
     HomeOutlined,
 } from "@ant-design/icons";
@@ -8,12 +8,12 @@
 import { Menu } from 'antd';
 import { useState } from "react";
 import style from './navbar.module.css'
-
+import { set } from "lodash";
+import { useNavigate } from "react-router";
 
 type CustomIconComponentProps = GetProps<typeof Icon>;
 type MenuItem = Required<MenuProps>['items'][number];
 const web_base_url = process.env.WEB_BASE_URL || 'http://localhost:3000';
-
 const VideoSvg = () => (
     <svg width="1em" height="1em" fill="currentColor" xmlns="http://www.w3.org/2000/svg" p-id="7331" viewBox="0 0 1024 1024">
       <title>video icon</title>
@@ -63,7 +63,6 @@
     <Icon component={ChatSvg} {...props} />
 );
 
-
 const items: MenuItem[] = [
 {
     key: 'home',
@@ -78,7 +77,7 @@
     key: 'video',
     icon: <VideoIcon />,
     label: (
-    <a href={{web_base_url}+'/posts?type=video'}>
+    <a href={'/posts?type=video'}>
         影视
     </a>
     ),
@@ -87,7 +86,7 @@
     key: 'music',
     icon: <MusicIcon />,
     label: (
-    <a href={{web_base_url}+'/posts?type=music'}>
+    <a href={'/posts?type=music'}>
         音乐
     </a>
     ),
@@ -96,7 +95,7 @@
     key: 'game',
     icon: <GameIcon />,
     label: (
-    <a href={{web_base_url}+'/posts?type=game'}>
+    <a href={'/posts?type=game'}>
         游戏
     </a>
     ),
@@ -105,7 +104,7 @@
     key: 'software',
     icon: <SoftwareIcon />,
     label: (
-    <a href={{web_base_url}+'/posts?type=software'}>
+    <a href={'/posts?type=software'}>
         软件
     </a>
     ),
@@ -114,20 +113,27 @@
     key: 'chat',
     icon: <ChatIcon />,
     label: (
-    <a href={{web_base_url}+'/posts?type=chat'}>
+    <a href={'/posts?type=chat'}>
         聊天
     </a>
     ),
 },
 ];
 
+interface NavbarProps {
+    current?: string;
+}
 
 
 
-
-const Navbar: React.FC = () => {
+const Navbar: React.FC<NavbarProps> = (props) => {
     const [current, setCurrent] = useState('home');
-
+    useEffect(() => {
+        console.log('current:', props.current);
+        if (props.current) {
+            setCurrent(props.current);
+        }
+    },[props.current]);
     const onClick: MenuProps['onClick'] = (e) => {
         console.log('click ', e);
         setCurrent(e.key);