fix(web): restore product navigation coverage
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 24s
CD Pipeline / build-and-deploy (push) Successful in 4m52s
CD Pipeline / post-deploy-checks (push) Successful in 58s

This commit is contained in:
Your Name
2026-06-30 02:39:51 +08:00
parent 320061af35
commit c04a72c2a6
9 changed files with 314 additions and 75 deletions

View File

@@ -15,7 +15,7 @@
import React, { useEffect, useRef, useState, useCallback } from 'react'
import { useTranslations } from 'next-intl'
import { useRouter, usePathname } from 'next/navigation'
import { useRouter } from 'next/navigation'
import { useLocale } from 'next-intl'
import {
Search,
@@ -26,6 +26,7 @@ import { Z_INDEX } from '@/lib/constants/z-index'
import {
PRODUCT_BOTTOM_NAV_ITEMS,
PRODUCT_NAV_SECTIONS,
type ProductNavItem,
} from '@/lib/navigation/product-ia'
interface PaletteItem {
@@ -47,12 +48,15 @@ const COMMAND_PALETTE_PRIMARY_NAV_IDS = new Set([
'operations',
])
type PaletteNavSource = ProductNavItem & {
parentId?: string
}
export function CommandPalette() {
const t = useTranslations('commandPalette')
const tNav = useTranslations('nav')
const router = useRouter()
const locale = useLocale()
const pathname = usePathname()
const { openTerminal } = useTerminalStore()
const [open, setOpen] = useState(false)
@@ -66,10 +70,21 @@ export function CommandPalette() {
setOpen(false)
}
const navigationItems: PaletteItem[] = [
...PRODUCT_NAV_SECTIONS.flatMap(section => section.items),
const navigationSources: PaletteNavSource[] = [
...PRODUCT_NAV_SECTIONS.flatMap(section => section.items.flatMap(item => [
item,
...(item.children ?? []).map(child => ({
...child,
id: `${item.id}-${child.id}`,
Icon: item.Icon,
parentId: item.id,
surface: 'secondary' as const,
})),
])),
...PRODUCT_BOTTOM_NAV_ITEMS,
].map((item) => {
]
const navigationItems: PaletteItem[] = navigationSources.map((item) => {
const path = item.href === '/' ? '' : item.href
return {
@@ -82,6 +97,7 @@ export function CommandPalette() {
item.id,
item.href,
item.labelKey,
item.parentId ?? '',
...(item.aliases ?? []),
...(item.relatedPaths ?? []),
],