feat: add hideHeader in url params

This commit is contained in:
moonrailgun 2023-10-08 19:06:59 +08:00
parent 822a307cec
commit bfc04e9033

View File

@ -1,11 +1,12 @@
import React from 'react'; import React from 'react';
import { Outlet } from 'react-router-dom'; import { Outlet, useSearchParams } from 'react-router-dom';
import { NavItem } from '../components/NavItem'; import { NavItem } from '../components/NavItem';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
import { Button, Dropdown } from 'antd'; import { Button, Dropdown } from 'antd';
import { useUserStore } from '../store/user'; import { useUserStore } from '../store/user';
export const Layout: React.FC = React.memo(() => { export const Layout: React.FC = React.memo(() => {
const [params] = useSearchParams();
const workspaces = useUserStore((state) => { const workspaces = useUserStore((state) => {
const userInfo = state.info; const userInfo = state.info;
if (userInfo) { if (userInfo) {
@ -19,46 +20,49 @@ export const Layout: React.FC = React.memo(() => {
return []; return [];
}); });
const showHeader = !params.has('hideHeader');
return ( return (
<div className="flex flex-col h-full"> <div className="flex flex-col h-full">
<div className="flex items-center bg-gray-100 px-4"> {showHeader && (
<div className="px-2 mr-10 font-bold">Tianji</div> <div className="flex items-center bg-gray-100 px-4">
<div className="flex gap-8"> <div className="px-2 mr-10 font-bold">Tianji</div>
<NavItem to="/dashboard" label="Dashboard" /> <div className="flex gap-8">
<NavItem to="/monitor" label="Monitor" /> <NavItem to="/dashboard" label="Dashboard" />
<NavItem to="/website" label="Website" /> <NavItem to="/monitor" label="Monitor" />
<NavItem to="/servers" label="Servers" /> <NavItem to="/website" label="Website" />
<NavItem to="/settings" label="Settings" /> <NavItem to="/servers" label="Servers" />
</div> <NavItem to="/settings" label="Settings" />
</div>
<div className="flex-1" /> <div className="flex-1" />
<div> <div>
<Dropdown <Dropdown
placement="bottomRight" placement="bottomRight"
menu={{ menu={{
items: [ items: [
{ {
key: 'workspaces', key: 'workspaces',
label: 'Workspaces', label: 'Workspaces',
children: workspaces.map((w) => ({ children: workspaces.map((w) => ({
key: w.id, key: w.id,
label: `${w.name}${w.current ? '(current)' : ''}`, label: `${w.name}${w.current ? '(current)' : ''}`,
disabled: w.current, disabled: w.current,
})), })),
}, },
{ {
key: 'logout', key: 'logout',
label: 'Logout', label: 'Logout',
}, },
], ],
}} }}
> >
<Button shape="circle" size="large" icon={<UserOutlined />} /> <Button shape="circle" size="large" icon={<UserOutlined />} />
</Dropdown> </Dropdown>
</div>
</div> </div>
</div> )}
<div className="flex-1 w-full px-4 overflow-auto"> <div className="flex-1 w-full px-4 overflow-auto">
<div className="max-w-7xl m-auto h-full"> <div className="max-w-7xl m-auto h-full">
<Outlet /> <Outlet />