({
projectName = 'Untitled',
uiRegistry,
messageHub,
pluginManager,
commandManager,
onNewScene,
onOpenScene,
onSaveScene,
onSaveSceneAs,
onOpenProject,
onCloseProject,
onExit,
onOpenPluginManager,
onOpenProfiler: _onOpenProfiler,
onOpenPortManager,
onOpenSettings,
onToggleDevtools,
onOpenAbout,
onCreatePlugin,
onReloadPlugins,
onOpenBuildSettings,
onOpenRenderDebug
}: TitleBarProps)
| 42 | } |
| 43 | |
| 44 | export function TitleBar({ |
| 45 | projectName = 'Untitled', |
| 46 | uiRegistry, |
| 47 | messageHub, |
| 48 | pluginManager, |
| 49 | commandManager, |
| 50 | onNewScene, |
| 51 | onOpenScene, |
| 52 | onSaveScene, |
| 53 | onSaveSceneAs, |
| 54 | onOpenProject, |
| 55 | onCloseProject, |
| 56 | onExit, |
| 57 | onOpenPluginManager, |
| 58 | onOpenProfiler: _onOpenProfiler, |
| 59 | onOpenPortManager, |
| 60 | onOpenSettings, |
| 61 | onToggleDevtools, |
| 62 | onOpenAbout, |
| 63 | onCreatePlugin, |
| 64 | onReloadPlugins, |
| 65 | onOpenBuildSettings, |
| 66 | onOpenRenderDebug |
| 67 | }: TitleBarProps) { |
| 68 | const { t } = useLocale(); |
| 69 | const [openMenu, setOpenMenu] = useState<string | null>(null); |
| 70 | const [pluginMenuItems, setPluginMenuItems] = useState<PluginMenuItem[]>([]); |
| 71 | const [isMaximized, setIsMaximized] = useState(false); |
| 72 | const [canUndo, setCanUndo] = useState(false); |
| 73 | const [canRedo, setCanRedo] = useState(false); |
| 74 | const menuRef = useRef<HTMLDivElement>(null); |
| 75 | const appWindow = getCurrentWindow(); |
| 76 | |
| 77 | // Update undo/redo state | 更新撤销/重做状态 |
| 78 | const updateUndoRedoState = useCallback(() => { |
| 79 | if (commandManager) { |
| 80 | setCanUndo(commandManager.canUndo()); |
| 81 | setCanRedo(commandManager.canRedo()); |
| 82 | } |
| 83 | }, [commandManager]); |
| 84 | |
| 85 | // Handle undo | 处理撤销 |
| 86 | const handleUndo = useCallback(() => { |
| 87 | if (commandManager && commandManager.canUndo()) { |
| 88 | commandManager.undo(); |
| 89 | updateUndoRedoState(); |
| 90 | } |
| 91 | }, [commandManager, updateUndoRedoState]); |
| 92 | |
| 93 | // Handle redo | 处理重做 |
| 94 | const handleRedo = useCallback(() => { |
| 95 | if (commandManager && commandManager.canRedo()) { |
| 96 | commandManager.redo(); |
| 97 | updateUndoRedoState(); |
| 98 | } |
| 99 | }, [commandManager, updateUndoRedoState]); |
| 100 | |
| 101 | // Update undo/redo state periodically | 定期更新撤销/重做状态 |
nothing calls this directly
no test coverage detected