From 9cb4ce6cb1d98cd2764c6fb80f012af2a27e6c84 Mon Sep 17 00:00:00 2001 From: "Nikolai A." Date: Wed, 2 Sep 2026 13:40:36 +0000 Subject: [PATCH] refactor: simplify side menu layout and drag-and-drop logic (#7838) * refactor: remove duplicated list wrapper in side menu * refactor: simplify side menu layout and drag drop logic - Always render DragDropProvider and pass disabled prop to menu items - Remove redundant layout branches and unused sortable component --- src/pages/_layout.tsx | 89 ++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 61 deletions(-) diff --git a/src/pages/_layout.tsx b/src/pages/_layout.tsx index 4cf4eea07..505ffba04 100644 --- a/src/pages/_layout.tsx +++ b/src/pages/_layout.tsx @@ -47,35 +47,12 @@ import { navItems } from './_navigation' import 'dayjs/locale/ru' import 'dayjs/locale/zh-cn' -type NavItem = (typeof navItems)[number] - type MenuContextPosition = { top: number; left: number } -interface SortableNavMenuItemProps { - item: NavItem - label: string - index: number -} - -const SortableNavMenuItem = ({ - item, - label, - index, -}: SortableNavMenuItemProps) => { - return ( - - {(sortable) => ( - - {label} - - )} - - ) -} - dayjs.extend(relativeTime) const OS = getSystem() +const SENSORS = [PointerSensor, KeyboardSensor] const Layout = () => { const mode = useThemeMode() @@ -213,6 +190,27 @@ const Layout = () => { ) } + // Navigation menu items + const navMenuItems = menuOrder.map((path, index) => { + const item = navItemMap.get(path) + if (!item) return null + + return ( + + {(sortable) => ( + + {t(item.label)} + + )} + + ) + }) + return ( {/* 左侧底部窗口控制按钮 */} @@ -318,43 +316,12 @@ const Layout = () => { )} - {menuUnlocked ? ( - - - {menuOrder.map((path) => { - const item = navItemMap.get(path) - if (!item) { - return null - } - return ( - - ) - })} - - - ) : ( - - {menuOrder.map((path) => { - const item = navItemMap.get(path) - if (!item) { - return null - } - return ( - - {t(item.label)} - - ) - })} - - )} + {/* Navigation menu */} + + + {navMenuItems} + +