feat: implement loading states in SpaceOAuthCallback and HomeSidebar components using Suspense

This commit is contained in:
Junyan Qin
2026-01-01 13:06:04 +08:00
parent 898144e9f4
commit 679e549b1d
2 changed files with 47 additions and 4 deletions
@@ -1,7 +1,7 @@
'use client';
import styles from './HomeSidebar.module.css';
import { useEffect, useState } from 'react';
import { useEffect, useState, Suspense } from 'react';
import {
SidebarChild,
SidebarChildVO,
@@ -20,6 +20,7 @@ import {
Lightbulb,
LogOut,
KeyRound,
Loader2,
} from 'lucide-react';
import { useTheme } from 'next-themes';
@@ -58,7 +59,7 @@ function compareVersions(v1: string, v2: string): boolean {
}
// TODO 侧边导航栏要加动画
export default function HomeSidebar({
function HomeSidebarContent({
onSelectedChangeAction,
}: {
onSelectedChangeAction: (sidebarChild: SidebarChildVO) => void;
@@ -482,3 +483,25 @@ export default function HomeSidebar({
</div>
);
}
function SidebarLoadingFallback() {
return (
<div className={`${styles.sidebarContainer}`}>
<div className="flex items-center justify-center h-full">
<Loader2 className="h-6 w-6 animate-spin" />
</div>
</div>
);
}
export default function HomeSidebar({
onSelectedChangeAction,
}: {
onSelectedChangeAction: (sidebarChild: SidebarChildVO) => void;
}) {
return (
<Suspense fallback={<SidebarLoadingFallback />}>
<HomeSidebarContent onSelectedChangeAction={onSelectedChangeAction} />
</Suspense>
);
}