feat: separate user navigation from focused host management
This commit is contained in:
1 parent
d7c007adc4
commit
8abb9d8a55
13 files changed
+153
-46
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import { Building2, ChevronDown, Menu, UserRound,LogOut } from 'lucide-react';
|
||||
import { ArrowLeft, Building2, ChevronDown, Menu, UserRound,LogOut } from 'lucide-react';
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import { Brand } from './Brand';
|
||||
import { Sidebar } from './Sidebar';
|
||||
import {useNavigationOverlay} from './overlay';
|
||||
|
||||
export function AppShell({ page, tenantName, displayName, hostScoped = false, onNavigate, onSecurity,onLogout, children }: { page: string; tenantName: string; displayName: string; hostScoped?: boolean; onNavigate: (page: string) => void; onSecurity: () => void;onLogout?:()=>void; children: ReactNode }) {
|
||||
export function AppShell({ page, tenantName, displayName, hostScoped = false, hostView = false, hostName, onBack, onNavigate, onSecurity,onLogout, children }: { page: string; tenantName: string; displayName: string; hostScoped?: boolean; hostView?: boolean; hostName?:string; onBack?:()=>void; onNavigate: (page: string) => void; onSecurity: () => void;onLogout?:()=>void; children: ReactNode }) {
|
||||
const [mobileNavOpen, setMobileNavOpen] = useState(false);
|
||||
useNavigationOverlay(mobileNavOpen,setMobileNavOpen);
|
||||
function navigate(pageName: string) {
|
||||
@@ -16,15 +16,15 @@ export function AppShell({ page, tenantName, displayName, hostScoped = false, on
|
||||
<header className="topbar">
|
||||
<button className="mobile-menu" aria-label={mobileNavOpen ? '关闭导航' : '打开导航'} aria-expanded={mobileNavOpen} onClick={() => setMobileNavOpen((value) => !value)}><Menu size={21} /></button>
|
||||
<Brand />
|
||||
<div className="tenant-switch"><Building2 size={17} /><span>{tenantName}</span></div>
|
||||
<div className="tenant-switch"><Building2 size={17} /><span>{hostView || hostScoped ? hostName : tenantName}</span></div>
|
||||
<div className="top-actions">
|
||||
{onLogout?<button className="icon-button" aria-label="退出登录" onClick={onLogout}><LogOut size={18}/></button>:null}
|
||||
<button className="user-menu" onClick={onSecurity} aria-label="账号安全"><span className="avatar"><UserRound size={17} /></span><span>{displayName}</span><ChevronDown size={15} /></button>
|
||||
</div>
|
||||
</header>
|
||||
{mobileNavOpen ? <button className="mobile-nav-backdrop" aria-label="关闭导航" onClick={() => setMobileNavOpen(false)} /> : null}
|
||||
<div className={mobileNavOpen ? 'mobile-sidebar open' : 'mobile-sidebar'}><Sidebar page={page} hostScoped={hostScoped} onNavigate={navigate} /></div>
|
||||
<main className="main-content">{children}</main>
|
||||
<div className={mobileNavOpen ? 'mobile-sidebar open' : 'mobile-sidebar'}><Sidebar page={page} hostScoped={hostScoped} hostView={hostView} onNavigate={navigate} /></div>
|
||||
<main className="main-content">{onBack ? <div className="host-context-bar"><span>目前主机 <b>{hostName}</b></span><button className="secondary" onClick={()=>{setMobileNavOpen(false);onBack()}}><ArrowLeft size={15}/>返回用户总览</button></div> : null}{children}</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user