From 51268f11873d7bd9604d110e28521ebf85dcc4de Mon Sep 17 00:00:00 2001 From: dreamer6680 <1468683855@qq.com> Date: Thu, 24 Jul 2025 17:35:14 +0800 Subject: [PATCH] fix:add not-found path map (#5309) --- document/components/docs/not-found.tsx | 43 ++++++++++++++++++- .../development/upgrading/4816.mdx | 2 +- .../development/upgrading/index.mdx | 2 +- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/document/components/docs/not-found.tsx b/document/components/docs/not-found.tsx index 9700849a8..7e172d09e 100644 --- a/document/components/docs/not-found.tsx +++ b/document/components/docs/not-found.tsx @@ -1,6 +1,45 @@ +'use client'; import { redirect } from 'next/navigation'; +import { usePathname } from 'next/navigation'; +import { useEffect } from 'react'; + +const exactMap: Record = { + '/docs/intro': '/docs/introduction/index', + '/docs/guide/dashboard/workflow/coreferenceresolution': + '/docs/introduction/guide/dashboard/workflow/coreferenceResolution', + '/docs/guide/admin/sso_dingtalk': + '/docs/introduction/guide/admin/sso#/docs/introduction/guide/admin/sso#钉钉', + '/docs/guide/knowledge_base/rag': '/docs/introduction/guide/knowledge_base/RAG', + '/docs/commercial/intro/': '/docs/introduction' +}; + +const prefixMap: Record = { + '/docs/development': '/docs/introduction/development', + '/docs/FAQ': '/docs/introduction/FAQ', + '/docs/guide': '/docs/introduction/guide', + '/docs/shopping_cart': '/docs/introduction/shopping_cart', + '/docs/agreement': '/docs/protocol' +}; export default function NotFound() { - redirect(`/docs/introduction`); - return <>; + const pathname = usePathname(); + + useEffect(() => { + if (exactMap[pathname]) { + redirect(exactMap[pathname]); + return; + } + + for (const [oldPrefix, newPrefix] of Object.entries(prefixMap)) { + if (pathname.startsWith(oldPrefix)) { + const rest = pathname.slice(oldPrefix.length); + redirect(newPrefix + rest); + return; + } + } + + redirect('/docs/introduction'); + }, [pathname]); + + return; } diff --git a/document/content/docs/introduction/development/upgrading/4816.mdx b/document/content/docs/introduction/development/upgrading/4816.mdx index 6563d7e21..78c44b7b1 100644 --- a/document/content/docs/introduction/development/upgrading/4816.mdx +++ b/document/content/docs/introduction/development/upgrading/4816.mdx @@ -50,7 +50,7 @@ description: FastGPT V4.8.16 更新说明 2. 新增 - 商业版支持 API 知识库和链接集合定时同步。 3. 新增 - 猜你想问支持选择模型和自定义提示词。 4. 新增 - 钉钉和企微机器人 webhook 插件。 -5. 新增 - 商业版支持钉钉 SSO 登录配置。[点击查看教程](/docs/introduction/guide/admin/sso_dingtalk/) +5. 新增 - 商业版支持钉钉 SSO 登录配置。[点击查看教程](/docs/introduction/guide/admin/sso#钉钉) 6. 新增 - 商业版支持飞书和语雀知识库导入。[点击查看教程](/docs/introduction/guide/knowledge_base/lark_dataset/) 7. 新增 - sandbox 新增 createHmac 加密全局方法。 8. 新增 - 工作流右键支持全部折叠。 diff --git a/document/content/docs/introduction/development/upgrading/index.mdx b/document/content/docs/introduction/development/upgrading/index.mdx index 52feb6ecf..96fde5e5e 100644 --- a/document/content/docs/introduction/development/upgrading/index.mdx +++ b/document/content/docs/introduction/development/upgrading/index.mdx @@ -5,4 +5,4 @@ description: FastGPT 版本更新 import { Redirect } from '@/components/docs/Redirect'; - \ No newline at end of file + \ No newline at end of file