From 9f4778244208ba6b388849aea743d33da346d0d5 Mon Sep 17 00:00:00 2001 From: xiezhouwei Date: Mon, 22 Jun 2026 09:09:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20homepage=20'=E6=96=87=E6=A1=A3'=20nav=20?= =?UTF-8?q?link=20now=20uses=20dynamic=20same-origin=20docs=20URL=20instea?= =?UTF-8?q?d=20of=20hardcoded=20docs.new-api.cc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Home/index.jsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/web/src/pages/Home/index.jsx b/web/src/pages/Home/index.jsx index de21e1c..8e539e9 100644 --- a/web/src/pages/Home/index.jsx +++ b/web/src/pages/Home/index.jsx @@ -17,10 +17,11 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ -import React, { useState, useEffect, useCallback, useRef } from 'react'; +import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Copy, Check, Code, Terminal, FileCode, Box, Grid3X3, Play, Trophy, PieChart, BookOpen, Search, Sun, Moon, Monitor, Languages } from 'lucide-react'; +import { mapWebLanguageToDocsLocale } from '../../helpers/docsLink'; /* ================================================================== @@ -139,7 +140,7 @@ function HomeLanguageSelector() { } function HeroSection() { - const { t } = useTranslation(); + const { t, i18n } = useTranslation(); const [copied, setCopied] = useState(false); const navigate = useNavigate(); const copyCmd = useCallback(() => { @@ -147,6 +148,12 @@ function HeroSection() { setCopied(true); setTimeout(() => setCopied(false), 1500); }, []); + + const docsUrl = useMemo(() => { + const locale = mapWebLanguageToDocsLocale(i18n.language); + return `/${locale}/docs`; + }, [i18n.language]); + return (
@@ -162,12 +169,12 @@ function HeroSection() { {[ { key: "model", label: "模型", icon: , to: "/pricing" }, { key: "benchmark", label: "评测", icon: , to: "/benchmarks" }, - { key: "docs", label: "文档", icon: , to: "https://docs.new-api.cc", external: true }, + { key: "docs", label: "文档", icon: , to: docsUrl, external: true }, { key: "console", label: "控制台", icon: , to: "/console" }, ].map((item) => { const linkClass = "inline-flex items-center gap-1.5 px-3 py-1.5 text-[14px] rounded-md transition-colors duration-150 text-white/60 hover:text-white"; if (item.external) { - return {item.icon}{t(item.label)}; + return {item.icon}{t(item.label)}; } return {item.icon}{t(item.label)}; })}