Skip to content

Let's use AI to Earn!

feat: 导航优化

gaoSir3e17ea7500f5
diff --git a/src/layout/Navigation/index.tsx b/src/layout/Navigation/index.tsx
index 6fa45ccd..92c9ff2f 100644
--- a/src/layout/Navigation/index.tsx
+++ b/src/layout/Navigation/index.tsx
@@ -5,36 +5,45 @@
* @LastEditors: nevin
* @Description:
*/
-import { Link } from 'react-router-dom';
-import logo from '@/assets/logo.png'; // 请确保这个路径指向您的 logo 图片
+import { Link, useLocation } from 'react-router-dom';
+import logo from '@/assets/logo.png';
import styles from './navigation.module.scss';
import { router } from '@/router';
import SysMenu from '../SysMenu';
+import { useEffect, useState } from 'react';
const Navigation = () => {
+ const location = useLocation();
+ const [pathname, setPathname] = useState('/');
+
+ useEffect(() => {
+ setPathname('/' + (location.pathname.split('/')[1] || ''));
+ }, [location]);
+
return (
- <nav className={`flex-none text-white shadow-md ${styles.navigation}`}>
- <div className="flex items-center h-16" style={{ padding: '0 2.5rem' }}>
- <div className="flex items-center mr-12 space-x-3">
+ <nav className={styles.navigation}>
+ <div className="navigation_left">
+ <div className="navigation-logo">
<img src={logo} alt="爱团团AiToEarn" className="w-9 h-9" />
- <span className="text-xl font-semibold tracking-wide text-white">
- 爱团团AiToEarn
- </span>
+ <span>爱团团AiToEarn</span>
</div>
- <ul className="flex items-center h-full space-x-2">
+ <ul className="navigation-list">
{router[0].children &&
router[0].children.map((v) => {
if (!v.meta) return;
const IconComponent = v.meta!.icon!;
return (
- <li className="h-full" key={v.meta!.name}>
- <Link
- to={v.path || '/'}
- className="flex items-center px-6 h-full hover:bg-white/10 transition-colors text-[15px]"
- >
- <IconComponent className="mr-2 text-lg text-white" />
- <span className="text-white">{v.meta!.name}</span>
+ <li
+ className={[
+ 'navigation-list-item',
+ pathname === v.path && 'navigation-list-item--active',
+ ].join(' ')}
+ key={v.meta!.name}
+ >
+ <Link to={v.path || '/'}>
+ <IconComponent />
+ <span className="navigation-list-text">{v.meta!.name}</span>
</Link>
</li>
);
diff --git a/src/layout/Navigation/navigation.module.scss b/src/layout/Navigation/navigation.module.scss
index 639985dd..e2340689 100644
--- a/src/layout/Navigation/navigation.module.scss
+++ b/src/layout/Navigation/navigation.module.scss
@@ -3,10 +3,53 @@
display: flex;
justify-content: space-between;
align-items: center;
+ padding: 0 15px;
:global {
.navigation-userinfo {
- margin-right: 25px;
+ }
+
+ .navigation_left {
+ display: flex;
+ align-items: center;
+ .navigation-logo {
+ color: #fff;
+ font-weight: 900;
+ display: flex;
+ align-items: center;
+ margin-right: 30px;
+ font-size: var(--fs-lg);
+ img {
+ margin-right: 4px;
+ }
+ }
+
+ .navigation-list {
+ display: flex;
+ &-text {
+ display: block;
+ margin-top: 3px;
+ }
+ &-item {
+ .anticon {
+ font-size: 20px;
+ }
+ a {
+ width: 88px;
+ box-sizing: border-box;
+ color: #fff;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ padding: 10px 15px;
+ font-size: var(--fs-sm);
+ }
+
+ &--active {
+ background: rgba(0, 0, 0, 0.05);
+ }
+ }
+ }
}
}
}
diff --git a/src/router/index.tsx b/src/router/index.tsx
index 4f5a7639..6ab3afd7 100644
--- a/src/router/index.tsx
+++ b/src/router/index.tsx
@@ -15,9 +15,11 @@ import { AntdIconProps } from '@ant-design/icons/lib/components/AntdIcon';
import {
CopyOutlined,
FireOutlined,
- // HomeOutlined,
- // InfoCircleOutlined,
- UserOutlined,
+ UsergroupAddOutlined,
+ ShopOutlined,
+ MessageOutlined,
+ AuditOutlined,
+ MoneyCollectOutlined,
} from '@ant-design/icons';
// 组件
@@ -30,6 +32,7 @@ import Trending from '@/views/trending';
import Account from '@/views/account';
import Publish from '@/views/publish/page';
import VideoPage from '@/views/publish/children/videoPage/page';
+import ImagePage from '@/views/publish/children/imagePage/page';
import PubRecord from '@/views/publish/children/pubRecord/page';
import Drafts from '@/views/publish/children/drafts/page';
import Statistics from '@/views/statistics';
@@ -82,7 +85,7 @@ export const router: CustomRouteObject[] = [
{
path: '/',
element: <Account />,
- meta: { name: '账户', icon: UserOutlined },
+ meta: { name: '账户', icon: UsergroupAddOutlined },
},
{
path: '/trending',
@@ -103,10 +106,10 @@ export const router: CustomRouteObject[] = [
meta: { name: '一键发布', icon: CopyOutlined },
children: [
{ path: 'video', element: <VideoPage /> },
- // {
- // path: 'image',
- // element: <ImagePage />,
- // },
+ {
+ path: 'image',
+ element: <ImagePage />,
+ },
// {
// path: 'text',
// element: <TextPage />,
@@ -118,22 +121,22 @@ export const router: CustomRouteObject[] = [
{
path: '/reply',
element: <Reply />,
- meta: { name: '评论', icon: UserOutlined },
+ meta: { name: '评论', icon: MessageOutlined },
},
{
path: '/statistics',
element: <Statistics />,
- meta: { name: '数据中心', icon: UserOutlined },
+ meta: { name: '数据中心', icon: AuditOutlined },
},
{
path: '/task',
element: <Task />,
- meta: { name: '任务市场', icon: UserOutlined },
+ meta: { name: '任务市场', icon: ShopOutlined },
},
{
path: '/finance',
element: <Finance />,
- meta: { name: '钱包', icon: UserOutlined },
+ meta: { name: '钱包', icon: MoneyCollectOutlined },
children: [
{ path: 'userWalletRecord', element: <UserWalletRecord /> },
{ path: 'userWalletAccount', element: <UserWalletAccount /> },
diff --git a/src/views/publish/children/imagePage/page.tsx b/src/views/publish/children/imagePage/page.tsx
index 44401239..7dc16abd 100644
--- a/src/views/publish/children/imagePage/page.tsx
+++ b/src/views/publish/children/imagePage/page.tsx
@@ -1,5 +1,11 @@
import styles from './image.module.scss';
+import { useShallow } from 'zustand/react/shallow';
+import { useImagePageStore } from './useImagePageStore';
export default function Page() {
- return <div className={styles.image}>图片发布</div>;
+ const {} = useImagePageStore(useShallow((state) => ({})));
+
+ return (
+ <div className={styles.image}>图片发布</div>
+ );
}
diff --git a/src/views/publish/children/imagePage/useImagePageStore.ts b/src/views/publish/children/imagePage/useImagePageStore.ts
new file mode 100644
index 00000000..60c6dc33
--- /dev/null
+++ b/src/views/publish/children/imagePage/useImagePageStore.ts
@@ -0,0 +1,19 @@
+import { create } from 'zustand';
+import { combine } from 'zustand/middleware';
+
+interface IVideoPageStore {}
+
+const store: IVideoPageStore = {};
+
+// 视频发布所有组件的共享状态和方法
+export const useImagePageStore = create(
+ combine(
+ {
+ ...store,
+ },
+ (set, get, storeApi) => {
+ const methods = {};
+ return methods;
+ },
+ ),
+);
diff --git a/src/views/publish/page.tsx b/src/views/publish/page.tsx
index 82583e8d..69fda505 100644
--- a/src/views/publish/page.tsx
+++ b/src/views/publish/page.tsx
@@ -6,7 +6,12 @@
* @Description:
*/
import styles from './publish.module.scss';
-import { VideoCameraOutlined, FileImageOutlined } from '@ant-design/icons';
+import {
+ VideoCameraOutlined,
+ FileImageOutlined,
+ HddOutlined,
+ ContainerOutlined,
+} from '@ant-design/icons';
import { message, Segmented } from 'antd';
import { Outlet, useLocation, useNavigate } from 'react-router-dom';
import { useEffect, useState } from 'react';
@@ -53,20 +58,20 @@ export default function Page() {
icon: <VideoCameraOutlined />,
},
// { label: '文章发布', value: '/publish/text', icon: <FileOutlined /> },
- // {
- // label: '图片发布',
- // value: '/publish/image',
- // icon: <FileImageOutlined />,
- // },
+ {
+ label: '图片发布',
+ value: '/publish/image',
+ icon: <FileImageOutlined />,
+ },
{
label: '发布记录',
value: '/publish/pubRecord',
- icon: <FileImageOutlined />,
+ icon: <ContainerOutlined />,
},
{
label: '草稿箱',
value: '/publish/drafts',
- icon: <FileImageOutlined />,
+ icon: <HddOutlined />,
},
]}
onChange={(value) => {