fix: restore admin sidebar routing
This commit is contained in:
1 parent
1e87be31da
commit
7353d140b8
1 file changed
+4
-6
@@ -1,5 +1,5 @@
|
|||||||
import { Suspense, useEffect, useState } from 'react'
|
import { Suspense, useEffect, useState } from 'react'
|
||||||
import { Outlet, useNavigate, useLocation , useOutlet } from 'react-router-dom'
|
import { Outlet, useNavigate, useLocation } from 'react-router-dom'
|
||||||
import { Layout, Menu, Button, Typography } from 'antd'
|
import { Layout, Menu, Button, Typography } from 'antd'
|
||||||
import {
|
import {
|
||||||
DashboardOutlined, VideoCameraOutlined, PlusOutlined, MonitorOutlined,
|
DashboardOutlined, VideoCameraOutlined, PlusOutlined, MonitorOutlined,
|
||||||
@@ -36,11 +36,9 @@ export default function AdminLayout() {
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
function navigateWithTransition(path: string) {
|
function navigateWithTransition(path: string) {
|
||||||
const startViewTransition = (document as unknown as { startViewTransition?: (callback: () => void) => void }).startViewTransition
|
if (path !== location.pathname) navigate(path)
|
||||||
if (startViewTransition) startViewTransition(() => navigate(path))
|
|
||||||
else navigate(path)
|
|
||||||
}
|
}
|
||||||
const outlet = useOutlet()
|
|
||||||
|
|
||||||
const selectedKey = menuItems.find(
|
const selectedKey = menuItems.find(
|
||||||
item => location.pathname === item.key || (location.pathname === '/' && item.key === '/admin')
|
item => location.pathname === item.key || (location.pathname === '/' && item.key === '/admin')
|
||||||
@@ -85,7 +83,7 @@ export default function AdminLayout() {
|
|||||||
</Header>
|
</Header>
|
||||||
<Content style={{ padding: 40, overflow: 'auto' }}>
|
<Content style={{ padding: 40, overflow: 'auto' }}>
|
||||||
<div className="admin-page-transition" key={location.pathname}>
|
<div className="admin-page-transition" key={location.pathname}>
|
||||||
{outlet}
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
</Content>
|
</Content>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|||||||
Reference in new issue
Block a user