mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 05:51:56 +08:00
Fix: pass location search
This commit is contained in:
parent
d0f61c9c57
commit
81362b0816
@ -1,5 +1,5 @@
|
||||
import classnames from 'classnames'
|
||||
import { Route, Navigate, Routes } from 'react-router-dom'
|
||||
import { Route, Navigate, Routes, useLocation } from 'react-router-dom'
|
||||
|
||||
// import Overview from '@containers/Overview'
|
||||
import Connections from '@containers/Connections'
|
||||
@ -18,6 +18,8 @@ import '../styles/iconfont.scss'
|
||||
export default function App () {
|
||||
useLogsStreamReader()
|
||||
|
||||
const location = useLocation()
|
||||
|
||||
const routes = [
|
||||
// { path: '/', name: 'Overview', component: Overview, exact: true },
|
||||
{ path: '/proxies', name: 'Proxies', element: <Proxies /> },
|
||||
@ -32,7 +34,7 @@ export default function App () {
|
||||
<SideBar routes={routes} />
|
||||
<div className="page-container">
|
||||
<Routes>
|
||||
<Route path="/" element={<Navigate to="/proxies" replace />} />
|
||||
<Route path="/" element={<Navigate to={{ pathname: '/proxies', search: location.search }} replace />} />
|
||||
{
|
||||
routes.map(
|
||||
route => <Route path={route.path} key={route.path} element={route.element} />,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import classnames from 'classnames'
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import { NavLink, useLocation } from 'react-router-dom'
|
||||
|
||||
import logo from '@assets/logo.png'
|
||||
import { Lang, Language } from '@i18n'
|
||||
@ -20,11 +20,12 @@ export default function Sidebar (props: SidebarProps) {
|
||||
const { version, premium } = useVersion()
|
||||
const { data } = useClashXData()
|
||||
const { t } = translation('SideBar')
|
||||
const location = useLocation()
|
||||
|
||||
const navlinks = routes.map(
|
||||
({ path, name, noMobile }) => (
|
||||
<li className={classnames('item', { 'no-mobile': noMobile })} key={name}>
|
||||
<NavLink to={path} className={({ isActive }) => classnames({ active: isActive })}>
|
||||
<NavLink to={{ pathname: path, search: location.search }} className={({ isActive }) => classnames({ active: isActive })}>
|
||||
{ t(name as keyof typeof Language[Lang]['SideBar']) }
|
||||
</NavLink>
|
||||
</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user