Files
FastGPT/document/components/docs/not-found.tsx
dreamer6680 47ef1a581f feat:get lastmodified time by git log (#5314)
* feat:get lastmodified time by git log

* fix:add sentence to run github.js for lastmodified time in pre-commit
2025-07-25 16:43:37 +08:00

46 lines
1.4 KiB
TypeScript

'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',
'/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() {
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 <></>;
}