forked from imbytecat/fullstack-starter
- 移除 TanStack Query 开发工具的集成配置 - 移除对 tanstack-query devtools 的导出 - 移除 TanStack Router 开发工具插件的集成配置 - 移除 tanstack-router 开发工具集成的导出 - 移除旧的 devtools 集成方式,改用新的组件化方式引入 TanStack Router 和 Query 的开发工具面板。
73 lines
1.7 KiB
TypeScript
73 lines
1.7 KiB
TypeScript
import { TanStackDevtools } from '@tanstack/react-devtools'
|
|
import type { QueryClient } from '@tanstack/react-query'
|
|
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
|
|
import {
|
|
createRootRouteWithContext,
|
|
HeadContent,
|
|
Scripts,
|
|
} from '@tanstack/react-router'
|
|
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
|
|
import type { ReactNode } from 'react'
|
|
import { ErrorComponent } from '@/components/Error'
|
|
import { NotFoundComponent } from '@/components/NotFount'
|
|
import appCss from '@/styles.css?url'
|
|
|
|
export interface RouterContext {
|
|
queryClient: QueryClient
|
|
}
|
|
|
|
export const Route = createRootRouteWithContext<RouterContext>()({
|
|
head: () => ({
|
|
meta: [
|
|
{
|
|
charSet: 'utf-8',
|
|
},
|
|
{
|
|
name: 'viewport',
|
|
content: 'width=device-width, initial-scale=1',
|
|
},
|
|
{
|
|
title: 'Fullstack Starter',
|
|
},
|
|
],
|
|
links: [
|
|
{
|
|
rel: 'stylesheet',
|
|
href: appCss,
|
|
},
|
|
],
|
|
}),
|
|
shellComponent: RootDocument,
|
|
errorComponent: () => <ErrorComponent />,
|
|
notFoundComponent: () => <NotFoundComponent />,
|
|
})
|
|
|
|
function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
|
|
return (
|
|
<html lang="zh-Hans">
|
|
<head>
|
|
<HeadContent />
|
|
</head>
|
|
<body>
|
|
{children}
|
|
<TanStackDevtools
|
|
config={{
|
|
position: 'bottom-right',
|
|
}}
|
|
plugins={[
|
|
{
|
|
name: 'TanStack Router',
|
|
render: <TanStackRouterDevtoolsPanel />,
|
|
},
|
|
{
|
|
name: 'TanStack Query',
|
|
render: <ReactQueryDevtoolsPanel />,
|
|
},
|
|
]}
|
|
/>
|
|
<Scripts />
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|