import type { DocKind } from "#office/contract.ts"; import type { Strings } from "#ui/i18n.ts"; import { FileType, Icon } from "#ui/icons.tsx"; import { baseName, dirName } from "#ui/rpc.ts"; import { Menu, MenuItem } from "#ui/shell/parts.tsx"; import type { FitMode } from "#ui/viewers/types.ts"; // 面板标题栏的两个下拉菜单(切换文档、更多操作),从 main.tsx 拆出以控制单文件规模,行为不变。 export function SwitchMenu({ t, recent, currentPath, onOpen, onBrowse, onClose, }: { t: Strings; recent: { path: string; kind: DocKind }[]; currentPath: string | undefined; onOpen(path: string): void; onBrowse(): void; onClose(): void; }) { return ( {recent.length ?
{t.recent}
: null} {recent.map((item) => ( } hint={ item.path === currentPath ? ( ) : ( baseName(dirName(item.path)) ) } onSelect={() => (item.path === currentPath ? onClose() : onOpen(item.path))} > {baseName(item.path)} ))} {recent.length ?
: null} } onSelect={onBrowse}> {t.openFile}
); } export function MoreMenu({ t, zoomable, zoomMode, onFit, onFind, onReload, onClose, }: { t: Strings; zoomable: boolean; zoomMode: FitMode | null | undefined; onFit(mode: FitMode): void; onFind(): void; onReload(): void; onClose(): void; }) { return ( {zoomable ? ( <> onFit("width")}> {t.fitWidth} onFit("page")}> {t.fitPage} onFit("actual")}> {t.actualSize}
) : null} } hint="⌘F" onSelect={onFind}> {t.find} } onSelect={onReload}> {t.reload}
); }