diff --git a/furniture-3d-system/src/app/supply-chain/components/SupplyChainSidebar.test.tsx b/furniture-3d-system/src/app/supply-chain/components/SupplyChainSidebar.test.tsx index d615a919..d352f6e7 100644 --- a/furniture-3d-system/src/app/supply-chain/components/SupplyChainSidebar.test.tsx +++ b/furniture-3d-system/src/app/supply-chain/components/SupplyChainSidebar.test.tsx @@ -5,6 +5,7 @@ const usePathnameMock = jest.fn() jest.mock('next/navigation', () => ({ usePathname: () => usePathnameMock(), + useRouter: () => ({ push: jest.fn(), refresh: jest.fn() }), })) describe('SupplyChainSidebar', () => { @@ -24,7 +25,7 @@ describe('SupplyChainSidebar', () => { ) expect(screen.getByRole('navigation', { name: '供应链导航' })).toBeInTheDocument() - const homeLink = screen.getByRole('link', { name: '首页' }) + const homeLink = screen.getByRole('button', { name: '首页' }) const workbenchLink = screen.getByRole('link', { name: '工作台' }) expect( homeLink.compareDocumentPosition(workbenchLink) & Node.DOCUMENT_POSITION_FOLLOWING, diff --git a/furniture-3d-system/src/components/layout/HomeQuickLinksNavItem.tsx b/furniture-3d-system/src/components/layout/HomeQuickLinksNavItem.tsx index ad8de425..c5089ac7 100644 --- a/furniture-3d-system/src/components/layout/HomeQuickLinksNavItem.tsx +++ b/furniture-3d-system/src/components/layout/HomeQuickLinksNavItem.tsx @@ -1,9 +1,8 @@ 'use client' import { useCallback, useEffect, useState } from 'react' -import { usePathname } from 'next/navigation' -import Link from 'next/link' -import { Home as HomeIcon, ChevronDown } from 'lucide-react' +import { usePathname, useRouter } from 'next/navigation' +import { Home as HomeIcon, ChevronDown, LayoutDashboard } from 'lucide-react' import { resolveHomeQuickLinkIcon } from '@/lib/home-quick-link-icons' import type { HomeQuickLinkDto } from '@/server/services/home-quick-links.service' @@ -11,8 +10,9 @@ export type HomeQuickLinksNavItemVariant = 'product' | 'supply-chain' /** * 左侧导航「首页」项(产品开发与供应链两个侧边栏共用): - * - 管理员配置了快捷网址时,点击「首页」展开/收起网址列表(点击网址新标签页跳转) - * - 没有配置时保持原行为:点击跳转首页工作台 + * - 管理员配置了快捷网址时,「首页」点击展开/收起网址列表(点击网址新标签页跳转), + * 其下新增「工作台」项指向原首页工作台选择页; + * - 没有配置时保持原行为:点击跳转首页工作台。 * 样式完全自包含,不依赖宿主侧边栏的全局类,保证两个侧边栏下表现一致。 */ export function HomeQuickLinksNavItem({ @@ -21,6 +21,7 @@ export function HomeQuickLinksNavItem({ variant?: HomeQuickLinksNavItemVariant }) { const pathname = usePathname() + const router = useRouter() const [links, setLinks] = useState([]) const [loaded, setLoaded] = useState(false) const [expanded, setExpanded] = useState(false) @@ -72,18 +73,32 @@ export function HomeQuickLinksNavItem({ /> ) : ( - router.push('/')} className={`home-quick-links-row ${active ? 'active' : ''}`} aria-current={active ? 'page' : undefined} > 首页 - + )} {hasLinks && expanded ? (