mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-28 03:44:27 +00:00
feat(ui): unify header bar into a single route-aware component in __root.tsx
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
} from '@tanstack/react-router'
|
||||
import { HomeIcon } from 'lucide-react'
|
||||
import { useEffect } from 'react'
|
||||
import { TopNav } from '@/ui/components/top-nav'
|
||||
|
||||
function RootComponent() {
|
||||
const user = useAuthStore((state) => state.user)
|
||||
@@ -47,7 +48,7 @@ function RootComponent() {
|
||||
}, [teamId, projectId, setTeamId, ensureTeamIdForProject])
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex h-screen w-full bg-background overflow-hidden">
|
||||
<Toaster />
|
||||
<DualSidebar>
|
||||
<DualSidebarItem
|
||||
@@ -77,10 +78,13 @@ function RootComponent() {
|
||||
<UploadTasks />
|
||||
</DualSidebarItem>
|
||||
</DualSidebar>
|
||||
<main className="md:pl-16">
|
||||
<Outlet />
|
||||
</main>
|
||||
</>
|
||||
<div className="flex flex-col flex-1 md:pl-16 overflow-hidden relative">
|
||||
<TopNav />
|
||||
<main className="flex-1 overflow-hidden relative">
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { InferRequestType, InferResponseType } from 'hono/client'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { BreadcrumbNav } from '@/ui/components/breadcrumb-nav'
|
||||
import { FileViewer } from '@/ui/components/file-viewer'
|
||||
import { FileViewerLeftSidebar } from '@/ui/components/file-viewer-left-sidebar'
|
||||
import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sidebar'
|
||||
@@ -27,7 +26,6 @@ function FileViewPage() {
|
||||
const videoRef = useRef<Player | null>(null)
|
||||
const {
|
||||
fileViewRightSidebarCollapsed: isRightSidebarCollapsed,
|
||||
setFileViewRightSidebarCollapsed: setIsRightSidebarCollapsed,
|
||||
fileViewLeftSidebarCollapsed: isLeftSidebarCollapsed,
|
||||
setFileViewLeftSidebarCollapsed: setIsLeftSidebarCollapsed,
|
||||
} = useUiStore()
|
||||
@@ -96,18 +94,6 @@ function FileViewPage() {
|
||||
placeholderData: keepPreviousData,
|
||||
})
|
||||
|
||||
const { data: versionsList } = useQuery({
|
||||
queryKey: ['projects', projectId, 'version_stacks', fileId, 'versions'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.projects[':projectId'].version_stacks[':stackId'].versions.$get({
|
||||
param: { projectId: projectId, stackId: fileId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch versions')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!projectId && !!fileId && !!versionAssetId,
|
||||
})
|
||||
|
||||
const { data: projectInfo } = useQuery({
|
||||
queryKey: ['projects', projectId],
|
||||
queryFn: async () => {
|
||||
@@ -123,7 +109,6 @@ function FileViewPage() {
|
||||
const isError = isStackError || (!!versionAssetId && isVersionError)
|
||||
const isFetching = isStackFetching || (!!versionAssetId && isVersionFetching)
|
||||
const fileData = versionData || stackData
|
||||
const versionsDataList = versionAssetId ? versionsList : stackData?.versionStack?.versions
|
||||
|
||||
if (isLoading && !fileData) {
|
||||
return <div>Loading...</div>
|
||||
@@ -167,28 +152,7 @@ function FileViewPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen flex-col bg-background">
|
||||
<BreadcrumbNav
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectInfo.name ?? ''}
|
||||
ancestorFolders={fileData.ancestorFolders ?? []}
|
||||
currentAsset={{
|
||||
name: fileData.name,
|
||||
type: 'file',
|
||||
version: versionsDataList
|
||||
? (versionsDataList.find((v) => v.id === activeFileId)?.version ??
|
||||
versionsDataList.length)
|
||||
: undefined,
|
||||
}}
|
||||
isRootFolder={false}
|
||||
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
||||
onLeftSidebarToggle={() => setIsLeftSidebarCollapsed(!isLeftSidebarCollapsed)}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
onRightSidebarToggle={() => setIsRightSidebarCollapsed(!isRightSidebarCollapsed)}
|
||||
fileId={fileId}
|
||||
versions={versionsDataList}
|
||||
/>
|
||||
<div className="flex h-full flex-col bg-background">
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
{!isLeftSidebarCollapsed && (
|
||||
<>
|
||||
|
||||
@@ -205,12 +205,8 @@ function TeamPage() {
|
||||
const safeMembers = Array.isArray(members) ? members : []
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex h-14 flex-wrap items-center justify-center gap-2 border-b border-border bg-card px-4 py-2">
|
||||
<ShumaiLogo className="w-10 h-10 text-orange-600" />
|
||||
</div>
|
||||
<div className="p-4">
|
||||
<div className="flex flex-wrap items-center justify-between mb-4 gap-4">
|
||||
<div className="p-4">
|
||||
<div className="flex flex-wrap items-center justify-between mb-4 gap-4">
|
||||
<h1 className="text-2xl font-bold">Projects</h1>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<div
|
||||
@@ -379,7 +375,6 @@ function TeamPage() {
|
||||
onInvite={handleInvite}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user