Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ’„ style(skeleton): align loading states with settled layouts (#19110)

Innei8af9214eef26
diff --git a/src/features/Eval/BenchmarkDetailLoading.tsx b/src/features/Eval/BenchmarkDetailLoading.tsx
new file mode 100644
index 00000000000..fa0d74cfca0
--- /dev/null
+++ b/src/features/Eval/BenchmarkDetailLoading.tsx
@@ -0,0 +1,128 @@
+import { Flexbox } from '@lobehub/ui';
+import { Skeleton } from '@lobehub/ui/base-ui';
+import { Card } from 'antd';
+import { createStaticStyles, cssVar } from 'antd-style';
+
+const styles = createStaticStyles(({ css }) => ({
+ header: css`
+ min-height: 66px;
+ `,
+ hero: css`
+ min-height: 106px;
+ padding: 20px;
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ runsSection: css`
+ border-style: dashed;
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ section: css`
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+
+ height: 287px;
+ padding-block: 64px;
+ padding-inline: 24px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ text-align: center;
+ `,
+ sectionTitle: css`
+ flex-shrink: 0;
+ align-items: center;
+ min-height: 25px;
+ `,
+ statCard: css`
+ min-height: 146px;
+ `,
+}));
+
+const BenchmarkDetailLoading = () => (
+ <>
+ <Flexbox className={styles.header} gap={16}>
+ <Flexbox horizontal align="start" justify={'space-between'}>
+ <Flexbox horizontal align="start" gap={12}>
+ <Skeleton.Avatar
+ shape="square"
+ size={40}
+ style={{ borderRadius: cssVar.borderRadiusLG }}
+ />
+ <Flexbox flex={1} gap={8}>
+ <Skeleton height={24} width={200} />
+ <Skeleton height={14} width={320} />
+ </Flexbox>
+ </Flexbox>
+ <Flexbox horizontal gap={8}>
+ <Skeleton height={28} width={72} />
+ <Skeleton height={28} width={28} />
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+
+ <Flexbox horizontal align={'center'} className={styles.hero} justify={'space-between'}>
+ <Flexbox gap={8}>
+ <Skeleton height={32} width={64} />
+ <Skeleton height={14} width={144} />
+ </Flexbox>
+ </Flexbox>
+
+ <Flexbox horizontal gap={12}>
+ {[1, 2, 3, 4].map((i) => (
+ <Card
+ className={styles.statCard}
+ key={i}
+ styles={{ body: { padding: 16 } }}
+ style={{
+ border: `1px solid ${cssVar.colorBorderSecondary}`,
+ borderRadius: cssVar.borderRadius,
+ flex: 1,
+ minWidth: 0,
+ }}
+ >
+ <Flexbox gap={12}>
+ <Flexbox horizontal align="center" gap={8}>
+ <Skeleton.Avatar
+ shape="square"
+ size={36}
+ style={{ borderRadius: cssVar.borderRadius }}
+ />
+ <Skeleton height={14} width={80} />
+ </Flexbox>
+ <Flexbox gap={4}>
+ <Skeleton height={24} width={60} />
+ <Skeleton height={12} width={100} />
+ </Flexbox>
+ </Flexbox>
+ </Card>
+ ))}
+ </Flexbox>
+
+ <Flexbox className={styles.sectionTitle}>
+ <Skeleton height={18} width={80} />
+ </Flexbox>
+ <Flexbox className={styles.section} gap={16}>
+ <Skeleton.Avatar shape={'square'} size={56} style={{ borderRadius: cssVar.borderRadiusLG }} />
+ <Flexbox align={'center'} gap={6}>
+ <Skeleton height={16} width={112} />
+ <Skeleton height={12} width={216} />
+ </Flexbox>
+ <Skeleton height={28} width={112} />
+ </Flexbox>
+ <Flexbox className={styles.sectionTitle}>
+ <Skeleton height={18} width={56} />
+ </Flexbox>
+ <Flexbox className={`${styles.section} ${styles.runsSection}`} gap={16}>
+ <Skeleton.Avatar shape={'square'} size={56} style={{ borderRadius: cssVar.borderRadiusLG }} />
+ <Flexbox align={'center'} gap={6}>
+ <Skeleton height={16} width={96} />
+ <Skeleton height={12} width={240} />
+ </Flexbox>
+ <Skeleton height={28} width={104} />
+ </Flexbox>
+ </>
+);
+
+export default BenchmarkDetailLoading;
diff --git a/src/features/Eval/index.ts b/src/features/Eval/index.ts
new file mode 100644
index 00000000000..0611989cbb9
--- /dev/null
+++ b/src/features/Eval/index.ts
@@ -0,0 +1 @@
+export { default as BenchmarkDetailLoading } from './BenchmarkDetailLoading';
diff --git a/src/features/ResourceHome/Skeleton.tsx b/src/features/ResourceHome/Skeleton.tsx
new file mode 100644
index 00000000000..37eb2d5cc88
--- /dev/null
+++ b/src/features/ResourceHome/Skeleton.tsx
@@ -0,0 +1,49 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { useLocation, useSearchParams } from 'react-router';
+
+import SkeletonBar from '@/components/Skeleton/Bar';
+import ListViewSkeleton from '@/features/ResourceManager/components/Explorer/ListView/Skeleton';
+import MasonryViewSkeleton from '@/features/ResourceManager/components/Explorer/MasonryView/Skeleton';
+import { useMasonryColumnCount } from '@/features/ResourceManager/components/Explorer/useMasonryColumnCount';
+import WorkGallerySkeleton from '@/features/WorkGallery/Skeleton';
+import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+
+import { resolveResourceSkeletonView } from './skeletonView';
+
+const ResourceCategorySkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => {
+ const { pathname } = useLocation();
+ const [searchParams] = useSearchParams();
+ const columnCount = useMasonryColumnCount();
+ const view = resolveResourceSkeletonView(pathname, searchParams.get('view'));
+
+ if (view === 'works') return <WorkGallerySkeleton />;
+
+ return (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {chrome !== 'body' && (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ height={44}
+ justify={'space-between'}
+ paddingInline={16}
+ >
+ <SkeletonBar height={20} width={144} />
+ <SkeletonBar height={28} width={72} />
+ </Flexbox>
+ )}
+ <Flexbox flex={1} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {view === 'masonry' ? (
+ <MasonryViewSkeleton columnCount={columnCount} />
+ ) : (
+ <ListViewSkeleton showUploader={!pathname.startsWith('/resource')} />
+ )}
+ </Flexbox>
+ </Flexbox>
+ );
+};
+
+export default ResourceCategorySkeleton;
diff --git a/src/features/ResourceHome/skeletonView.test.ts b/src/features/ResourceHome/skeletonView.test.ts
new file mode 100644
index 00000000000..e6547feb5f5
--- /dev/null
+++ b/src/features/ResourceHome/skeletonView.test.ts
@@ -0,0 +1,14 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveResourceSkeletonView } from './skeletonView';
+
+describe('resolveResourceSkeletonView', () => {
+ it.each([
+ ['/resource/files', null, 'list'],
+ ['/resource/images', null, 'masonry'],
+ ['/resource/images', 'list', 'list'],
+ ['/resource/works', null, 'works'],
+ ])('uses the settled view for %s', (pathname, requestedView, expected) => {
+ expect(resolveResourceSkeletonView(pathname, requestedView)).toBe(expected);
+ });
+});
diff --git a/src/features/ResourceHome/skeletonView.ts b/src/features/ResourceHome/skeletonView.ts
new file mode 100644
index 00000000000..040d17adf5f
--- /dev/null
+++ b/src/features/ResourceHome/skeletonView.ts
@@ -0,0 +1,16 @@
+import { getDefaultResourceViewMode } from '@/features/ResourceManager/components/Explorer/viewMode';
+import type { FilesTabs } from '@/types/files';
+
+export type ResourceSkeletonView = 'list' | 'masonry' | 'works';
+
+export const resolveResourceSkeletonView = (
+ pathname: string,
+ requestedView: string | null,
+): ResourceSkeletonView => {
+ const segment = pathname.split('/').findLast(Boolean);
+
+ if (segment === 'works') return 'works';
+ if (requestedView === 'list' || requestedView === 'masonry') return requestedView;
+
+ return getDefaultResourceViewMode(segment as FilesTabs);
+};
diff --git a/src/features/ResourceManager/components/Explorer/hooks/useViewMode.ts b/src/features/ResourceManager/components/Explorer/hooks/useViewMode.ts
index 6de7859726d..6392de08f68 100644
--- a/src/features/ResourceManager/components/Explorer/hooks/useViewMode.ts
+++ b/src/features/ResourceManager/components/Explorer/hooks/useViewMode.ts
@@ -3,18 +3,8 @@ import { useCallback, useEffect } from 'react';
import { useResourceManagerStore } from '@/features/ResourceManager/store';
import { type ViewMode } from '@/features/ResourceManager/store/initialState';
import { parseAsStringEnum, useQueryState } from '@/hooks/useQueryParam';
-import { FilesTabs } from '@/types/files';
-/**
- * Categories whose content is media first β€” they open in the gallery
- * (masonry) view unless the URL explicitly asks for another one.
- */
-const GALLERY_FIRST_CATEGORIES = new Set<FilesTabs>([
- FilesTabs.Audios,
- FilesTabs.Images,
- FilesTabs.Videos,
- FilesTabs.Websites,
-]);
+import { getDefaultResourceViewMode } from '../viewMode';
/**
* Hook to manage view mode with URL query sync
@@ -29,8 +19,7 @@ export const useViewMode = (): [ViewMode, (mode: ViewMode) => void] => {
// Inside a library the category filter is not applied, so the stale home
// category must not leak its gallery default there.
- const defaultViewMode: ViewMode =
- !libraryId && GALLERY_FIRST_CATEGORIES.has(category) ? 'masonry' : 'list';
+ const defaultViewMode = getDefaultResourceViewMode(category, libraryId);
// Sync view mode with URL query parameter
const [viewModeFromUrl, setViewModeInUrl] = useQueryState(
diff --git a/src/features/ResourceManager/components/Explorer/viewMode.ts b/src/features/ResourceManager/components/Explorer/viewMode.ts
new file mode 100644
index 00000000000..1f4f1ec704e
--- /dev/null
+++ b/src/features/ResourceManager/components/Explorer/viewMode.ts
@@ -0,0 +1,12 @@
+import type { ViewMode } from '@/features/ResourceManager/store/initialState';
+import { FilesTabs } from '@/types/files';
+
+const GALLERY_FIRST_CATEGORIES = new Set<FilesTabs>([
+ FilesTabs.Audios,
+ FilesTabs.Images,
+ FilesTabs.Videos,
+ FilesTabs.Websites,
+]);
+
+export const getDefaultResourceViewMode = (category: FilesTabs, libraryId?: string): ViewMode =>
+ !libraryId && GALLERY_FIRST_CATEGORIES.has(category) ? 'masonry' : 'list';
diff --git a/src/features/Settings/appearance/features/Font/index.tsx b/src/features/Settings/appearance/features/Font/index.tsx
index 59ee3c5d968..b18f473d4b9 100644
--- a/src/features/Settings/appearance/features/Font/index.tsx
+++ b/src/features/Settings/appearance/features/Font/index.tsx
@@ -2,7 +2,7 @@
import { isDesktop } from '@lobechat/const';
import type { FormGroupItemType } from '@lobehub/ui';
-import { Form } from '@lobehub/ui';
+import { Flexbox, Form } from '@lobehub/ui';
import { Select, Skeleton } from '@lobehub/ui/base-ui';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -24,6 +24,8 @@ const wrapperCol = {
},
};
+const loadingTextStyle = { marginBlock: 1.5 };
+
const FontSettings = memo(() => {
const { t } = useTranslation('setting');
const [fontFamily, monospaceFontFamily] = useUserStore((s) => [
@@ -50,7 +52,63 @@ const FontSettings = memo(() => {
value: monospaceFontFamily,
});
- if (!isUserStateInit) return <Skeleton.Text rows={5} />;
+ if (!isUserStateInit) {
+ const loadingFont: FormGroupItemType = {
+ children: [
+ ...(isDesktop
+ ? [
+ {
+ children: <Skeleton height={32} width={320} />,
+ desc: <Skeleton height={12} style={loadingTextStyle} width={240} />,
+ label: <Skeleton height={16} style={loadingTextStyle} width={96} />,
+ minWidth: undefined,
+ },
+ {
+ children: <Skeleton height={32} width={320} />,
+ desc: <Skeleton height={12} style={loadingTextStyle} width={280} />,
+ label: <Skeleton height={16} style={loadingTextStyle} width={128} />,
+ minWidth: undefined,
+ },
+ ]
+ : []),
+ {
+ children: (
+ <Flexbox gap={16} width={'100%'}>
+ <Flexbox gap={24}>
+ <Skeleton height={4} width={'100%'} />
+ <Flexbox horizontal align={'center'} justify={'space-between'}>
+ <Skeleton height={14} width={12} />
+ <Skeleton height={14} width={64} />
+ <Skeleton height={14} width={12} />
+ </Flexbox>
+ </Flexbox>
+ <Flexbox justify={'center'} style={{ height: 30 }}>
+ <Skeleton height={16} style={{ maxWidth: '100%' }} width={400} />
+ </Flexbox>
+ </Flexbox>
+ ),
+ desc: <Skeleton height={12} style={loadingTextStyle} width={144} />,
+ label: <Skeleton height={16} style={loadingTextStyle} width={72} />,
+ layout: 'vertical',
+ minWidth: '100%',
+ wrapperCol,
+ },
+ ],
+ extra: <Skeleton height={16} width={136} />,
+ title: <Skeleton height={18} width={48} />,
+ };
+
+ return (
+ <Form
+ aria-busy
+ collapsible={false}
+ items={[loadingFont]}
+ itemsType={'group'}
+ variant={'filled'}
+ {...FORM_STYLE}
+ />
+ );
+ }
const font: FormGroupItemType = {
children: [
diff --git a/src/features/WorkGallery/Skeleton.tsx b/src/features/WorkGallery/Skeleton.tsx
new file mode 100644
index 00000000000..2086dc4763e
--- /dev/null
+++ b/src/features/WorkGallery/Skeleton.tsx
@@ -0,0 +1,64 @@
+import { Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { memo } from 'react';
+
+import ArticleSkeleton from '@/components/Skeleton/Article';
+
+const styles = createStaticStyles(({ css }) => ({
+ card: css`
+ aspect-ratio: 0.9;
+ padding: 12px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: 16px;
+
+ background: ${cssVar.colorBgContainer};
+ `,
+ grid: css`
+ display: grid;
+ grid-template-columns: repeat(3, minmax(280px, 1fr));
+ gap: 16px;
+ width: 100%;
+
+ @media (width >= 1600px) {
+ grid-template-columns: repeat(4, minmax(280px, 1fr));
+ }
+
+ @media (width <= 920px) {
+ grid-template-columns: repeat(2, minmax(280px, 1fr));
+ }
+
+ @media (width <= 620px) {
+ grid-template-columns: minmax(0, 1fr);
+ }
+ `,
+ scroll: css`
+ overflow: hidden auto;
+ flex: 1;
+
+ min-height: 0;
+ padding-block: 8px 24px;
+ padding-inline: 24px;
+ `,
+}));
+
+export const WorkGalleryCardsSkeleton = memo<{ count?: number }>(({ count = 8 }) => (
+ <div className={styles.grid}>
+ {Array.from({ length: count }).map((_, index) => (
+ <div className={styles.card} key={index}>
+ <ArticleSkeleton rows={6} />
+ </div>
+ ))}
+ </div>
+));
+
+WorkGalleryCardsSkeleton.displayName = 'WorkGalleryCardsSkeleton';
+
+const WorkGallerySkeleton = () => (
+ <Flexbox aria-busy height={'100%'}>
+ <Flexbox className={styles.scroll}>
+ <WorkGalleryCardsSkeleton />
+ </Flexbox>
+ </Flexbox>
+);
+
+export default WorkGallerySkeleton;
diff --git a/src/features/WorkGallery/index.tsx b/src/features/WorkGallery/index.tsx
index 6bb35b63921..09733a0ae40 100644
--- a/src/features/WorkGallery/index.tsx
+++ b/src/features/WorkGallery/index.tsx
@@ -8,13 +8,13 @@ import { PackageOpenIcon, TriangleAlertIcon } from 'lucide-react';
import { memo, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { ArticleSkeleton } from '@/components/Skeleton';
import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';
import { useFetchAgentList } from '@/hooks/useFetchAgentList';
import { formatWorkVersionCost } from '@/utils/workVersionCost';
import type { WorkGalleryKey } from './const';
import { useWorkspaceWorksInfinite } from './hooks';
+import WorkGallerySkeleton, { WorkGalleryCardsSkeleton } from './Skeleton';
import { useOpenWork } from './useOpenWork';
import WorkPreviewCard from './WorkPreviewCard';
@@ -125,14 +125,6 @@ const styles = createStaticStyles(({ css }) => ({
padding-block: 8px 24px;
padding-inline: 24px;
`,
- skeletonCard: css`
- aspect-ratio: 0.9;
- padding: 12px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 16px;
-
- background: ${cssVar.colorBgContainer};
- `,
}));
interface AgentFilterProps {
@@ -168,18 +160,6 @@ const AgentFilter = memo<AgentFilterProps>(({ active, agentId, onSelect }) => {
AgentFilter.displayName = 'AgentFilter';
-const SkeletonCards = memo<{ count: number }>(({ count }) => (
- <div className={styles.cardList}>
- {Array.from({ length: count }).map((_, index) => (
- <div className={styles.skeletonCard} key={index}>
- <ArticleSkeleton rows={6} />
- </div>
- ))}
- </div>
-));
-
-SkeletonCards.displayName = 'SkeletonCards';
-
interface WorkGalleryProps {
galleryKey: WorkGalleryKey;
}
@@ -268,8 +248,6 @@ const WorkGallery = memo<WorkGalleryProps>(({ galleryKey }) => {
</Center>
);
- if (isLoadingInitial && items.length === 0) return <SkeletonCards count={8} />;
-
if (items.length === 0)
return (
<Center className={styles.emptyState}>
@@ -315,7 +293,7 @@ const WorkGallery = memo<WorkGalleryProps>(({ galleryKey }) => {
<div aria-hidden ref={sentinelRef} style={{ height: 1 }} />
{isLoadingMore ? (
<Flexbox style={{ marginBlockStart: 12 }}>
- <SkeletonCards count={4} />
+ <WorkGalleryCardsSkeleton count={4} />
</Flexbox>
) : error ? (
<div className={styles.loadMoreError}>
@@ -329,7 +307,9 @@ const WorkGallery = memo<WorkGalleryProps>(({ galleryKey }) => {
);
};
- return (
+ return isLoadingInitial && items.length === 0 ? (
+ <WorkGallerySkeleton />
+ ) : (
<Flexbox className={styles.container}>
{agentIds.length > 0 && (
<Flexbox horizontal align={'center'} className={styles.filterBar} gap={4}>
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/index.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/index.tsx
index 6ecc2373ff1..9b41275f05a 100644
--- a/src/routes/(main)/eval/bench/[benchmarkId]/index.tsx
+++ b/src/routes/(main)/eval/bench/[benchmarkId]/index.tsx
@@ -1,8 +1,6 @@
'use client';
import { Flexbox } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
-import { Card } from 'antd';
import { createStaticStyles, cssVar } from 'antd-style';
import {
Activity,
@@ -21,6 +19,7 @@ import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
+import { BenchmarkDetailLoading } from '@/features/Eval';
import { runSelectors, useEvalStore } from '@/store/eval';
import BenchmarkHeader from './features/BenchmarkHeader';
@@ -114,58 +113,8 @@ const BenchmarkDetail = memo(() => {
if (!benchmark)
return (
- <Flexbox className={styles.container} gap={24} height="100%" width="100%">
- {/* Header skeleton */}
- <Flexbox gap={16}>
- <Flexbox horizontal align="start" gap={12}>
- <Skeleton.Avatar
- shape="square"
- size={40}
- style={{ borderRadius: cssVar.borderRadiusLG }}
- />
- <Flexbox flex={1} gap={8}>
- <Skeleton height={24} width={200} />
- <Skeleton height={14} width={320} />
- </Flexbox>
- </Flexbox>
- </Flexbox>
-
- {/* Stats cards skeleton */}
- <Flexbox horizontal gap={12}>
- {[1, 2, 3, 4].map((i) => (
- <Card
- key={i}
- styles={{ body: { padding: 16 } }}
- style={{
- border: `1px solid ${cssVar.colorBorderSecondary}`,
- borderRadius: cssVar.borderRadius,
- flex: 1,
- minWidth: 0,
- }}
- >
- <Flexbox gap={12}>
- <Flexbox horizontal align="center" gap={8}>
- <Skeleton.Avatar
- shape="square"
- size={36}
- style={{ borderRadius: cssVar.borderRadius }}
- />
- <Skeleton height={14} width={80} />
- </Flexbox>
- <Flexbox gap={4}>
- <Skeleton height={24} width={60} />
- <Skeleton height={12} width={100} />
- </Flexbox>
- </Flexbox>
- </Card>
- ))}
- </Flexbox>
-
- {/* Section skeletons */}
- <Skeleton height={16} width={80} />
- <Skeleton height={64} width={'100%'} />
- <Skeleton height={16} width={80} />
- <Skeleton height={64} width={'100%'} />
+ <Flexbox aria-busy className={styles.container} gap={24} height="100%" width="100%">
+ <BenchmarkDetailLoading />
</Flexbox>
);
diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsx
index 9e3b9f42435..68f7e9a5424 100644
--- a/src/spa/router/desktopRouter.shared.tsx
+++ b/src/spa/router/desktopRouter.shared.tsx
@@ -16,7 +16,14 @@ import {
ShapesIcon,
SquarePlay,
} from 'lucide-react';
-import { createElement, isValidElement, type ReactElement, type ReactNode, Suspense } from 'react';
+import {
+ createElement,
+ isValidElement,
+ lazy,
+ type ReactElement,
+ type ReactNode,
+ Suspense,
+} from 'react';
import type { RouteObject } from 'react-router';
import {
@@ -64,10 +71,18 @@ import {
} from '@/routes/(main)/group/features/routeMeta';
import AppShellSkeleton, { APP_SHELL_FALLBACK_ID } from '@/spa/BootShell/AppShellSkeleton';
import { loadRouteWithBuiltinToolSurfaces } from '@/spa/initialize/toolSurfaces';
-import { routeMeta } from '@/spa/router/routeMeta';
+import { routeMeta, type RouteSkeletonProps } from '@/spa/router/routeMeta';
import { SettingsTabs } from '@/store/global/initialState';
import { dynamicElement, dynamicLayout, ErrorBoundary, redirectElement } from '@/utils/router';
+const LazyResourceCategorySkeleton = lazy(() => import('@/features/ResourceHome/Skeleton'));
+
+export const ResourceCategorySkeleton = (props: RouteSkeletonProps) => (
+ <Suspense fallback={null}>
+ <LazyResourceCategorySkeleton {...props} />
+ </Suspense>
+);
+
const agentChatElement = dynamicElement(
() => loadRouteWithBuiltinToolSurfaces(() => import('@/routes/(main)/agent')),
'Desktop > Chat',
@@ -664,6 +679,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
'Desktop > Resource > Home > Layout',
{ preloadId: 'resource' },
),
+ handle: { meta: routeMeta({ Skeleton: ResourceCategorySkeleton }) },
},
// Library routes (knowledge base detail)
{
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 48f315d5221..725c5a7fb5a 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -32,7 +32,7 @@ import {
createMainAreaChildren as createElectronMainAreaChildren,
desktopRoutes as electronDesktopRoutes,
} from './desktopRouter.config.desktop';
-import { createMainAreaRouteFactory } from './desktopRouter.shared';
+import { createMainAreaRouteFactory, ResourceCategorySkeleton } from './desktopRouter.shared';
type MainAreaFactory = () => RouteObject[];
@@ -390,6 +390,9 @@ describe('desktop router shared definition', () => {
['/apps', AppsSkeleton],
['/memory', MemorySkeleton],
['/resource', ResourceHomeSkeleton],
+ ['/resource/files', ResourceCategorySkeleton],
+ ['/resource/images', ResourceCategorySkeleton],
+ ['/resource/works', ResourceCategorySkeleton],
] as const) {
const matches = matchRoutes(getRoutes(pathname), pathname);
expect(