'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { useState } from 'react'; import { LanguageType } from '../lib/content'; interface NavigationProps { /** 🔧 修改 #1:currentLang 从 string 改为 LanguageType */ currentLang: LanguageType; /** 🔧 修改 #2:setCurrentLang 返回值改为 void(原来写成了 string),签名也保持只接受 LanguageType */ setCurrentLang: (lang: LanguageType) => void; content: { nav: { home: string; services: string; solutions: string; pricing: string; news: string; contact: string; }; }; /** 🔧 修改 #3:createLocalizedPath 的签名改为 (path: string) => string */ createLocalizedPath?: (path: string) => string; } export default function Navigation({ currentLang, setCurrentLang, content, createLocalizedPath, }: NavigationProps) { const pathname = usePathname(); const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); // Helper to build localized URLs const getLocalizedPath = (path: string) => { return createLocalizedPath ? createLocalizedPath(path) : path; }; const navItems = [ { label: content.nav.home, href: getLocalizedPath('/') }, { label: content.nav.services, href: getLocalizedPath('/services') }, { label: content.nav.solutions, href: getLocalizedPath('/solutions') }, { label: content.nav.pricing, href: getLocalizedPath('/pricing') }, { label: content.nav.news, href: getLocalizedPath('/news') }, { label: content.nav.contact, href: getLocalizedPath('/contact') }, ]; return ( ); }