mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-18 09:24:03 +00:00
fix:add not-found path map (#5309)
This commit is contained in:
@@ -1,6 +1,45 @@
|
||||
'use client';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const exactMap: Record<string, string> = {
|
||||
'/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<string, string> = {
|
||||
'/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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user