Add dynamic menu. Add slogan to home page #8
@@ -1,6 +1,7 @@
|
||||
import React, { createContext } from 'react'
|
||||
import '@/assets/css/header.scss'
|
||||
import LoadingMask from '@/components/LoadingMask.tsx'
|
||||
import router from '@/router'
|
||||
|
||||
export const MainFrameworkContext = createContext<{
|
||||
navbarHiddenState: {
|
||||
@@ -16,6 +17,8 @@ export const MainFrameworkContext = createContext<{
|
||||
|
||||
const MainFramework: React.FC = () => {
|
||||
const [navbarHidden, setNavbarHidden] = useState(false)
|
||||
const routeId = useMatches()[1].id
|
||||
const routeChildren = router.routes[0].children?.find((value) => value.id === routeId)?.children
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -26,36 +29,20 @@ const MainFramework: React.FC = () => {
|
||||
</a>
|
||||
<nav>
|
||||
<ul className={'menu'}>
|
||||
{routeChildren?.map((route) => {
|
||||
return (
|
||||
<li className={'item'}>
|
||||
<NavLink
|
||||
to={''}
|
||||
to={route.path ?? ''}
|
||||
className={({ isActive, isPending }) =>
|
||||
isPending ? 'pending' : isActive ? 'active' : ''
|
||||
}
|
||||
>
|
||||
主页
|
||||
</NavLink>
|
||||
</li>
|
||||
<li className={'item'}>
|
||||
<NavLink
|
||||
to={'https://blog.fatweb.top'}
|
||||
className={({ isActive, isPending }) =>
|
||||
isPending ? 'pending' : isActive ? 'active' : ''
|
||||
}
|
||||
>
|
||||
博客
|
||||
</NavLink>
|
||||
</li>
|
||||
<li className={'item'}>
|
||||
<NavLink
|
||||
to={'project'}
|
||||
className={({ isActive, isPending }) =>
|
||||
isPending ? 'pending' : isActive ? 'active' : ''
|
||||
}
|
||||
>
|
||||
App
|
||||
{(route.handle as RouteHandle).name}
|
||||
</NavLink>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
@@ -25,6 +25,17 @@ const routes: RouteObject[] = [
|
||||
id: 'home',
|
||||
Component: React.lazy(() => import('@/components/Home')),
|
||||
handle: {
|
||||
name: '主页',
|
||||
menu: true,
|
||||
auth: false
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'https://blog.fatweb.top',
|
||||
id: 'blog',
|
||||
handle: {
|
||||
name: '博客',
|
||||
menu: true,
|
||||
auth: false
|
||||
}
|
||||
},
|
||||
@@ -33,6 +44,8 @@ const routes: RouteObject[] = [
|
||||
id: 'project',
|
||||
Component: React.lazy(() => import('@/components/Project')),
|
||||
handle: {
|
||||
name: '项目',
|
||||
menu: true,
|
||||
auth: false
|
||||
}
|
||||
}
|
||||
|
||||
17
src/vite-env.d.ts
vendored
17
src/vite-env.d.ts
vendored
@@ -1,12 +1,14 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
type Captcha = {
|
||||
value: string
|
||||
base64Src: string
|
||||
type RouteHandle = {
|
||||
name?: string
|
||||
menu?: boolean
|
||||
auth?: boolean
|
||||
}
|
||||
|
||||
type RouteHandle = {
|
||||
auth: boolean
|
||||
interface FitFullscreenProps extends PropsWithChildren {
|
||||
zIndex?: number
|
||||
backgroundColor?: string
|
||||
}
|
||||
|
||||
type _Response<T> = {
|
||||
@@ -15,6 +17,11 @@ type _Response<T> = {
|
||||
data: T | null
|
||||
}
|
||||
|
||||
type Captcha = {
|
||||
value: string
|
||||
base64Src: string
|
||||
}
|
||||
|
||||
type Token = {
|
||||
token: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user