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'
|
2025-05-08 15:31:37 +08:00
|
|
|
import type { HeaderInHistoryProps } from './header-in-view-history'
|
2025-04-18 13:59:12 +08:00
|
|
|
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
|
2025-05-08 15:31:37 +08:00
|
|
|
viewHistory?: HeaderInHistoryProps
|
2025-04-18 13:59:12 +08:00
|
|
|
restoring?: HeaderInRestoringProps
|
|
|
|
}
|
|
|
|
const Header = ({
|
|
|
|
normal: normalProps,
|
2025-05-08 15:31:37 +08:00
|
|
|
viewHistory: viewHistoryProps,
|
2025-04-18 13:59:12 +08:00
|
|
|
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-05-08 15:31:37 +08:00
|
|
|
<HeaderInHistory
|
|
|
|
{...viewHistoryProps}
|
|
|
|
/>
|
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
|