|
1 | | -import { |
2 | | - HeadContent, |
3 | | - Outlet, |
4 | | - Scripts, |
5 | | - createRootRoute, |
6 | | -} from '@tanstack/react-router' |
7 | | -import { QueryClient, QueryClientProvider } from '@tanstack/react-query' |
8 | | -import appCss from '../styles.css?url' |
9 | | -import { SearchModal } from '@/components/search/search-modal' |
10 | | -import { TerminalShortcutListener } from '@/components/terminal-shortcut-listener' |
11 | | -import { KeyboardShortcutsModal } from '@/components/keyboard-shortcuts-modal' |
12 | | - |
13 | | - |
14 | | -const themeScript = ` |
15 | | -(() => { |
16 | | - try { |
17 | | - const stored = localStorage.getItem('openclaw-settings') |
18 | | - const fallback = localStorage.getItem('chat-settings') |
19 | | - let theme = 'dark' |
20 | | - if (stored) { |
21 | | - const parsed = JSON.parse(stored) |
22 | | - const storedTheme = parsed?.state?.settings?.theme |
23 | | - if (storedTheme === 'light' || storedTheme === 'dark' || storedTheme === 'system') { |
24 | | - theme = storedTheme |
25 | | - } |
26 | | - } else if (fallback) { |
27 | | - const parsed = JSON.parse(fallback) |
28 | | - const storedTheme = parsed?.state?.settings?.theme |
29 | | - if (storedTheme === 'light' || storedTheme === 'dark' || storedTheme === 'system') { |
30 | | - theme = storedTheme |
31 | | - } |
32 | | - } |
33 | | - const root = document.documentElement |
34 | | - const media = window.matchMedia('(prefers-color-scheme: dark)') |
35 | | - const apply = () => { |
36 | | - root.classList.remove('light', 'dark', 'system') |
37 | | - root.classList.add(theme) |
38 | | - if (theme === 'system' && media.matches) { |
39 | | - root.classList.add('dark') |
40 | | - } |
41 | | - } |
42 | | - apply() |
43 | | - media.addEventListener('change', () => { |
44 | | - if (theme === 'system') apply() |
45 | | - }) |
46 | | - } catch {} |
47 | | -})() |
48 | | -` |
| 1 | +import * as React from 'react' |
| 2 | +import { Outlet, createRootRoute } from '@tanstack/react-router' |
49 | 3 |
|
50 | 4 | export const Route = createRootRoute({ |
51 | | - head: () => ({ |
52 | | - meta: [ |
53 | | - { |
54 | | - charSet: 'utf-8', |
55 | | - }, |
56 | | - { |
57 | | - name: 'viewport', |
58 | | - content: 'width=device-width, initial-scale=1', |
59 | | - }, |
60 | | - { |
61 | | - title: 'OpenClaw Studio', |
62 | | - }, |
63 | | - { |
64 | | - name: 'description', |
65 | | - content: 'Supercharged chat interface for OpenClaw AI agents with file explorer, terminal, and usage tracking', |
66 | | - }, |
67 | | - { |
68 | | - property: 'og:image', |
69 | | - content: '/cover.webp', |
70 | | - }, |
71 | | - { |
72 | | - property: 'og:image:type', |
73 | | - content: 'image/webp', |
74 | | - }, |
75 | | - { |
76 | | - name: 'twitter:card', |
77 | | - content: 'summary_large_image', |
78 | | - }, |
79 | | - { |
80 | | - name: 'twitter:image', |
81 | | - content: '/cover.webp', |
82 | | - }, |
83 | | - ], |
84 | | - links: [ |
85 | | - { |
86 | | - rel: 'stylesheet', |
87 | | - href: appCss, |
88 | | - }, |
89 | | - { |
90 | | - rel: 'icon', |
91 | | - type: 'image/svg+xml', |
92 | | - href: '/favicon.svg', |
93 | | - }, |
94 | | - ], |
95 | | - }), |
96 | | - |
97 | | - shellComponent: RootDocument, |
98 | | - component: RootLayout, |
| 5 | + component: RootComponent, |
99 | 6 | }) |
100 | 7 |
|
101 | | -const queryClient = new QueryClient() |
102 | | - |
103 | | -function RootLayout() { |
| 8 | +function RootComponent() { |
104 | 9 | return ( |
105 | | - <QueryClientProvider client={queryClient}> |
106 | | - <TerminalShortcutListener /> |
| 10 | + <React.Fragment> |
| 11 | + <div>Hello "__root"!</div> |
107 | 12 | <Outlet /> |
108 | | - <SearchModal /> |
109 | | - <KeyboardShortcutsModal /> |
110 | | - </QueryClientProvider> |
111 | | - ) |
112 | | -} |
113 | | - |
114 | | -function RootDocument({ children }: { children: React.ReactNode }) { |
115 | | - return ( |
116 | | - <html lang="en" suppressHydrationWarning> |
117 | | - <head> |
118 | | - <script dangerouslySetInnerHTML={{ __html: themeScript }} /> |
119 | | - <HeadContent /> |
120 | | - </head> |
121 | | - <body> |
122 | | - <div className="root">{children}</div> |
123 | | - <Scripts /> |
124 | | - </body> |
125 | | - </html> |
| 13 | + </React.Fragment> |
126 | 14 | ) |
127 | 15 | } |
0 commit comments