mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-26 21:22:48 +00:00
Some checks are pending
Document deploy / sync-images (push) Waiting to run
Document deploy / generate-timestamp (push) Blocked by required conditions
Document deploy / build-images (map[domain:https://fastgpt.cn suffix:cn]) (push) Blocked by required conditions
Document deploy / build-images (map[domain:https://fastgpt.io suffix:io]) (push) Blocked by required conditions
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.cn kube_config:KUBE_CONFIG_CN suffix:cn]) (push) Blocked by required conditions
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.io kube_config:KUBE_CONFIG_IO suffix:io]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / get-vars (push) Waiting to run
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:amd64 runs-on:ubuntu-24.04]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / release-fastgpt-images (push) Blocked by required conditions
* perf: auto focus * perF: getInitData api cache * perf: tool description field * signoz store level * perF: chat logs index
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
'use client';
|
|
import { useEffect } from 'react';
|
|
import { usePathname, useRouter } from 'next/navigation';
|
|
|
|
const exactMap: Record<string, string> = {
|
|
'/docs': '/docs/introduction',
|
|
'/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/commercial',
|
|
'/docs/upgrading/intro/': '/docs/upgrading',
|
|
'/docs/introduction/shopping_cart/intro/': '/docs/introduction/commercial'
|
|
};
|
|
|
|
const prefixMap: Record<string, string> = {
|
|
'/docs/development': '/docs/introduction/development',
|
|
'/docs/FAQ': '/docs/faq',
|
|
'/docs/guide': '/docs/introduction/guide',
|
|
'/docs/shopping_cart': '/docs/introduction/shopping_cart',
|
|
'/docs/agreement': '/docs/protocol'
|
|
};
|
|
|
|
const fallbackRedirect = '/docs/introduction';
|
|
|
|
export default function NotFound() {
|
|
const pathname = usePathname();
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
(async () => {
|
|
if (exactMap[pathname]) {
|
|
window.location.replace(exactMap[pathname]);
|
|
return;
|
|
}
|
|
|
|
for (const [oldPrefix, newPrefix] of Object.entries(prefixMap)) {
|
|
if (pathname.startsWith(oldPrefix)) {
|
|
const rest = pathname.slice(oldPrefix.length);
|
|
window.location.replace(newPrefix + rest);
|
|
return;
|
|
}
|
|
}
|
|
|
|
try {
|
|
const basePath = pathname.replace(/\/$/, '');
|
|
const res = await fetch(`/api/meta?path=${basePath}`);
|
|
console.log('res', res);
|
|
|
|
if (!res.ok) throw new Error('meta API not found');
|
|
|
|
const validPage = await res.json();
|
|
|
|
if (validPage) {
|
|
console.log('validPage', validPage);
|
|
window.location.replace(validPage);
|
|
return;
|
|
}
|
|
} catch (e) {
|
|
console.warn('meta.json fallback failed:', e);
|
|
}
|
|
|
|
window.location.replace(fallbackRedirect);
|
|
})();
|
|
}, [pathname, router]);
|
|
|
|
return null;
|
|
}
|