AFFiNE/packages/frontend/admin/src/app.tsx
JimmFly b214003968
feat(admin): add prompt management page (#7611)
close AF-907

Supports online modification of prompt, but does not support custom ai key yet

![CleanShot 2024-07-29 at 22 12 39@2x](https://github.com/user-attachments/assets/c67ad0d0-3e5b-44ff-b7db-d07dd11c19e2)
2024-08-13 14:51:54 +08:00

89 lines
2.0 KiB
TypeScript

import { Toaster } from '@affine/admin/components/ui/sonner';
import { Telemetry } from '@affine/core/telemetry';
import { wrapCreateBrowserRouter } from '@sentry/react';
import { useEffect } from 'react';
import {
createBrowserRouter as reactRouterCreateBrowserRouter,
RouterProvider,
useLocation,
useNavigate,
} from 'react-router-dom';
import { TooltipProvider } from './components/ui/tooltip';
const createBrowserRouter = wrapCreateBrowserRouter(
reactRouterCreateBrowserRouter
);
const _createBrowserRouter = window.SENTRY_RELEASE
? createBrowserRouter
: reactRouterCreateBrowserRouter;
const Redirect = function Redirect() {
const location = useLocation();
const navigate = useNavigate();
useEffect(() => {
if (!location.pathname.startsWith('/admin/accounts')) {
navigate('/admin/accounts', { replace: true });
}
}, [location, navigate]);
return null;
};
export const router = _createBrowserRouter(
[
{
path: '/',
element: <Redirect />,
},
{
path: '/admin',
children: [
{
path: '',
element: <Redirect />,
},
{
path: '/admin/accounts',
lazy: () => import('./modules/accounts'),
},
{
path: '/admin/auth',
lazy: () => import('./modules/auth'),
},
{
path: '/admin/ai',
lazy: () => import('./modules/ai'),
},
{
path: '/admin/setup',
lazy: () => import('./modules/setup'),
},
{
path: '/admin/config',
lazy: () => import('./modules/config'),
},
{
path: '/admin/settings',
lazy: () => import('./modules/settings'),
},
],
},
],
{
future: {
v7_normalizeFormMethod: true,
},
}
);
export const App = () => {
return (
<TooltipProvider>
<Telemetry />
<RouterProvider router={router} />
<Toaster />
</TooltipProvider>
);
};