diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index f46afd5..ccb29cc 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -9,7 +9,7 @@ import { IoSettings } from 'react-icons/io5' import routes from '@renderer/routes' import { DndContext, - closestCenter, + closestCorners, PointerSensor, useSensor, useSensors, @@ -111,8 +111,25 @@ const App: React.FC = () => { newOrder.splice(overIndex, 0, active.id as string) setOrder(newOrder) await patchAppConfig({ siderOrder: newOrder }) + return } } + navigate(navigateMap[active.id as string]) + } + + const navigateMap = { + sysproxy: "sysproxy", + tun: "tun", + profile: "profiles", + proxy: "proxies", + mihomo: "mihomo", + connection: "connections", + dns: "dns", + sniff: "sniffer", + log: "logs", + rule: "rules", + resource: "resources", + override: "override" } const componentMap = { @@ -158,13 +175,9 @@ const App: React.FC = () => {
- +
- { - return x - })} - > + {order.map((key: string) => { return componentMap[key] })} diff --git a/src/renderer/src/components/sider/conn-card.tsx b/src/renderer/src/components/sider/conn-card.tsx index 3619461..10b532a 100644 --- a/src/renderer/src/components/sider/conn-card.tsx +++ b/src/renderer/src/components/sider/conn-card.tsx @@ -1,6 +1,6 @@ import { Button, Card, CardBody, CardFooter } from '@nextui-org/react' import { FaCircleArrowDown, FaCircleArrowUp } from 'react-icons/fa6' -import { useLocation, useNavigate } from 'react-router-dom' +import { useLocation } from 'react-router-dom' import { calcTraffic } from '@renderer/utils/calc' import { useEffect, useState } from 'react' import { useSortable } from '@dnd-kit/sortable' @@ -21,7 +21,6 @@ const ConnCard: React.FC = () => { const { theme = 'system', systemTheme = 'dark' } = useTheme() const { appConfig } = useAppConfig() const { showTraffic, connectionCardStatus = 'col-span-2' } = appConfig || {} - const navigate = useNavigate() const location = useLocation() const match = location.pathname.includes('/connections') @@ -178,12 +177,11 @@ const ConnCard: React.FC = () => { <> navigate('/connections')} + ref={setNodeRef} {...attributes} {...listeners} + className={`${match ? 'bg-primary' : 'hover:bg-primary/30'} ${isDragging ? 'scale-[0.97] tap-highlight-transparent' : ''}`} > -
+