mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-22 16:01:33 +03:00
b214003968
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)
89 lines
2.0 KiB
TypeScript
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>
|
|
);
|
|
};
|