- 新增 loading-animation.tsx 组件,从 public/load.html 转换 - 动画特性: SVG路径逐条绘制 + 渐变填充,最少展示1.5秒 - 替换 homepage/layout.tsx, workspace/redirect.tsx, protected-route.tsx 中的全屏加载 - 修复 sidebar-user.tsx 中 Invitations 按钮在缩回状态下的居中问题
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import {Outlet} from 'react-router-dom';
|
|
import {useQuery} from '@tanstack/react-query';
|
|
import {workspaceList, workspaceInfo} from '@/client';
|
|
import type {WorkspaceInfoResponse} from '@/client';
|
|
import {WorkspaceSidebar} from '@/components/layout/workspace-sidebar';
|
|
import LoadingAnimation from '@/components/ui/loading-animation';
|
|
|
|
export default function HomePageLayout() {
|
|
const {data, isLoading} = useQuery({
|
|
queryKey: ['workspaceList'],
|
|
queryFn: async () => {
|
|
const resp = await workspaceList();
|
|
return resp.data?.data;
|
|
},
|
|
});
|
|
|
|
const first = data?.workspaces?.[0];
|
|
const slug = first?.slug;
|
|
|
|
const {data: workspaceInfoData, isLoading: infoLoading} = useQuery({
|
|
queryKey: ['workspaceInfo', slug],
|
|
queryFn: async (): Promise<WorkspaceInfoResponse> => {
|
|
if (!slug) throw new Error('no slug');
|
|
const resp = await workspaceInfo({path: {slug}});
|
|
return resp.data!.data!;
|
|
},
|
|
enabled: !!slug,
|
|
});
|
|
|
|
if (isLoading || infoLoading) {
|
|
return <LoadingAnimation/>;
|
|
}
|
|
|
|
if (!workspaceInfoData) {
|
|
return (
|
|
<div className="flex h-screen w-full items-center justify-center bg-background">
|
|
<div className="text-muted-foreground">Loading workspace...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="flex h-screen w-full bg-background">
|
|
<WorkspaceSidebar workspace={workspaceInfoData}/>
|
|
<main className="flex-1 overflow-y-auto">
|
|
<Outlet/>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|