mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-16 08:01:18 +00:00

* feat:get lastmodified time by git log * fix:add sentence to run github.js for lastmodified time in pre-commit
46 lines
1.4 KiB
TypeScript
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 <></>;
|
|
}
|