@lobehub/lobehub 2.0.0-next.213 → 2.0.0-next.214

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/apps/desktop/package.json +3 -2
  3. package/apps/desktop/src/main/const/store.ts +1 -1
  4. package/apps/desktop/src/main/controllers/SystemCtr.ts +2 -3
  5. package/apps/desktop/src/main/core/App.ts +10 -3
  6. package/apps/desktop/src/main/types/store.ts +1 -1
  7. package/changelog/v1.json +5 -0
  8. package/package.json +4 -3
  9. package/packages/builtin-tool-knowledge-base/src/client/Render/SearchKnowledgeBase/Item/index.tsx +4 -2
  10. package/packages/builtin-tool-local-system/src/client/Intervention/EditLocalFile/index.tsx +3 -2
  11. package/packages/builtin-tool-local-system/src/client/Render/EditLocalFile/index.tsx +3 -2
  12. package/packages/const/src/theme.ts +0 -2
  13. package/packages/desktop-bridge/src/routeVariants.ts +2 -9
  14. package/packages/electron-client-ipc/src/types/system.ts +1 -1
  15. package/scripts/electronWorkflow/modifiers/nextConfig.mts +41 -13
  16. package/src/app/[variants]/(auth)/_layout/index.tsx +3 -2
  17. package/src/app/[variants]/(auth)/_layout/style.ts +8 -18
  18. package/src/app/[variants]/(auth)/layout.tsx +7 -3
  19. package/src/app/[variants]/(desktop)/desktop-onboarding/_layout/index.tsx +4 -2
  20. package/src/app/[variants]/(desktop)/desktop-onboarding/_layout/style.ts +3 -0
  21. package/src/app/[variants]/(main)/_layout/DesktopLayoutContainer.tsx +3 -2
  22. package/src/app/[variants]/(main)/chat/profile/features/ProfileEditor/PluginTag.tsx +3 -2
  23. package/src/app/[variants]/(main)/community/(list)/_layout/Footer.tsx +3 -2
  24. package/src/app/[variants]/(main)/group/features/Conversation/ChatItem/Thread.tsx +3 -2
  25. package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/index.tsx +0 -1
  26. package/src/app/[variants]/(main)/group/profile/features/ProfileEditor/PluginTag.tsx +3 -2
  27. package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentItem/Editing.tsx +2 -2
  28. package/src/app/[variants]/(main)/home/_layout/Footer/index.tsx +1 -1
  29. package/src/app/[variants]/(main)/home/_layout/index.tsx +3 -2
  30. package/src/app/[variants]/(main)/home/features/CommunityAgents/Item.tsx +3 -2
  31. package/src/app/[variants]/(main)/image/_layout/ConfigPanel/components/AspectRatioSelect/index.tsx +4 -2
  32. package/src/app/[variants]/(main)/image/_layout/ConfigPanel/components/ModelSelect/ImageModelItem.tsx +3 -2
  33. package/src/app/[variants]/(main)/image/_layout/ConfigPanel/components/Select/index.tsx +4 -2
  34. package/src/app/[variants]/(main)/image/features/PromptInput/index.tsx +3 -2
  35. package/src/app/[variants]/(main)/memory/features/TimeLineView/index.tsx +9 -4
  36. package/src/app/[variants]/(main)/page/_layout/Body/List/Item/Editing.tsx +2 -2
  37. package/src/app/[variants]/(main)/settings/common/features/Common/Common.tsx +11 -11
  38. package/src/app/[variants]/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +3 -2
  39. package/src/app/[variants]/(main)/settings/stats/features/overview/ShareButton/TotalCard.tsx +4 -2
  40. package/src/app/[variants]/(mobile)/me/(home)/features/Header.tsx +6 -8
  41. package/src/app/[variants]/layout.tsx +10 -15
  42. package/src/app/[variants]/onboarding/_layout/index.tsx +3 -2
  43. package/src/app/[variants]/onboarding/features/ModeSelectionStep.tsx +3 -2
  44. package/src/app/[variants]/router/index.tsx +12 -8
  45. package/src/components/Cell/Divider.tsx +4 -2
  46. package/src/components/DataStyleModal/index.tsx +4 -2
  47. package/src/components/FeatureList/index.tsx +4 -2
  48. package/src/components/FileParsingStatus/EmbeddingStatus.tsx +3 -2
  49. package/src/components/FileParsingStatus/index.tsx +3 -2
  50. package/src/components/Notification/index.tsx +4 -2
  51. package/src/components/client/ClientOnly.tsx +17 -0
  52. package/src/features/AlertBanner/CloudBanner.tsx +4 -3
  53. package/src/features/CommandMenu/ThemeMenu.tsx +1 -1
  54. package/src/features/CommandMenu/types.ts +5 -2
  55. package/src/features/CommandMenu/useCommandMenu.ts +3 -2
  56. package/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx +3 -2
  57. package/src/features/Conversation/Messages/components/FileChunks/ChunkItem.tsx +3 -2
  58. package/src/features/Conversation/Messages/components/FileChunks/index.tsx +4 -2
  59. package/src/features/Conversation/Messages/components/SearchGrounding.tsx +3 -2
  60. package/src/features/ElectronTitlebar/hooks/useWatchThemeUpdate.ts +21 -38
  61. package/src/features/GroupChatSettings/AgentCard.tsx +3 -2
  62. package/src/features/GroupChatSettings/HostMemberCard.tsx +3 -2
  63. package/src/features/PageEditor/DiffAllToolbar.tsx +4 -2
  64. package/src/features/User/UserPanel/ThemeButton.tsx +18 -29
  65. package/src/hooks/useIsDark.ts +11 -0
  66. package/src/layout/AuthProvider/Clerk/useAppearance.ts +4 -2
  67. package/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsx +3 -2
  68. package/src/layout/GlobalProvider/AppTheme.tsx +15 -19
  69. package/src/layout/GlobalProvider/NextThemeProvider.tsx +22 -0
  70. package/src/layout/GlobalProvider/StyleRegistry.tsx +18 -13
  71. package/src/layout/GlobalProvider/index.tsx +38 -36
  72. package/src/libs/next/proxy/define-config.ts +2 -11
  73. package/src/store/global/action.test.ts +0 -15
  74. package/src/store/global/actions/__tests__/general.test.ts +0 -37
  75. package/src/store/global/actions/general.ts +0 -21
  76. package/src/store/global/initialState.ts +0 -6
  77. package/src/store/global/selectors/systemStatus.test.ts +0 -20
  78. package/src/store/global/selectors/systemStatus.ts +0 -2
  79. package/src/styles/global.ts +0 -2
  80. package/src/utils/server/routeVariants.test.ts +17 -51
  81. package/src/utils/server/routeVariants.ts +0 -1
@@ -1,8 +1,9 @@
1
1
  import { Flexbox } from '@lobehub/ui';
2
- import { useTheme, useThemeMode } from 'antd-style';
2
+ import { useTheme } from 'antd-style';
3
3
  import { Activity, type FC, type ReactNode, useEffect, useMemo, useState } from 'react';
4
4
  import { Outlet, useLocation, useNavigate } from 'react-router-dom';
5
5
 
6
+ import { useIsDark } from '@/hooks/useIsDark';
6
7
  import { useHomeStore } from '@/store/home';
7
8
 
8
9
  import RecentHydration from './RecentHydration';
@@ -14,7 +15,7 @@ interface LayoutProps {
14
15
  }
15
16
 
16
17
  const Layout: FC<LayoutProps> = ({ children }) => {
17
- const { isDarkMode } = useThemeMode();
18
+ const isDarkMode = useIsDark();
18
19
  const theme = useTheme(); // Keep for colorBgContainerSecondary (not in cssVar)
19
20
  const navigate = useNavigate();
20
21
  const { pathname } = useLocation();
@@ -1,14 +1,15 @@
1
1
  import { Avatar, Block, Flexbox, Text } from '@lobehub/ui';
2
- import { cssVar, useThemeMode } from 'antd-style';
2
+ import { cssVar } from 'antd-style';
3
3
  import { memo } from 'react';
4
4
 
5
5
  import { RECENT_BLOCK_SIZE } from '@/app/[variants]/(main)/home/features/const';
6
6
  import { DEFAULT_AVATAR } from '@/const/meta';
7
+ import { useIsDark } from '@/hooks/useIsDark';
7
8
  import { type DiscoverAssistantItem } from '@/types/discover';
8
9
 
9
10
  const CommunityAgentItem = memo<DiscoverAssistantItem>(
10
11
  ({ title, avatar, backgroundColor, author, description }) => {
11
- const { isDarkMode } = useThemeMode();
12
+ const isDarkMode = useIsDark();
12
13
 
13
14
  return (
14
15
  <Block
@@ -1,10 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  import { Block, Center, Grid, type GridProps, Text } from '@lobehub/ui';
4
- import { cssVar, useThemeMode } from 'antd-style';
4
+ import { cssVar } from 'antd-style';
5
5
  import { memo } from 'react';
6
6
  import useMergeState from 'use-merge-value';
7
7
 
8
+ import { useIsDark } from '@/hooks/useIsDark';
9
+
8
10
  export interface AspectRatioSelectProps extends Omit<GridProps, 'children' | 'onChange'> {
9
11
  defaultValue?: string;
10
12
  onChange?: (value: string) => void;
@@ -14,7 +16,7 @@ export interface AspectRatioSelectProps extends Omit<GridProps, 'children' | 'on
14
16
 
15
17
  const AspectRatioSelect = memo<AspectRatioSelectProps>(
16
18
  ({ options, onChange, value, defaultValue, ...rest }) => {
17
- const { isDarkMode } = useThemeMode();
19
+ const isDarkMode = useIsDark();
18
20
  const [active, setActive] = useMergeState('1:1', {
19
21
  defaultValue: defaultValue || '1:1',
20
22
  onChange,
@@ -1,12 +1,13 @@
1
1
  import { ModelIcon } from '@lobehub/icons';
2
2
  import { Flexbox, Text } from '@lobehub/ui';
3
3
  import { Popover } from 'antd';
4
- import { createStaticStyles, cx, useThemeMode } from 'antd-style';
4
+ import { createStaticStyles, cx } from 'antd-style';
5
5
  import { type AiModelForSelect } from 'model-bank';
6
6
  import numeral from 'numeral';
7
7
  import { memo, useMemo } from 'react';
8
8
 
9
9
  import NewModelBadge from '@/components/ModelSelect/NewModelBadge';
10
+ import { useIsDark } from '@/hooks/useIsDark';
10
11
 
11
12
  const POPOVER_MAX_WIDTH = 320;
12
13
 
@@ -59,7 +60,7 @@ const ImageModelItem = memo<ImageModelItemProps>(
59
60
  showBadge = true,
60
61
  ...model
61
62
  }) => {
62
- const { isDarkMode } = useThemeMode();
63
+ const isDarkMode = useIsDark();
63
64
 
64
65
  const priceLabel = useMemo(() => {
65
66
  // Priority 1: Use exact price
@@ -1,10 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  import { Block, Center, Grid, type GridProps, Select, Text } from '@lobehub/ui';
4
- import { cssVar, useThemeMode } from 'antd-style';
4
+ import { cssVar } from 'antd-style';
5
5
  import { type ReactNode, memo } from 'react';
6
6
  import useMergeState from 'use-merge-value';
7
7
 
8
+ import { useIsDark } from '@/hooks/useIsDark';
9
+
8
10
  export interface SizeSelectProps extends Omit<GridProps, 'children' | 'onChange'> {
9
11
  defaultValue?: 'auto' | string;
10
12
  onChange?: (value: string) => void;
@@ -26,7 +28,7 @@ const canParseAsRatio = (value: string): boolean => {
26
28
  };
27
29
 
28
30
  const SizeSelect = memo<SizeSelectProps>(({ options, onChange, value, defaultValue, ...rest }) => {
29
- const { isDarkMode } = useThemeMode();
31
+ const isDarkMode = useIsDark();
30
32
  const [active, setActive] = useMergeState('auto', {
31
33
  defaultValue,
32
34
  onChange,
@@ -2,13 +2,14 @@
2
2
 
3
3
  import { ChatInput } from '@lobehub/editor/react';
4
4
  import { Button, Flexbox, TextArea } from '@lobehub/ui';
5
- import { createStaticStyles, cx, useThemeMode } from 'antd-style';
5
+ import { createStaticStyles, cx } from 'antd-style';
6
6
  import { Sparkles } from 'lucide-react';
7
7
  import type { KeyboardEvent } from 'react';
8
8
  import { useTranslation } from 'react-i18next';
9
9
 
10
10
  import { loginRequired } from '@/components/Error/loginRequiredNotification';
11
11
  import { useGeminiChineseWarning } from '@/hooks/useGeminiChineseWarning';
12
+ import { useIsDark } from '@/hooks/useIsDark';
12
13
  import { useImageStore } from '@/store/image';
13
14
  import { createImageSelectors } from '@/store/image/selectors';
14
15
  import { useGenerationConfigParam } from '@/store/image/slices/generationConfig/hooks';
@@ -39,7 +40,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
39
40
  }));
40
41
 
41
42
  const PromptInput = ({ showTitle = false }: PromptInputProps) => {
42
- const { isDarkMode } = useThemeMode();
43
+ const isDarkMode = useIsDark();
43
44
  const { t } = useTranslation('image');
44
45
  const { value, setValue } = useGenerationConfigParam('prompt');
45
46
  const isCreating = useImageStore(createImageSelectors.isCreating);
@@ -1,11 +1,12 @@
1
1
  'use client';
2
2
 
3
- import { createStaticStyles, cx, useThemeMode } from 'antd-style';
3
+ import { createStaticStyles, cx } from 'antd-style';
4
4
  import dayjs from 'dayjs';
5
5
  import { type ReactNode, memo, useMemo } from 'react';
6
6
  import { GroupedVirtuoso } from 'react-virtuoso';
7
7
 
8
8
  import Loading from '@/app/[variants]/(main)/memory/features/Loading';
9
+ import { useIsDark } from '@/hooks/useIsDark';
9
10
 
10
11
  import { useScrollParent } from './useScrollParent';
11
12
 
@@ -31,7 +32,9 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
31
32
 
32
33
  export type GroupBy = 'day' | 'month';
33
34
 
34
- interface TimelineViewProps<T extends { capturedAt?: Date | string; createdAt?: Date | string; id: string }> {
35
+ interface TimelineViewProps<
36
+ T extends { capturedAt?: Date | string; createdAt?: Date | string; id: string },
37
+ > {
35
38
  data: T[];
36
39
  /**
37
40
  * Custom date field extractor for grouping
@@ -68,7 +71,9 @@ const getDateValue = <T extends { capturedAt?: Date | string; createdAt?: Date |
68
71
  return item.capturedAt ?? item.createdAt ?? new Date();
69
72
  };
70
73
 
71
- function TimelineViewInner<T extends { capturedAt?: Date | string; createdAt?: Date | string; id: string }>({
74
+ function TimelineViewInner<
75
+ T extends { capturedAt?: Date | string; createdAt?: Date | string; id: string },
76
+ >({
72
77
  data,
73
78
  groupBy = 'day',
74
79
  getDateForGrouping,
@@ -78,7 +83,7 @@ function TimelineViewInner<T extends { capturedAt?: Date | string; createdAt?: D
78
83
  renderHeader,
79
84
  renderItem,
80
85
  }: TimelineViewProps<T>) {
81
- const { isDarkMode } = useThemeMode();
86
+ const isDarkMode = useIsDark();
82
87
  const scrollParent = useScrollParent();
83
88
 
84
89
  const { groupCounts, sortedPeriods, groupedItems } = useMemo(() => {
@@ -1,10 +1,10 @@
1
1
  import { Block, Flexbox, Input } from '@lobehub/ui';
2
2
  import { Popover } from 'antd';
3
- import { useThemeMode } from 'antd-style';
4
3
  import { memo, useCallback, useState } from 'react';
5
4
  import { useTranslation } from 'react-i18next';
6
5
 
7
6
  import EmojiPicker from '@/components/EmojiPicker';
7
+ import { useIsDark } from '@/hooks/useIsDark';
8
8
  import { useFileStore } from '@/store/file';
9
9
  import { useGlobalStore } from '@/store/global';
10
10
  import { globalGeneralSelectors } from '@/store/global/selectors';
@@ -18,7 +18,7 @@ interface EditingProps {
18
18
 
19
19
  const Editing = memo<EditingProps>(({ documentId, title, currentEmoji, toggleEditing }) => {
20
20
  const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);
21
- const { isDarkMode } = useThemeMode();
21
+ const isDarkMode = useIsDark();
22
22
  const { t } = useTranslation('file');
23
23
 
24
24
  const editing = useFileStore((s) => s.renamingPageId === documentId);
@@ -5,6 +5,7 @@ import { Select, Skeleton } from '@lobehub/ui';
5
5
  import { Segmented, Switch } from 'antd';
6
6
  import isEqual from 'fast-deep-equal';
7
7
  import { Ban, Gauge, Loader2Icon, Monitor, Moon, Mouse, Sun, Waves } from 'lucide-react';
8
+ import { useTheme as useNextThemesTheme } from 'next-themes';
8
9
  import { memo, useState } from 'react';
9
10
  import { useTranslation } from 'react-i18next';
10
11
 
@@ -22,16 +23,15 @@ const Common = memo(() => {
22
23
  const { t } = useTranslation('setting');
23
24
 
24
25
  const general = useUserStore((s) => settingsSelectors.currentSettings(s).general, isEqual);
25
- const themeMode = useGlobalStore(systemStatusSelectors.themeMode);
26
+ const { theme, setTheme } = useNextThemesTheme();
26
27
  const language = useGlobalStore(systemStatusSelectors.language);
27
28
  const [setSettings, isUserStateInit] = useUserStore((s) => [s.setSettings, s.isUserStateInit]);
28
- const [setThemeMode, switchLocale, isStatusInit] = useGlobalStore((s) => [
29
- s.switchThemeMode,
30
- s.switchLocale,
31
- s.isStatusInit,
32
- ]);
29
+ const [switchLocale, isStatusInit] = useGlobalStore((s) => [s.switchLocale, s.isStatusInit]);
33
30
  const [loading, setLoading] = useState(false);
34
31
 
32
+ // Use the theme value from next-themes, default to 'system'
33
+ const currentTheme = theme || 'system';
34
+
35
35
  const handleLangChange = (value: LocaleMode) => {
36
36
  switchLocale(value);
37
37
  };
@@ -39,13 +39,13 @@ const Common = memo(() => {
39
39
  if (!(isStatusInit && isUserStateInit))
40
40
  return <Skeleton active paragraph={{ rows: 5 }} title={false} />;
41
41
 
42
- const theme: FormGroupItemType = {
42
+ const themeFormGroup: FormGroupItemType = {
43
43
  children: [
44
44
  {
45
45
  children: (
46
46
  <ImageSelect
47
47
  height={60}
48
- onChange={setThemeMode}
48
+ onChange={(value) => setTheme(value === 'auto' ? 'system' : value)}
49
49
  options={[
50
50
  {
51
51
  icon: Sun,
@@ -63,11 +63,11 @@ const Common = memo(() => {
63
63
  icon: Monitor,
64
64
  img: imageUrl('theme_auto.webp'),
65
65
  label: t('settingCommon.themeMode.auto'),
66
- value: 'auto',
66
+ value: 'system',
67
67
  },
68
68
  ]}
69
69
  unoptimized={isDesktop}
70
- value={themeMode}
70
+ value={currentTheme}
71
71
  width={100}
72
72
  />
73
73
  ),
@@ -173,7 +173,7 @@ const Common = memo(() => {
173
173
  <Form
174
174
  collapsible={false}
175
175
  initialValues={general}
176
- items={[theme]}
176
+ items={[themeFormGroup]}
177
177
  itemsType={'group'}
178
178
  onValuesChange={async (v) => {
179
179
  setLoading(true);
@@ -2,11 +2,12 @@ import { BRANDING_PROVIDER } from '@lobechat/business-const';
2
2
  import { ProviderCombine, ProviderIcon } from '@lobehub/icons';
3
3
  import { Avatar, Flexbox, Skeleton, Text } from '@lobehub/ui';
4
4
  import { Divider } from 'antd';
5
- import { cssVar, cx, useThemeMode } from 'antd-style';
5
+ import { cssVar, cx } from 'antd-style';
6
6
  import { memo } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
 
9
9
  import { BrandingProviderCard } from '@/business/client/features/BrandingProviderCard';
10
+ import { useIsDark } from '@/hooks/useIsDark';
10
11
  import { type AiProviderListItem } from '@/types/aiProvider';
11
12
 
12
13
  import EnableSwitch from './EnableSwitch';
@@ -19,7 +20,7 @@ interface ProviderCardProps extends AiProviderListItem {
19
20
  const ProviderCard = memo<ProviderCardProps>(
20
21
  ({ id, description, name, enabled, source, logo, loading, onProviderSelect }) => {
21
22
  const { t } = useTranslation('providers');
22
- const { isDarkMode } = useThemeMode();
23
+ const isDarkMode = useIsDark();
23
24
 
24
25
  if (loading)
25
26
  return (
@@ -1,14 +1,16 @@
1
1
  import { Flexbox } from '@lobehub/ui';
2
- import { cssVar, useThemeMode } from 'antd-style';
2
+ import { cssVar } from 'antd-style';
3
3
  import { memo } from 'react';
4
4
 
5
+ import { useIsDark } from '@/hooks/useIsDark';
6
+
5
7
  interface TotalCardProps {
6
8
  count: string | number;
7
9
  title: string;
8
10
  }
9
11
 
10
12
  const TotalCard = memo<TotalCardProps>(({ title, count }) => {
11
- const { isDarkMode } = useThemeMode();
13
+ const isDarkMode = useIsDark();
12
14
  return (
13
15
  <Flexbox
14
16
  padding={12}
@@ -2,28 +2,26 @@
2
2
 
3
3
  import { ActionIcon } from '@lobehub/ui';
4
4
  import { ChatHeader } from '@lobehub/ui/mobile';
5
- import { useThemeMode } from 'antd-style';
6
5
  import { Moon, Sun } from 'lucide-react';
6
+ import { useTheme as useNextThemesTheme } from 'next-themes';
7
7
  import { memo } from 'react';
8
8
 
9
9
  import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
10
- import { useGlobalStore } from '@/store/global';
11
- import { mobileHeaderSticky } from '@/styles/mobileHeader';
10
+ import { useIsDark } from '@/hooks/useIsDark';
12
11
 
13
12
  const Header = memo(() => {
14
- const { isDarkMode } = useThemeMode();
15
- const switchThemeMode = useGlobalStore((s) => s.switchThemeMode);
13
+ const { setTheme } = useNextThemesTheme();
14
+ const isDark = useIsDark();
16
15
 
17
16
  return (
18
17
  <ChatHeader
19
18
  right={
20
19
  <ActionIcon
21
- icon={isDarkMode ? Moon : Sun}
22
- onClick={() => switchThemeMode(isDarkMode ? 'light' : 'dark')}
20
+ icon={isDark ? Moon : Sun}
21
+ onClick={() => setTheme(isDark ? 'light' : 'dark')}
23
22
  size={MOBILE_HEADER_ICON_SIZE}
24
23
  />
25
24
  }
26
- style={mobileHeaderSticky}
27
25
  />
28
26
  );
29
27
  });
@@ -1,6 +1,5 @@
1
1
  import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
2
2
  import { SpeedInsights } from '@vercel/speed-insights/next';
3
- import { type ThemeAppearance } from 'antd-style';
4
3
  import { type ResolvingViewport } from 'next';
5
4
  import Script from 'next/script';
6
5
  import { type ReactNode, Suspense } from 'react';
@@ -26,7 +25,7 @@ export interface RootLayoutProps extends DynamicLayoutProps {
26
25
  const RootLayout = async ({ children, params }: RootLayoutProps) => {
27
26
  const { variants } = await params;
28
27
 
29
- const { locale, isMobile, theme, primaryColor, neutralColor } =
28
+ const { locale, isMobile, primaryColor, neutralColor } =
30
29
  RouteVariants.deserializeVariants(variants);
31
30
 
32
31
  const direction = isRtlLang(locale) ? 'rtl' : 'ltr';
@@ -34,7 +33,6 @@ const RootLayout = async ({ children, params }: RootLayoutProps) => {
34
33
  const renderContent = () => {
35
34
  return (
36
35
  <GlobalProvider
37
- appearance={theme}
38
36
  isMobile={isMobile}
39
37
  locale={locale}
40
38
  neutralColor={neutralColor}
@@ -50,8 +48,9 @@ const RootLayout = async ({ children, params }: RootLayoutProps) => {
50
48
  };
51
49
 
52
50
  return (
53
- <html dir={direction} lang={locale}>
51
+ <html dir={direction} lang={locale} suppressHydrationWarning>
54
52
  <head>
53
+ {/* <script dangerouslySetInnerHTML={{ __html: 'setTimeout(() => {debugger}, 16)' }} /> */}
55
54
  {process.env.DEBUG_REACT_SCAN === '1' && (
56
55
  <Script
57
56
  crossOrigin={'anonymous'}
@@ -99,7 +98,6 @@ export const generateViewport = async (props: DynamicLayoutProps): ResolvingView
99
98
  };
100
99
 
101
100
  export const generateStaticParams = () => {
102
- const themes: ThemeAppearance[] = ['dark', 'light'];
103
101
  const mobileOptions = isDesktop ? [false] : [true, false];
104
102
  // only static for serveral page, other go to dynamtic
105
103
  const staticLocales: Locales[] = [DEFAULT_LANG, 'zh-CN'];
@@ -107,16 +105,13 @@ export const generateStaticParams = () => {
107
105
  const variants: { variants: string }[] = [];
108
106
 
109
107
  for (const locale of staticLocales) {
110
- for (const theme of themes) {
111
- for (const isMobile of mobileOptions) {
112
- variants.push({
113
- variants: RouteVariants.serializeVariants({
114
- isMobile,
115
- locale,
116
- theme: theme as 'dark' | 'light',
117
- }),
118
- });
119
- }
108
+ for (const isMobile of mobileOptions) {
109
+ variants.push({
110
+ variants: RouteVariants.serializeVariants({
111
+ isMobile,
112
+ locale,
113
+ }),
114
+ });
120
115
  }
121
116
  }
122
117
 
@@ -2,16 +2,17 @@
2
2
 
3
3
  import { Center, Flexbox, Text } from '@lobehub/ui';
4
4
  import { Divider } from 'antd';
5
- import { cx, useThemeMode } from 'antd-style';
5
+ import { cx } from 'antd-style';
6
6
  import type { FC, PropsWithChildren } from 'react';
7
7
 
8
8
  import LangButton from '@/features/User/UserPanel/LangButton';
9
9
  import ThemeButton from '@/features/User/UserPanel/ThemeButton';
10
+ import { useIsDark } from '@/hooks/useIsDark';
10
11
 
11
12
  import { styles } from './style';
12
13
 
13
14
  const OnBoardingContainer: FC<PropsWithChildren> = ({ children }) => {
14
- const { isDarkMode } = useThemeMode();
15
+ const isDarkMode = useIsDark();
15
16
  return (
16
17
  <Flexbox className={styles.outerContainer} height={'100%'} padding={8} width={'100%'}>
17
18
  <Flexbox
@@ -1,13 +1,14 @@
1
1
  'use client';
2
2
 
3
3
  import { Block, Button, Flexbox, Text } from '@lobehub/ui';
4
- import { createStaticStyles, cssVar, cx, useThemeMode } from 'antd-style';
4
+ import { createStaticStyles, cssVar, cx } from 'antd-style';
5
5
  import { Undo2Icon } from 'lucide-react';
6
6
  import React, { memo, useMemo } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { useNavigate } from 'react-router-dom';
9
9
 
10
10
  import LobeMessage from '@/app/[variants]/onboarding/components/LobeMessage';
11
+ import { useIsDark } from '@/hooks/useIsDark';
11
12
  import { useUserStore } from '@/store/user';
12
13
 
13
14
  const styles = createStaticStyles(({ css, cssVar }) => ({
@@ -76,7 +77,7 @@ interface ModeSelectionStepProps {
76
77
  const ModeSelectionStep = memo<ModeSelectionStepProps>(({ onBack, onNext }) => {
77
78
  const { t } = useTranslation('onboarding');
78
79
  const navigate = useNavigate();
79
- const { isDarkMode } = useThemeMode();
80
+ const isDarkMode = useIsDark();
80
81
 
81
82
  const imageStyles = useMemo<React.CSSProperties>(
82
83
  () =>
@@ -1,16 +1,20 @@
1
1
  'use client';
2
2
 
3
- import dynamic from 'next/dynamic';
3
+ import { useEffect, useState } from 'react';
4
4
 
5
- import Loading from '@/components/Loading/BrandTextLoading';
6
-
7
- const DesktopRouterClient = dynamic(() => import('./DesktopClientRouter'), {
8
- loading: () => <Loading debugId="DesktopRouter" />,
9
- ssr: false,
10
- });
5
+ import DesktopClientRouter from './DesktopClientRouter';
11
6
 
7
+ const useIsClient = () => {
8
+ const [isClient, setIsClient] = useState(false);
9
+ useEffect(() => {
10
+ setIsClient(true);
11
+ }, []);
12
+ return isClient;
13
+ };
12
14
  const DesktopRouter = () => {
13
- return <DesktopRouterClient />;
15
+ const isClient = useIsClient();
16
+ if (!isClient) return null;
17
+ return <DesktopClientRouter />;
14
18
  };
15
19
 
16
20
  export default DesktopRouter;
@@ -1,8 +1,10 @@
1
1
  'use client';
2
2
 
3
- import { createStaticStyles, useThemeMode } from 'antd-style';
3
+ import { createStaticStyles } from 'antd-style';
4
4
  import { memo } from 'react';
5
5
 
6
+ import { useIsDark } from '@/hooks/useIsDark';
7
+
6
8
  const styles = createStaticStyles(({ css, cssVar }) => ({
7
9
  dividerDark: css`
8
10
  flex: none;
@@ -19,7 +21,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
19
21
  }));
20
22
 
21
23
  const Divider = memo(() => {
22
- const { isDarkMode } = useThemeMode();
24
+ const isDarkMode = useIsDark();
23
25
 
24
26
  return <div className={isDarkMode ? styles.dividerDark : styles.dividerLight} />;
25
27
  });
@@ -1,8 +1,10 @@
1
1
  import { Flexbox, Icon, Modal } from '@lobehub/ui';
2
- import { createStaticStyles, useThemeMode } from 'antd-style';
2
+ import { createStaticStyles } from 'antd-style';
3
3
  import { type LucideIcon } from 'lucide-react';
4
4
  import { type ReactNode, memo } from 'react';
5
5
 
6
+ import { useIsDark } from '@/hooks/useIsDark';
7
+
6
8
  const prefixCls = 'ant';
7
9
 
8
10
  const styles = createStaticStyles(({ css, cssVar }) => ({
@@ -52,7 +54,7 @@ interface DataStyleModalProps {
52
54
 
53
55
  const DataStyleModal = memo<DataStyleModalProps>(
54
56
  ({ icon, onOpenChange, title, open, children, width = 550, height }) => {
55
- const { isDarkMode } = useThemeMode();
57
+ const isDarkMode = useIsDark();
56
58
 
57
59
  return (
58
60
  <Modal
@@ -1,8 +1,10 @@
1
1
  import { Center, Flexbox, Icon } from '@lobehub/ui';
2
- import { createStaticStyles, useThemeMode , responsive } from 'antd-style';
2
+ import { createStaticStyles, responsive } from 'antd-style';
3
3
  import { type LucideIcon } from 'lucide-react';
4
4
  import { memo } from 'react';
5
5
 
6
+ import { useIsDark } from '@/hooks/useIsDark';
7
+
6
8
  const styles = createStaticStyles(({ css, cssVar }) => ({
7
9
  desc: css`
8
10
  width: 280px;
@@ -48,7 +50,7 @@ interface FeatureListProps {
48
50
  }
49
51
 
50
52
  const FeatureList = memo<FeatureListProps>(({ data }) => {
51
- const { isDarkMode } = useThemeMode();
53
+ const isDarkMode = useIsDark();
52
54
 
53
55
  return (
54
56
  <Flexbox gap={32}>
@@ -1,9 +1,10 @@
1
1
  import { Flexbox, Icon, Tag, Tooltip } from '@lobehub/ui';
2
- import { createStaticStyles, cx, useThemeMode } from 'antd-style';
2
+ import { createStaticStyles, cx } from 'antd-style';
3
3
  import { BoltIcon, RotateCwIcon } from 'lucide-react';
4
4
  import { memo } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
 
7
+ import { useIsDark } from '@/hooks/useIsDark';
7
8
  import { AsyncTaskStatus, type FileParsingTask } from '@/types/asyncTask';
8
9
 
9
10
  const styles = createStaticStyles(({ css, cssVar }) => ({
@@ -36,7 +37,7 @@ interface EmbeddingStatusProps extends FileParsingTask {
36
37
  const EmbeddingStatus = memo<EmbeddingStatusProps>(
37
38
  ({ chunkCount, embeddingStatus, embeddingError, onClick, onErrorClick, className }) => {
38
39
  const { t } = useTranslation(['components', 'common']);
39
- const { isDarkMode } = useThemeMode();
40
+ const isDarkMode = useIsDark();
40
41
 
41
42
  switch (embeddingStatus) {
42
43
  case AsyncTaskStatus.Processing: {
@@ -1,10 +1,11 @@
1
1
  import { Button, Flexbox, Icon, Tag, Tooltip } from '@lobehub/ui';
2
2
  import { Badge } from 'antd';
3
- import { createStaticStyles, cssVar, cx, useThemeMode } from 'antd-style';
3
+ import { createStaticStyles, cssVar, cx } from 'antd-style';
4
4
  import { BoltIcon, Loader2Icon, RotateCwIcon } from 'lucide-react';
5
5
  import { memo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
 
8
+ import { useIsDark } from '@/hooks/useIsDark';
8
9
  import { AsyncTaskStatus, type FileParsingTask } from '@/types/asyncTask';
9
10
 
10
11
  import EmbeddingStatus from './EmbeddingStatus';
@@ -52,7 +53,7 @@ const FileParsingStatus = memo<FileParsingStatusProps>(
52
53
  hideEmbeddingButton,
53
54
  }) => {
54
55
  const { t } = useTranslation(['components', 'common']);
55
- const { isDarkMode } = useThemeMode();
56
+ const isDarkMode = useIsDark();
56
57
 
57
58
  switch (chunkingStatus) {
58
59
  case AsyncTaskStatus.Processing: {
@@ -1,10 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  import { ActionIcon, Flexbox, type FlexboxProps } from '@lobehub/ui';
4
- import { createStaticStyles, cssVar, cx, useThemeMode } from 'antd-style';
4
+ import { createStaticStyles, cssVar, cx } from 'antd-style';
5
5
  import { XIcon } from 'lucide-react';
6
6
  import { memo } from 'react';
7
7
 
8
+ import { useIsDark } from '@/hooks/useIsDark';
9
+
8
10
  const styles = createStaticStyles(({ css }) => ({
9
11
  cancelIcon: css`
10
12
  position: absolute;
@@ -70,7 +72,7 @@ const Notification = memo<NotificationProps>(
70
72
  className,
71
73
  ...rest
72
74
  }) => {
73
- const { isDarkMode } = useThemeMode();
75
+ const isDarkMode = useIsDark();
74
76
  const { className: wrapperClassName, ...restWrapper } = wrapper;
75
77
  return (
76
78
  show && (
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+
3
+ import { type FC, type PropsWithChildren, useEffect, useState } from 'react';
4
+
5
+ const ClientOnly: FC<PropsWithChildren> = ({ children }) => {
6
+ const [mounted, setMounted] = useState(false);
7
+
8
+ useEffect(() => {
9
+ setMounted(true);
10
+ }, []);
11
+
12
+ if (!mounted) return null;
13
+
14
+ return children;
15
+ };
16
+
17
+ export default ClientOnly;