-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathRouter.tsx
More file actions
85 lines (80 loc) · 2.42 KB
/
Router.tsx
File metadata and controls
85 lines (80 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { createRoute, createRouter, Link } from '@tanstack/react-router';
import { ShowRoute } from './ShowRoute';
import { SearchRoute } from './Search/SearchRoute';
import { NewRoute } from './NewResource/NewRoute';
import { AppSettingsRoute } from './AppSettings';
import { EditRoute } from './EditRoute';
import { DataRoute } from './DataRoute';
import { ShortcutsRoute } from './ShortcutsRoute';
import { AboutRoute } from './AboutRoute';
import { AgentSettingsRoute } from './SettingsAgent';
import { ServerSettingsRoute } from './SettingsServer';
import { pathNames } from './paths';
import { ShareRoute } from './Share/ShareRoute';
import { TokenRoute } from './TokenRoute';
import { isDev } from '../config';
import { rootRoute, topRoute, appRoute } from './RootRoutes';
import { unavailableLazyRoute } from './UnavailableLazyRoute';
import { ImportRoute } from './ImportRoute';
import { HistoryRoute } from './History/HistoryRoute';
import { LinkOpenRouter } from './LinkOpenRouter';
const PruneTestsRoute = createRoute({
getParentRoute: () => appRoute,
path: pathNames.pruneTests,
// @ts-expect-error - Mismatch between unavailable route name and prune route name, not sure how to fix this.
}).lazy(() => {
if (isDev()) {
return import('./PruneTestsRoute').then(mod => mod.pruneTestRouteLazy);
} else {
return Promise.resolve(unavailableLazyRoute);
}
});
const SandboxRoute = createRoute({
getParentRoute: () => appRoute,
path: pathNames.sandbox,
// @ts-expect-error - Mismatch between unavailable route name and sandbox route name, not sure how to fix this.
}).lazy(() => {
if (isDev()) {
return import('./Sandbox').then(mod => mod.sandboxRouteLazy);
} else {
return Promise.resolve(unavailableLazyRoute);
}
});
const routeTree = rootRoute.addChildren({
appRoute: appRoute.addChildren({
ShowRoute,
SearchRoute,
AppSettingsRoute,
ShortcutsRoute,
AgentSettingsRoute,
ServerSettingsRoute,
DataRoute,
EditRoute,
ImportRoute,
ShareRoute,
AboutRoute,
TokenRoute,
HistoryRoute,
NewRoute,
PruneTestsRoute,
SandboxRoute,
LinkOpenRouter,
}),
topRoute,
});
export const router = createRouter({
routeTree,
defaultNotFoundComponent: () => {
return (
<div>
<p>Not found!</p>
<Link to='/'>Go home</Link>
</div>
);
},
});
declare module '@tanstack/react-router' {
interface Register {
router: typeof router;
}
}