From 0711c3c003d1e86130afece1178d2fb32d0d7191 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 2 Apr 2024 23:11:29 +0800 Subject: [PATCH] refactor: move add desktop layout into --- src/client/pages/Layout/DesktopLayout.tsx | 162 +++++++++++++++++++++ src/client/pages/Layout/MobileLayout.tsx | 6 + src/client/pages/Layout/UserConfig.tsx | 1 - src/client/pages/Layout/types.ts | 3 + src/client/pages/LayoutV2.tsx | 166 ++-------------------- 5 files changed, 180 insertions(+), 158 deletions(-) create mode 100644 src/client/pages/Layout/DesktopLayout.tsx create mode 100644 src/client/pages/Layout/MobileLayout.tsx create mode 100644 src/client/pages/Layout/types.ts diff --git a/src/client/pages/Layout/DesktopLayout.tsx b/src/client/pages/Layout/DesktopLayout.tsx new file mode 100644 index 0000000..1d4b597 --- /dev/null +++ b/src/client/pages/Layout/DesktopLayout.tsx @@ -0,0 +1,162 @@ +import * as React from 'react'; +import { + LuAreaChart, + LuFilePieChart, + LuMonitorDot, + LuServer, + LuWifi, +} from 'react-icons/lu'; +import { TooltipProvider } from '@/components/ui/tooltip'; +import { + ResizableHandle, + ResizablePanel, + ResizablePanelGroup, +} from '@/components/ui/resizable'; +import { useLocalStorageState } from 'ahooks'; +import { cn } from '@/utils/style'; +import { Separator } from '@/components/ui/separator'; +import { Nav } from './Nav'; +import { WorkspaceSwitcher } from '@/components/WorkspaceSwitcher'; +import { UserConfig } from './UserConfig'; +import { Outlet } from '@tanstack/react-router'; +import { trpc } from '@/api/trpc'; +import { useUserStore } from '@/store/user'; +import { LayoutProps } from './types'; + +const defaultLayout: [number, number, number] = [265, 440, 655]; + +export const DesktopLayout: React.FC = React.memo((props) => { + const [layout = defaultLayout, setLayout] = useLocalStorageState( + 'react-resizable-panels:layout', + { defaultValue: defaultLayout } + ); + const [isCollapsed = false, setIsCollapsed] = useLocalStorageState( + 'react-resizable-panels:collapsed', + { + defaultValue: false, + } + ); + const workspaceId = useUserStore((state) => state.info?.currentWorkspace?.id); + const { data: serviceCount } = trpc.workspace.getServiceCount.useQuery( + { + workspaceId: workspaceId!, + }, + { + enabled: !!workspaceId, + } + ); + + const navbar = ( + <> +
+ +
+ +