import { Icon, IconButton, Tag } from '@stash/ui' import { fillHeaderText, type HeaderItem, type SettingsTone } from '../../settings' /** * 顶部栏:左品牌、中间滚动信息(可在 /admin 配置)、右侧操作图标。 * 外层
由 Layout 提供,这里只渲染栏内的内容。 */ type SiteHeaderProps = { projectCount: number /** 用于展示的第一个项目名,没有项目时留空 */ sampleProject?: string live: boolean /** 页头滚动信息;为空时用默认三条 */ headerItems: HeaderItem[] headerEnabled: boolean /** 滚动一轮的秒数 */ headerSpeed: number /** 是否已登录:决定右侧是「登录」还是「退出登录」 */ authenticated: boolean username?: string onFocusSearch: () => void onLogin: () => void onLogout: () => void onSettings: () => void } const tagTone: Record = { plain: 'neutral', neutral: 'neutral', primary: 'primary', success: 'success', } type InfoGroupProps = { items: HeaderItem[] projectCount: number sampleProject?: string live: boolean 'aria-hidden'?: boolean } /** 运行信息:同一份内容渲染三遍,轨道平移 1/3 形成无缝滚动 */ function InfoGroup({ items, projectCount, sampleProject, live, 'aria-hidden': ariaHidden, }: InfoGroupProps) { const context = { count: projectCount, project: sampleProject, live } return ( {items.map((item, index) => ( {item.tag !== undefined && item.tag !== null && item.tag !== '' && ( {item.tag} )} {fillHeaderText(item.text, context)} ))} ) } export function SiteHeader({ projectCount, sampleProject, live, headerItems, headerEnabled, headerSpeed, authenticated, username, onFocusSearch, onLogin, onLogout, onSettings, }: SiteHeaderProps) { return (
STASH {headerEnabled && (
)}
} onClick={onFocusSearch} /> {authenticated && ( } onClick={onSettings} /> )} {authenticated ? ( } onClick={onLogout} /> ) : ( } onClick={onLogin} /> )}
) }