| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2025-01-17 20:13:54 |
| 4 | * @LastEditTime: 2025-01-21 16:22:55 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: |
| 7 | */ |
| 8 | import { Link, useLocation } from 'react-router-dom'; |
| 9 | import logo from '@/assets/logo.png'; |
| 10 | import styles from './navigation.module.scss'; |
| 11 | import { router } from '@/router'; |
| 12 | import SysMenu from '../SysMenu'; |
| 13 | import { useEffect, useState, useRef } from 'react'; |
| 14 | import { ipcAppInfo } from '../../icp/app'; |
| 15 | import Windowcontrolbuttons from '../../components/WindowControlButtons/WindowControlButtons'; |
| 16 | import Bellmessage from '../BellMessage'; |
| 17 | import { BellOutlined } from '@ant-design/icons'; |
| 18 | import { Popover } from 'antd'; |
| 19 | import SignInCard from '@/components/SignInCard'; |
| 20 | import treeSvg from '@/assets/svgs/tree.svg'; |
| 21 | |
| 22 | const Navigation = () => { |
| 23 | const location = useLocation(); |
| 24 | const [pathname, setPathname] = useState('/'); |
| 25 | const [platform, setPlatform] = useState(''); |
| 26 | |
| 27 | const signInCardRef = useRef<any>(null); |
| 28 | |
| 29 | useEffect(() => { |
| 30 | setPathname('/' + (location.pathname.split('/')[1] || '')); |
| 31 | }, [location]); |
| 32 | |
| 33 | useEffect(() => { |
| 34 | ipcAppInfo().then((res) => { |
| 35 | setPlatform(res.platform); |
| 36 | }); |
| 37 | }, []); |
| 38 | |
| 39 | return ( |
| 40 | <nav className={`${styles.navigation} ${styles['navigation-' + platform]}`}> |
| 41 | <div className="navigation_left"> |
| 42 | <div className="navigation-logo"> |
| 43 | <img src={logo} alt="哎哟赚AiToEarn" className="w-9 h-9" /> |
| 44 | <span>哎哟赚AiToEarn</span> |
| 45 | </div> |
| 46 | |
| 47 | <ul className="navigation-list"> |
| 48 | {router[0].children && |
| 49 | router[0].children.map((v) => { |
| 50 | if (!v.meta) return; |
| 51 | const IconComponent = v.meta!.icon!; |
| 52 | return ( |
| 53 | <li |
| 54 | className={[ |
| 55 | 'navigation-list-item', |
| 56 | pathname === v.path && 'navigation-list-item--active', |
| 57 | ].join(' ')} |
| 58 | key={v.meta!.name} |
| 59 | > |
| 60 | <Link to={v.path || '/'}> |
| 61 | <IconComponent /> |
| 62 | <span className="navigation-list-text">{v.meta!.name}</span> |
| 63 | </Link> |
| 64 | </li> |
| 65 | ); |
| 66 | })} |
| 67 | </ul> |
| 68 | </div> |
| 69 | |
| 70 | <div className="navigation_drag" /> |
| 71 | |
| 72 | <div className="navigation-userinfo"> |
| 73 | <Popover |
| 74 | content={<SignInCard ref={signInCardRef} />} |
| 75 | trigger="hover" |
| 76 | placement="bottom" |
| 77 | onOpenChange={(open) => { |
| 78 | if (open) { |
| 79 | signInCardRef.current?.fetchSignInList(); |
| 80 | } |
| 81 | }} |
| 82 | > |
| 83 | <div className="navigation-icon"> |
| 84 | <img |
| 85 | src={treeSvg} |
| 86 | alt="小树苗" |
| 87 | style={{ width: 20, height: 20, verticalAlign: 'middle' }} |
| 88 | /> |
| 89 | <span className="navigation-icon-text">小树苗</span> |
| 90 | </div> |
| 91 | </Popover> |
| 92 | <div className="navigation-line"></div> |
| 93 | |
| 94 | <Bellmessage> |
| 95 | <div className="navigation-icon"> |
| 96 | <BellOutlined /> |
| 97 | <span className="navigation-icon-text">消息</span> |
| 98 | </div> |
| 99 | </Bellmessage> |
| 100 | |
| 101 | <div className="navigation-line"></div> |
| 102 | <SysMenu /> |
| 103 | <div className="navigation-line"></div> |
| 104 | </div> |
| 105 | |
| 106 | <Windowcontrolbuttons /> |
| 107 | </nav> |
| 108 | ); |
| 109 | }; |
| 110 | |
| 111 | export default Navigation; |
| 112 |