| 
									
										
										
										
											2025-06-24 09:10:30 +08:00
										 |  |  | import { usePathname } from 'next/navigation' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import { | 
					
						
							| 
									
										
										
										
											2024-04-28 17:09:56 +08:00
										 |  |  |   useWorkflowMode, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | } from '../hooks' | 
					
						
							| 
									
										
										
										
											2025-04-18 13:59:12 +08:00
										 |  |  | import type { HeaderInNormalProps } from './header-in-normal' | 
					
						
							|  |  |  | import HeaderInNormal from './header-in-normal' | 
					
						
							|  |  |  | import HeaderInHistory from './header-in-view-history' | 
					
						
							|  |  |  | import type { HeaderInRestoringProps } from './header-in-restoring' | 
					
						
							|  |  |  | import HeaderInRestoring from './header-in-restoring' | 
					
						
							| 
									
										
										
										
											2025-06-24 09:10:30 +08:00
										 |  |  | import { useStore } from '../store' | 
					
						
							| 
									
										
										
										
											2025-04-18 13:59:12 +08:00
										 |  |  | export type HeaderProps = { | 
					
						
							|  |  |  |   normal?: HeaderInNormalProps | 
					
						
							|  |  |  |   restoring?: HeaderInRestoringProps | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | const Header = ({ | 
					
						
							|  |  |  |   normal: normalProps, | 
					
						
							|  |  |  |   restoring: restoringProps, | 
					
						
							|  |  |  | }: HeaderProps) => { | 
					
						
							| 
									
										
										
										
											2025-06-24 09:10:30 +08:00
										 |  |  |   const pathname = usePathname() | 
					
						
							|  |  |  |   const inWorkflowCanvas = pathname.endsWith('/workflow') | 
					
						
							| 
									
										
										
										
											2024-04-28 17:09:56 +08:00
										 |  |  |   const { | 
					
						
							|  |  |  |     normal, | 
					
						
							|  |  |  |     restoring, | 
					
						
							|  |  |  |     viewHistory, | 
					
						
							|  |  |  |   } = useWorkflowMode() | 
					
						
							| 
									
										
										
										
											2025-06-24 09:10:30 +08:00
										 |  |  |   const maximizeCanvas = useStore(s => s.maximizeCanvas) | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |       className='absolute left-0 top-0 z-10 flex h-14 w-full items-center justify-between bg-mask-top2bottom-gray-50-to-transparent px-3' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     > | 
					
						
							| 
									
										
										
										
											2025-06-24 09:10:30 +08:00
										 |  |  |       {inWorkflowCanvas && maximizeCanvas && <div className='h-14 w-[52px]' />} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2024-04-28 17:09:56 +08:00
										 |  |  |         normal && ( | 
					
						
							| 
									
										
										
										
											2025-04-18 13:59:12 +08:00
										 |  |  |           <HeaderInNormal | 
					
						
							|  |  |  |             {...normalProps} | 
					
						
							|  |  |  |           /> | 
					
						
							| 
									
										
										
										
											2024-04-28 17:09:56 +08:00
										 |  |  |         ) | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         viewHistory && ( | 
					
						
							| 
									
										
										
										
											2025-04-18 13:59:12 +08:00
										 |  |  |           <HeaderInHistory /> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |         ) | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2024-04-28 17:09:56 +08:00
										 |  |  |         restoring && ( | 
					
						
							| 
									
										
										
										
											2025-04-18 13:59:12 +08:00
										 |  |  |           <HeaderInRestoring | 
					
						
							|  |  |  |             {...restoringProps} | 
					
						
							|  |  |  |           /> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |         ) | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-18 13:59:12 +08:00
										 |  |  | export default Header |