Skip to content

Commit fde5456

Browse files
committed
fix:add not-found path map
1 parent c390eb1 commit fde5456

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed
Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
1+
'use client';
12
import { redirect } from 'next/navigation';
3+
import { usePathname } from 'next/navigation';
4+
import { useEffect } from 'react';
5+
6+
const exactMap: Record<string, string> = {
7+
'/docs/intro': '/docs/introduction/index',
8+
'/docs/guide/dashboard/workflow/coreferenceresolution':
9+
'/docs/introduction/guide/dashboard/workflow/coreferenceResolution',
10+
'/docs/guide/admin/sso_dingtalk':
11+
'/docs/introduction/guide/admin/sso#/docs/introduction/guide/admin/sso#钉钉',
12+
'/docs/guide/knowledge_base/rag': '/docs/introduction/guide/knowledge_base/RAG',
13+
'/docs/commercial/intro/': '/docs/introduction'
14+
};
15+
16+
const prefixMap: Record<string, string> = {
17+
'/docs/development': '/docs/introduction/development',
18+
'/docs/FAQ': '/docs/introduction/FAQ',
19+
'/docs/guide': '/docs/introduction/guide',
20+
'/docs/shopping_cart': '/docs/introduction/shopping_cart',
21+
'/docs/agreement': '/docs/protocol'
22+
};
223

324
export default function NotFound() {
4-
redirect(`/docs/introduction`);
5-
return <></>;
25+
const pathname = usePathname();
26+
27+
useEffect(() => {
28+
if (exactMap[pathname]) {
29+
redirect(exactMap[pathname]);
30+
return;
31+
}
32+
33+
for (const [oldPrefix, newPrefix] of Object.entries(prefixMap)) {
34+
if (pathname.startsWith(oldPrefix)) {
35+
const rest = pathname.slice(oldPrefix.length);
36+
redirect(newPrefix + rest);
37+
return;
38+
}
39+
}
40+
41+
redirect('/docs/introduction');
42+
}, [pathname]);
43+
44+
return;
645
}

document/content/docs/introduction/development/upgrading/4816.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ description: FastGPT V4.8.16 更新说明
5050
2. 新增 - 商业版支持 API 知识库和链接集合定时同步。
5151
3. 新增 - 猜你想问支持选择模型和自定义提示词。
5252
4. 新增 - 钉钉和企微机器人 webhook 插件。
53-
5. 新增 - 商业版支持钉钉 SSO 登录配置。[点击查看教程](/docs/introduction/guide/admin/sso_dingtalk/)
53+
5. 新增 - 商业版支持钉钉 SSO 登录配置。[点击查看教程](/docs/introduction/guide/admin/sso#钉钉)
5454
6. 新增 - 商业版支持飞书和语雀知识库导入。[点击查看教程](/docs/introduction/guide/knowledge_base/lark_dataset/)
5555
7. 新增 - sandbox 新增 createHmac 加密全局方法。
5656
8. 新增 - 工作流右键支持全部折叠。

document/content/docs/introduction/development/upgrading/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ description: FastGPT 版本更新
55

66
import { Redirect } from '@/components/docs/Redirect';
77

8-
<Redirect to="/docs/introduction/development/upgrading/4111" />
8+
<Redirect to="/docs/introduction/development/upgrading/intro" />

0 commit comments

Comments
 (0)