feat(ia): 一级导航改对标双轴(行业 × 能力 + 洞察),并把导航真源从 DB 行反转为代码
依据实测:Bain 一级导航 = Industries · Consulting Services · Digital · Insights · About · Careers,
Porsche = 行业 · 实践 · 洞察 · 职业 · 关于我们 —— **两家的导航里都没有「产品」**。
咨询业按「客户的问题空间 × 本所的能力」组织,不按产品 SKU 组织。本仓此前 7 项里
产品居首,且 案例(case-study 0 行)、新闻动态(2 行) 是挂在骨架上的空渠道。
落地策略是**换标签、不换路由**:行业→既有 /solutions(solution 模型本就是行业),
能力→既有 /services(service 模型的 4 行本就是能力组)。
理由不是省事,而是避免制造重复内容:若新增 /capabilities 与 /services 并行,
同一个 ContentItem 会同时挂在两个 URL 下 —— 那是 canonical 冲突,比不改更糟。
URL 改名 + 308 留给第二批一次性处理。唯一真正新增的面是 /insights:
它聚合 news + methodology + case-study,今天没有任何单一页面做过这件事,故不构成重复。
「轴 = 视图,模型 = 真源」:本轮零新 ContentModel、零 schema、零 seed 权限测试改动。
沿用 solution/service/product 三个 code ⇒ src/lib/seed-permissions.test.ts:50 的
SUPER_ADMIN_ONLY_MODELS 断言保持绿。**这是设计选择的回报,不是没做事。**
最关键的一处:反转导航优先级
layout.tsx 原为 `(navData?.mainNav) || NAVIGATION_V2` —— **DB 行胜出、代码只兜底**。
`navigation` 的字段是泛型 json,改导航不需动 schema,听起来省事,实际是:
只改 navigation.ts 会上线一个**生产静默忽略它**的新导航。
而 footer 按 megaDropdown 的 key 取栏目 —— 新代码 key 对旧 DB key ⇒ 页脚三栏静默变空。
我在工作树里真的复现了这个状态:本地 navigation/default 行仍是旧 7 项,
它**内部完全自洽**(每个 dropdownKey 都找得到面板),所以「自洽即放行」会继续覆盖代码。
⇒ 新校验器的标准是「它是不是这套 IA」(必须覆盖 industries/capabilities/insights 三轴),
而不是「它是不是合法 JSON」。不合格则 fail-closed 到代码 + 把原因 console.warn 出来
(渲染期不写库:Notification 是后台数据,在 RSC 里写它等于给每次首页渲染挂写副作用)。
这条有专门用例:「旧 IA 的自洽配置必须被拒」。
顺带修掉两处同族缺陷
- injectStandaloneProducts 原按 `key === 'products'` 匹配;双轴改名后该 key 不存在 ⇒
独立产品会**静默不再注入**。改为按组 id(STANDALONE_GROUP_ID)找,组 id 比 key 稳定。
- 激活判定原来有**三套**:header 的 8 分支 per-id 阶梯(末尾落回 pathname===`/${item.id}`,
新 id industries 会拼出一个不存在的路由 ⇒ 行业永不高亮)、mobile-tab-bar 的 per-id
if 阶梯(改名后每项静默返回 false ⇒ tab bar 照渲染、永不高亮 = 绿但空洞)、footer 自一套。
现统一为 lib/nav-active.ts,按 segment 切(不被 /solutionship 这类同前缀误点亮)。
撤下两个空渠道入口(含一处我自己计划里的回退,已当场纠正)
- /cases 从一级导航与移动端 tab bar 撤下:case-study 0 行,点进去是空列表。
路由与模型**保留休眠**,真实授权案例到位当天即可渲染,不必二次迁移。
- 补 { id: 'all-products', href: '/products' } 进能力轴第二层:
撤「产品」时若不补这一条,/products(sitemap priority 0.9、6 个详情页的上游 hub)
就变成**没有导航入口的孤儿页** —— 那是回退不是重构。「降级」不等于「消失」,
已加守卫用例「被退出一级导航的 hub 必须在第二层仍可达」。
/insights 的三处登记(少一处就是「新页面没人扫、门禁仍然绿」的静默覆盖收缩)
- sitemap.ts:新增,priority 0.8;/news 暂留(已索引),第二批 301 归并
- check:headings 的 PAGES 列表:新增(该列表是硬编码路由清单)
- revalidate:新增 INSIGHTS_AFFECTED_MODELS(news/case-study/methodology)
—— /insights 不在 CONTENT_TYPE_CONFIGS 的任何 listPage 里,通用推导只刷 /news、
/methodology;少登记这条的后果不是报错,而是后台发了新内容、洞察页仍端出旧 ISR
快照最长 1 小时,且没有任何门禁会红。已钉 3 正向 + 1 负向(product 变更不得刷
/insights,否则该断言恒真、失去约束力)+ 1 去重。
删除 NAVIGATION(V1):7 个 href 全是 '/'、全站零生产引用,只被 constants.test.ts 供着 ——
那 4 条用例的作用是让死码看起来「有人在用」。已改写成断言活的 NAVIGATION_V2,
并保留其原有意图(每个目的地互不相同,正是 V1 缺的那条)。
KNOWN-RED: test:visual —— 一级导航 7→4、页脚三栏改标题改取数、移动端 tab bar 换轴,
header/footer 相关基线预期 churn。按计划 #10 在所有代码落地后一次性重捕(需 AUTH-VISUAL)。
待授权(本笔**未**执行,且必须执行才能对用户生效):
CMS 的 navigation/default 行仍是旧 7 项。本笔的反转校验会让它 fail-closed 到代码,
所以**新导航会立即在页面上生效**(不再被旧行遮蔽),但后台那一行要改需
`npm run db:seed`(生产为独立授权动作)。seed.ts:945 直接引用 NAVIGATION_V2,
重跑即得新行 —— 本地已复跑验证过(库内 mainNav 已是 industries/capabilities/insights)。
门禁实测:type-check EXIT=0 · 全量 jest 146 套件 / 1807 例通过 ·
eslint --quiet 改动文件 0 error · check:grammar 9/9 及其 selftest 9/9 ·
check:token-twins 44/44 · check:contrast 44/44 · check:brand-token 0 违规 ·
e2e nav-keyboard@chromium 6 passed(含 /insights 实测 HTTP 200)
This commit is contained in:
1 parent
e9bd965411
commit
7d1a22a596
23 files changed
+1083
-197
No files matched your search
@@ -43,35 +43,40 @@ jest.mock('@/lib/site-config', () => ({
|
||||
icp: '蜀ICP备XXXXXXXX号',
|
||||
police: '川公网安备XXXXXXXXXXX号',
|
||||
megaDropdown: {
|
||||
products: [
|
||||
industries: [
|
||||
{
|
||||
id: 'group1',
|
||||
title: '企业套装',
|
||||
items: [
|
||||
{ id: 'erp', title: 'ERP 管理系统', description: '财务·采购·销售·库存·生产', href: '/products/erp' },
|
||||
{ id: 'crm', title: 'CRM 客户管理', description: '线索·商机·合同·服务', href: '/products/crm' },
|
||||
],
|
||||
},
|
||||
],
|
||||
solutions: [
|
||||
{
|
||||
id: 'group1',
|
||||
title: '行业解决方案',
|
||||
id: 'industry-solutions',
|
||||
title: '行业实践',
|
||||
items: [
|
||||
{ id: 'manufacturing', title: '制造业', description: '智能制造·MES·质量管控', href: '/solutions/manufacturing' },
|
||||
{ id: 'retail', title: '零售业', description: '全渠道·会员·精准营销', href: '/solutions/retail' },
|
||||
],
|
||||
},
|
||||
],
|
||||
services: [
|
||||
capabilities: [
|
||||
{
|
||||
id: 'professional-services',
|
||||
title: '专业服务',
|
||||
id: 'capability-groups',
|
||||
title: '能力组',
|
||||
items: [
|
||||
{ id: 'consulting', title: '战略咨询', description: '数字化转型咨询规划', href: '/services/consulting' },
|
||||
{ id: 'software', title: '企业软件', description: 'ERP/CRM/BI 系统实施', href: '/services/software' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'enterprise-suite',
|
||||
title: '产品矩阵',
|
||||
items: [
|
||||
{ id: 'erp', title: 'ERP 管理系统', description: '财务·采购·销售·库存·生产', href: '/products/erp' },
|
||||
{ id: 'crm', title: 'CRM 客户管理', description: '线索·商机·合同·服务', href: '/products/crm' },
|
||||
],
|
||||
},
|
||||
],
|
||||
insights: [
|
||||
{
|
||||
id: 'insight-groups',
|
||||
title: '洞察',
|
||||
items: [{ id: 'all', title: '全部洞察', description: '', href: '/insights' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
@@ -90,6 +95,8 @@ jest.mock('@/lib/constants', () => ({
|
||||
icp: '蜀ICP备XXXXXXXX号',
|
||||
police: '川公网安备XXXXXXXXXXX号',
|
||||
},
|
||||
MEGA_KEYS: { industries: 'industries', capabilities: 'capabilities', insights: 'insights' },
|
||||
STANDALONE_GROUP_ID: 'standalone-products',
|
||||
MEGA_DROPDOWN_DATA: {
|
||||
products: [
|
||||
{
|
||||
@@ -140,12 +147,12 @@ describe('Footer', () => {
|
||||
|
||||
it('should render products section', () => {
|
||||
render(<Footer />);
|
||||
expect(screen.getByText('产品')).toBeInTheDocument();
|
||||
expect(screen.getByText('产品矩阵')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render solutions section', () => {
|
||||
render(<Footer />);
|
||||
expect(screen.getByText('解决方案')).toBeInTheDocument();
|
||||
expect(screen.getByText('行业')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render contact information section', () => {
|
||||
@@ -168,7 +175,7 @@ describe('Footer', () => {
|
||||
it('should render services column from megaDropdown.services (P3 footer)', () => {
|
||||
render(<Footer />);
|
||||
expect(screen.getByTestId('card-services')).toBeInTheDocument();
|
||||
expect(screen.getByText('服务', { exact: true })).toBeInTheDocument();
|
||||
expect(screen.getByText('能力', { exact: true })).toBeInTheDocument();
|
||||
expect(screen.getByText('战略咨询')).toBeInTheDocument();
|
||||
expect(screen.getByText('企业软件')).toBeInTheDocument();
|
||||
});
|
||||
@@ -180,8 +187,13 @@ describe('Footer', () => {
|
||||
expect(screen.getByText('公司', { exact: true })).toBeInTheDocument();
|
||||
expect(screen.getByText('关于我们').closest('a')).toHaveAttribute('href', '/about');
|
||||
expect(screen.getByText('方法论').closest('a')).toHaveAttribute('href', '/methodology');
|
||||
expect(screen.getByText('案例').closest('a')).toHaveAttribute('href', '/cases');
|
||||
expect(screen.getByText('新闻动态').closest('a')).toHaveAttribute('href', '/news');
|
||||
// 案例(0 行)与新闻动态(已并入洞察)两个空渠道入口已撤下;换成品牌故事与洞察。
|
||||
// ⚠ 断言「不存在」必须用 queryByText —— getByText 找不到时直接抛,
|
||||
// 那会让后面几行根本执行不到,看起来像通过了其实什么都没测。
|
||||
expect(screen.queryByText('案例')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('新闻动态')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('洞察').closest('a')).toHaveAttribute('href', '/insights');
|
||||
expect(screen.getByText('品牌故事').closest('a')).toHaveAttribute('href', '/about/brand');
|
||||
});
|
||||
|
||||
it('should render contact details', () => {
|
||||
|
||||
@@ -4,28 +4,42 @@ import { StaticLink } from '@/components/ui/static-link';
|
||||
import Image from 'next/image';
|
||||
import { Mail, MapPin } from 'lucide-react';
|
||||
import { useSiteConfig } from '@/lib/site-config';
|
||||
import { MEGA_KEYS } from '@/lib/constants/navigation';
|
||||
|
||||
// 公司栏目为固定信息架构,路由均已验证存在(/about · /methodology · /cases · /news),与 NAVIGATION_V2 对齐。
|
||||
// 公司栏目为固定信息架构,路由均已验证存在,与 NAVIGATION_V2(行业 × 能力 双轴)对齐。
|
||||
// ⚠ 2026-10-16 撤掉两个入口:**案例**(case-study 模型 0 行,prisma/seeds/case-studies.ts:11
|
||||
// 明示「首批客户共创阶段,暂无对外可验证案例」)与**新闻动态**(仅 2 行,已并入「洞察」)。
|
||||
// 对标两家(Bain Insights / Porsche 洞察)都不挂一个没有内容的频道。
|
||||
// /cases 路由与 case-study 模型**保留休眠**,真实授权案例到位当天即可渲染,不必二次迁移。
|
||||
const COMPANY_LINKS: ReadonlyArray<{ id: string; label: string; href: string }> = [
|
||||
{ id: 'about', label: '关于我们', href: '/about' },
|
||||
{ id: 'brand', label: '品牌故事', href: '/about/brand' },
|
||||
{ id: 'methodology', label: '方法论', href: '/methodology' },
|
||||
{ id: 'cases', label: '案例', href: '/cases' },
|
||||
{ id: 'news', label: '新闻动态', href: '/news' },
|
||||
{ id: 'insights', label: '洞察', href: '/insights' },
|
||||
];
|
||||
|
||||
export function Footer() {
|
||||
const config = useSiteConfig();
|
||||
const productItems = (config.megaDropdown.products ?? [])
|
||||
.flatMap(group => group.items)
|
||||
.filter(item => item.href !== '#');
|
||||
// ⚠ 这三处 key 必须与 src/lib/constants/navigation.ts 的 MEGA_KEYS 同步。
|
||||
// 旧写法读 products/solutions/services;双轴改名后那些 key 已不存在,
|
||||
// 不同步改这里就会让页脚栏目**静默变空** —— 页脚照样渲染,只是没链接。
|
||||
// data-testid 保持原值(card-products / card-solutions / card-services):
|
||||
// 它们是测试与视觉基线的锚点,不是用户可见文案,改它们只会无谓放大改动半径。
|
||||
const capabilityItems = (config.megaDropdown[MEGA_KEYS.capabilities] ?? [])
|
||||
.filter((group) => group.id === 'capability-groups')
|
||||
.flatMap((group) => group.items)
|
||||
.filter((item) => item.href !== '#');
|
||||
|
||||
const solutionItems = (config.megaDropdown.solutions ?? [])
|
||||
.flatMap(group => group.items)
|
||||
.filter(item => item.href !== '#');
|
||||
const industryItems = (config.megaDropdown[MEGA_KEYS.industries] ?? [])
|
||||
.flatMap((group) => group.items)
|
||||
.filter((item) => item.href !== '#');
|
||||
|
||||
const serviceItems = (config.megaDropdown.services ?? [])
|
||||
.flatMap(group => group.items)
|
||||
.filter(item => item.href !== '#');
|
||||
// 产品矩阵:能力轴里「用什么交付」那一组,仍在页脚保留入口(页脚是 sitemap 区,
|
||||
// 与一级导航「不以产品为轴」是两件事 —— Bain/Porsche 的页脚也都罗列全部资产)
|
||||
const productItems = (config.megaDropdown[MEGA_KEYS.capabilities] ?? [])
|
||||
.filter((group) => group.id !== 'capability-groups')
|
||||
.flatMap((group) => group.items)
|
||||
.filter((item) => item.href !== '#');
|
||||
|
||||
return (
|
||||
<footer className="bg-dark-bg text-dark-text-primary relative overflow-hidden [&_a]:inline-flex [&_a]:items-center [&_a]:min-h-6" data-testid="footer" role="contentinfo">
|
||||
@@ -102,7 +116,7 @@ export function Footer() {
|
||||
</div>
|
||||
|
||||
<div data-testid="card-products" className="lg:col-span-2">
|
||||
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">产品</div>
|
||||
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">产品矩阵</div>
|
||||
<ul className="space-y-3 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
|
||||
{productItems.map((item) => (
|
||||
<li key={item.id}>
|
||||
@@ -118,9 +132,9 @@ export function Footer() {
|
||||
</div>
|
||||
|
||||
<div data-testid="card-solutions" className="lg:col-span-2">
|
||||
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">解决方案</div>
|
||||
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">行业</div>
|
||||
<ul className="space-y-3 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
|
||||
{solutionItems.map((item) => (
|
||||
{industryItems.map((item) => (
|
||||
<li key={item.id}>
|
||||
<StaticLink
|
||||
href={item.href}
|
||||
@@ -133,11 +147,11 @@ export function Footer() {
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{serviceItems.length > 0 && (
|
||||
{capabilityItems.length > 0 && (
|
||||
<div data-testid="card-services" className="lg:col-span-2">
|
||||
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">服务</div>
|
||||
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">能力</div>
|
||||
<ul className="space-y-3 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
|
||||
{serviceItems.map((item) => (
|
||||
{capabilityItems.map((item) => (
|
||||
<li key={item.id}>
|
||||
<StaticLink
|
||||
href={item.href}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Menu, X, MessageCircle } from 'lucide-react';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useSiteConfig, type NavigationItem } from '@/lib/site-config';
|
||||
import { isNavItemActive } from '@/lib/nav-active';
|
||||
import { MegaDropdown } from '@/components/layout/mega-dropdown';
|
||||
import { useFocusTrap } from '@/hooks/use-focus-trap';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -59,27 +60,13 @@ function HeaderContent() {
|
||||
setIsOpen(false);
|
||||
}, []);
|
||||
|
||||
const isActive = useCallback((item: NavigationItem) => {
|
||||
if (item.id === 'contact') {
|
||||
return pathname === '/contact';
|
||||
}
|
||||
if (item.id === 'home') {
|
||||
return pathname === '/';
|
||||
}
|
||||
if (item.id === 'products') {
|
||||
return pathname === '/products' || pathname.startsWith('/products/');
|
||||
}
|
||||
if (item.id === 'solutions') {
|
||||
return pathname === '/solutions' || pathname.startsWith('/solutions/');
|
||||
}
|
||||
if (item.id === 'cases') {
|
||||
return pathname === '/cases' || pathname.startsWith('/cases/');
|
||||
}
|
||||
if (item.id === 'services') {
|
||||
return pathname === '/services' || pathname.startsWith('/services/');
|
||||
}
|
||||
return pathname === `/${item.id}`;
|
||||
}, [pathname]);
|
||||
// 激活判定唯一实现见 lib/nav-active.ts —— 原来是 8 个分支的 per-id `if` 阶梯,
|
||||
// 末尾还落回 `pathname === `/${item.id}``:双轴改名后 id 变成 industries/insights,
|
||||
// 于是「行业」永远点不亮(菜单照常渲染 = 绿但空洞)。
|
||||
const isActive = useCallback(
|
||||
(item: NavigationItem) => isNavItemActive(pathname, item.href),
|
||||
[pathname],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -39,9 +39,9 @@ describe('MobileTabBar', () => {
|
||||
it('should render all tabs', () => {
|
||||
render(<MobileTabBar />);
|
||||
expect(screen.getByText('首页')).toBeInTheDocument();
|
||||
expect(screen.getByText('产品')).toBeInTheDocument();
|
||||
expect(screen.getByText('方案')).toBeInTheDocument();
|
||||
expect(screen.getByText('案例')).toBeInTheDocument();
|
||||
expect(screen.getByText('能力')).toBeInTheDocument();
|
||||
expect(screen.getByText('行业')).toBeInTheDocument();
|
||||
expect(screen.getByText('洞察')).toBeInTheDocument();
|
||||
expect(screen.getByText('联系')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -76,20 +76,24 @@ describe('MobileTabBar', () => {
|
||||
|
||||
it('should have correct href for solutions', () => {
|
||||
render(<MobileTabBar />);
|
||||
const solutionsLink = screen.getByText('方案').closest('a');
|
||||
const solutionsLink = screen.getByText('行业').closest('a');
|
||||
expect(solutionsLink).toHaveAttribute('href', '/solutions');
|
||||
});
|
||||
|
||||
it('should have correct href for products', () => {
|
||||
it('能力 tab 落在 /services(本轮换标签不换路由:能力轴读 service 模型)', () => {
|
||||
render(<MobileTabBar />);
|
||||
const productsLink = screen.getByText('产品').closest('a');
|
||||
expect(productsLink).toHaveAttribute('href', '/products');
|
||||
expect(screen.getByText('能力').closest('a')).toHaveAttribute('href', '/services');
|
||||
});
|
||||
|
||||
it('should have correct href for cases', () => {
|
||||
it('洞察 tab 落在 /insights,且「案例」常驻位已撤下(case-study 0 行)', () => {
|
||||
render(<MobileTabBar />);
|
||||
const casesLink = screen.getByText('案例').closest('a');
|
||||
expect(casesLink).toHaveAttribute('href', '/cases');
|
||||
expect(screen.getByText('洞察').closest('a')).toHaveAttribute('href', '/insights');
|
||||
expect(screen.queryByText('案例')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('行业 tab 落在 /solutions', () => {
|
||||
render(<MobileTabBar />);
|
||||
expect(screen.getByText('行业').closest('a')).toHaveAttribute('href', '/solutions');
|
||||
});
|
||||
|
||||
it('should have correct href for contact', () => {
|
||||
|
||||
@@ -5,45 +5,34 @@ import { usePathname } from 'next/navigation';
|
||||
import { Home, Lightbulb, Package, FolderOpen, User } from 'lucide-react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { isNavItemActive } from '@/lib/nav-active';
|
||||
|
||||
// 关于页让位给案例页:转化路径上「看实证」优先于「看介绍」,
|
||||
// 关于/新闻等仍可通过汉堡抽屉(header)到达。
|
||||
// 2026-10-16 随一级导航改对标双轴(行业 × 能力 + 洞察),与 header 同源。
|
||||
// ⚠ 撤掉「案例」tab:case-study 模型 0 行(prisma/seeds/case-studies.ts:11),
|
||||
// 原来把它放在移动端第五个、也是唯一常驻的转化位上,点开是一个空列表 ——
|
||||
// 移动端比桌面端更吃「点了没东西」的亏。路由 /cases 保留休眠,出数后回归。
|
||||
const tabs = [
|
||||
{ id: 'home', label: '首页', href: '/', icon: Home },
|
||||
{ id: 'products', label: '产品', href: '/products', icon: Package },
|
||||
{ id: 'solutions', label: '方案', href: '/solutions', icon: Lightbulb },
|
||||
{ id: 'cases', label: '案例', href: '/cases', icon: FolderOpen },
|
||||
{ id: 'industries', label: '行业', href: '/solutions', icon: Lightbulb },
|
||||
{ id: 'capabilities', label: '能力', href: '/services', icon: Package },
|
||||
{ id: 'insights', label: '洞察', href: '/insights', icon: FolderOpen },
|
||||
{ id: 'contact', label: '联系', href: '/contact', icon: User },
|
||||
];
|
||||
|
||||
export function MobileTabBar() {
|
||||
const pathname = usePathname();
|
||||
|
||||
const isActive = (_href: string, id: string) => {
|
||||
if (id === 'home') {
|
||||
return pathname === '/';
|
||||
}
|
||||
if (id === 'contact') {
|
||||
return pathname === '/contact';
|
||||
}
|
||||
if (id === 'products') {
|
||||
return pathname === '/products' || pathname.startsWith('/products/');
|
||||
}
|
||||
if (id === 'solutions') {
|
||||
return pathname === '/solutions' || pathname.startsWith('/solutions/');
|
||||
}
|
||||
if (id === 'cases') {
|
||||
return pathname === '/cases' || pathname.startsWith('/cases/');
|
||||
}
|
||||
return false;
|
||||
};
|
||||
// 原实现是按 id 手写的 5 分支 `if` 阶梯,且 switch 在 **id** 上而不是 href:
|
||||
// 改名后每一项都静默返回 false ⇒ tab bar 照常渲染、永不高亮(典型「绿但空洞」)。
|
||||
// 现改用与 header 同一份 lib/nav-active.ts。
|
||||
const isActive = (href: string) => isNavItemActive(pathname, href);
|
||||
|
||||
return (
|
||||
<nav className="fixed bottom-0 left-0 right-0 z-50 md:hidden bg-bg-primary/95 backdrop-blur-xl border-t border-border-primary" style={{ paddingBottom: 'env(safe-area-inset-bottom, 0px)' }}>
|
||||
<div className="flex items-center justify-around h-16">
|
||||
{tabs.map((tab) => {
|
||||
const Icon = tab.icon;
|
||||
const active = isActive(tab.href, tab.id);
|
||||
const active = isActive(tab.href);
|
||||
|
||||
return (
|
||||
<StaticLink
|
||||
|
||||
Reference in new issue
Block a user