@lobehub/lobehub 2.0.0-next.212 → 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 (152) hide show
  1. package/.github/workflows/auto-i18n.yml +1 -1
  2. package/.github/workflows/bundle-analyzer.yml +1 -1
  3. package/.github/workflows/claude-auto-testing.yml +1 -1
  4. package/.github/workflows/claude-dedupe-issues.yml +1 -1
  5. package/.github/workflows/claude-issue-triage.yml +1 -1
  6. package/.github/workflows/claude-translate-comments.yml +1 -1
  7. package/.github/workflows/claude-translator.yml +1 -1
  8. package/.github/workflows/claude.yml +1 -1
  9. package/.github/workflows/desktop-build-electron.yml +2 -2
  10. package/.github/workflows/e2e.yml +1 -1
  11. package/.github/workflows/issue-auto-close-duplicates.yml +1 -1
  12. package/.github/workflows/lighthouse.yml +2 -2
  13. package/.github/workflows/lock-closed-issues.yml +1 -1
  14. package/.github/workflows/manual-build-desktop.yml +6 -6
  15. package/.github/workflows/pr-build-desktop.yml +5 -5
  16. package/.github/workflows/pr-build-docker.yml +2 -2
  17. package/.github/workflows/release-desktop-beta.yml +4 -4
  18. package/.github/workflows/release-docker.yml +2 -2
  19. package/.github/workflows/release.yml +1 -1
  20. package/.github/workflows/sync-database-schema.yml +1 -1
  21. package/.github/workflows/sync.yml +1 -1
  22. package/.github/workflows/test.yml +5 -5
  23. package/.github/workflows/verify-desktop-patch.yml +1 -1
  24. package/CHANGELOG.md +58 -0
  25. package/apps/desktop/package.json +3 -2
  26. package/apps/desktop/src/main/const/store.ts +1 -1
  27. package/apps/desktop/src/main/controllers/SystemCtr.ts +2 -3
  28. package/apps/desktop/src/main/core/App.ts +10 -3
  29. package/apps/desktop/src/main/types/store.ts +1 -1
  30. package/changelog/v1.json +14 -0
  31. package/locales/ar/models.json +35 -4
  32. package/locales/ar/providers.json +1 -0
  33. package/locales/bg-BG/models.json +24 -1
  34. package/locales/bg-BG/providers.json +1 -0
  35. package/locales/de-DE/models.json +30 -1
  36. package/locales/de-DE/providers.json +1 -0
  37. package/locales/en-US/models.json +1 -0
  38. package/locales/en-US/providers.json +1 -0
  39. package/locales/es-ES/models.json +32 -1
  40. package/locales/es-ES/providers.json +1 -0
  41. package/locales/fa-IR/models.json +48 -1
  42. package/locales/fa-IR/providers.json +1 -0
  43. package/locales/fr-FR/models.json +47 -1
  44. package/locales/fr-FR/providers.json +1 -0
  45. package/locales/it-IT/models.json +32 -1
  46. package/locales/it-IT/providers.json +1 -0
  47. package/locales/ja-JP/models.json +2 -1
  48. package/locales/ja-JP/providers.json +1 -0
  49. package/locales/ko-KR/models.json +24 -1
  50. package/locales/ko-KR/providers.json +1 -0
  51. package/locales/nl-NL/models.json +46 -1
  52. package/locales/nl-NL/providers.json +1 -0
  53. package/locales/pl-PL/models.json +41 -1
  54. package/locales/pl-PL/providers.json +1 -0
  55. package/locales/pt-BR/models.json +32 -1
  56. package/locales/pt-BR/providers.json +1 -0
  57. package/locales/ru-RU/models.json +54 -2
  58. package/locales/ru-RU/providers.json +1 -0
  59. package/locales/tr-TR/models.json +32 -1
  60. package/locales/tr-TR/providers.json +1 -0
  61. package/locales/vi-VN/models.json +37 -1
  62. package/locales/vi-VN/providers.json +1 -0
  63. package/locales/zh-CN/models.json +24 -3
  64. package/locales/zh-CN/providers.json +1 -0
  65. package/locales/zh-TW/models.json +11 -1
  66. package/locales/zh-TW/providers.json +1 -0
  67. package/package.json +4 -3
  68. package/packages/builtin-tool-knowledge-base/src/client/Render/SearchKnowledgeBase/Item/index.tsx +4 -2
  69. package/packages/builtin-tool-local-system/src/client/Intervention/EditLocalFile/index.tsx +3 -2
  70. package/packages/builtin-tool-local-system/src/client/Render/EditLocalFile/index.tsx +3 -2
  71. package/packages/const/src/theme.ts +0 -2
  72. package/packages/context-engine/src/engine/messages/types.ts +1 -1
  73. package/packages/desktop-bridge/src/routeVariants.ts +2 -9
  74. package/packages/electron-client-ipc/src/types/system.ts +1 -1
  75. package/packages/model-runtime/src/core/BaseAI.ts +1 -1
  76. package/packages/model-runtime/src/core/streams/qwen.test.ts +140 -0
  77. package/packages/model-runtime/src/core/streams/qwen.ts +17 -5
  78. package/packages/model-runtime/src/types/chat.ts +12 -12
  79. package/packages/model-runtime/src/types/error.ts +1 -1
  80. package/packages/model-runtime/src/types/image.ts +1 -1
  81. package/scripts/electronWorkflow/modifiers/nextConfig.mts +41 -13
  82. package/src/app/[variants]/(auth)/_layout/index.tsx +3 -2
  83. package/src/app/[variants]/(auth)/_layout/style.ts +8 -18
  84. package/src/app/[variants]/(auth)/layout.tsx +7 -3
  85. package/src/app/[variants]/(desktop)/desktop-onboarding/_layout/index.tsx +4 -2
  86. package/src/app/[variants]/(desktop)/desktop-onboarding/_layout/style.ts +3 -0
  87. package/src/app/[variants]/(main)/_layout/DesktopLayoutContainer.tsx +3 -2
  88. package/src/app/[variants]/(main)/chat/features/Conversation/Header/index.tsx +2 -1
  89. package/src/app/[variants]/(main)/chat/profile/features/ProfileEditor/PluginTag.tsx +3 -2
  90. package/src/app/[variants]/(main)/community/(list)/_layout/Footer.tsx +3 -2
  91. package/src/app/[variants]/(main)/group/features/Conversation/ChatItem/Thread.tsx +3 -2
  92. package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/index.tsx +0 -1
  93. package/src/app/[variants]/(main)/group/profile/features/ProfileEditor/PluginTag.tsx +3 -2
  94. package/src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentItem/Editing.tsx +2 -2
  95. package/src/app/[variants]/(main)/home/_layout/Footer/index.tsx +1 -1
  96. package/src/app/[variants]/(main)/home/_layout/index.tsx +3 -2
  97. package/src/app/[variants]/(main)/home/features/CommunityAgents/Item.tsx +3 -2
  98. package/src/app/[variants]/(main)/image/_layout/ConfigPanel/components/AspectRatioSelect/index.tsx +4 -2
  99. package/src/app/[variants]/(main)/image/_layout/ConfigPanel/components/ModelSelect/ImageModelItem.tsx +3 -2
  100. package/src/app/[variants]/(main)/image/_layout/ConfigPanel/components/Select/index.tsx +4 -2
  101. package/src/app/[variants]/(main)/image/features/PromptInput/index.tsx +3 -2
  102. package/src/app/[variants]/(main)/memory/features/TimeLineView/index.tsx +9 -4
  103. package/src/app/[variants]/(main)/page/_layout/Body/List/Item/Editing.tsx +2 -2
  104. package/src/app/[variants]/(main)/settings/common/features/Common/Common.tsx +11 -11
  105. package/src/app/[variants]/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +3 -2
  106. package/src/app/[variants]/(main)/settings/stats/features/overview/ShareButton/TotalCard.tsx +4 -2
  107. package/src/app/[variants]/(mobile)/me/(home)/features/Header.tsx +6 -8
  108. package/src/app/[variants]/layout.tsx +10 -15
  109. package/src/app/[variants]/onboarding/_layout/index.tsx +3 -2
  110. package/src/app/[variants]/onboarding/features/ModeSelectionStep.tsx +3 -2
  111. package/src/app/[variants]/router/index.tsx +12 -8
  112. package/src/components/Cell/Divider.tsx +4 -2
  113. package/src/components/DataStyleModal/index.tsx +4 -2
  114. package/src/components/FeatureList/index.tsx +4 -2
  115. package/src/components/FileParsingStatus/EmbeddingStatus.tsx +3 -2
  116. package/src/components/FileParsingStatus/index.tsx +3 -2
  117. package/src/components/Notification/index.tsx +4 -2
  118. package/src/components/client/ClientOnly.tsx +17 -0
  119. package/src/features/AlertBanner/CloudBanner.tsx +4 -3
  120. package/src/features/CommandMenu/ThemeMenu.tsx +1 -1
  121. package/src/features/CommandMenu/types.ts +5 -2
  122. package/src/features/CommandMenu/useCommandMenu.ts +3 -2
  123. package/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx +3 -2
  124. package/src/features/Conversation/Messages/components/FileChunks/ChunkItem.tsx +3 -2
  125. package/src/features/Conversation/Messages/components/FileChunks/index.tsx +4 -2
  126. package/src/features/Conversation/Messages/components/SearchGrounding.tsx +3 -2
  127. package/src/features/ElectronTitlebar/hooks/useWatchThemeUpdate.ts +21 -38
  128. package/src/features/GroupChatSettings/AgentCard.tsx +3 -2
  129. package/src/features/GroupChatSettings/HostMemberCard.tsx +3 -2
  130. package/src/features/PageEditor/DiffAllToolbar.tsx +4 -2
  131. package/src/features/User/UserPanel/ThemeButton.tsx +18 -29
  132. package/src/hooks/useIsDark.ts +11 -0
  133. package/src/layout/AuthProvider/Clerk/useAppearance.ts +4 -2
  134. package/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsx +3 -2
  135. package/src/layout/GlobalProvider/AppTheme.tsx +15 -19
  136. package/src/layout/GlobalProvider/NextThemeProvider.tsx +22 -0
  137. package/src/layout/GlobalProvider/StyleRegistry.tsx +18 -13
  138. package/src/layout/GlobalProvider/index.tsx +38 -36
  139. package/src/libs/next/proxy/define-config.ts +2 -11
  140. package/src/server/services/comfyui/config/constants.ts +7 -7
  141. package/src/server/services/comfyui/config/promptToolConst.ts +26 -26
  142. package/src/server/services/comfyui/utils/promptSplitter.ts +23 -23
  143. package/src/server/services/comfyui/utils/weightDType.ts +4 -5
  144. package/src/store/global/action.test.ts +0 -15
  145. package/src/store/global/actions/__tests__/general.test.ts +0 -37
  146. package/src/store/global/actions/general.ts +0 -21
  147. package/src/store/global/initialState.ts +0 -6
  148. package/src/store/global/selectors/systemStatus.test.ts +0 -20
  149. package/src/store/global/selectors/systemStatus.ts +0 -2
  150. package/src/styles/global.ts +0 -2
  151. package/src/utils/server/routeVariants.test.ts +17 -51
  152. package/src/utils/server/routeVariants.ts +0 -1
@@ -1,33 +1,15 @@
1
1
  import { useWatchBroadcast } from '@lobechat/electron-client-ipc';
2
- import { LOBE_THEME_APP_ID } from '@lobehub/ui';
3
- import { useLayoutEffect } from 'react';
2
+ import { useTheme } from 'next-themes';
3
+ import { useEffect } from 'react';
4
4
 
5
+ import { isDesktop } from '@/const/version';
5
6
  import { useElectronStore } from '@/store/electron';
6
7
  import { useGlobalStore } from '@/store/global';
7
- import { systemStatusSelectors } from '@/store/global/selectors';
8
8
  import { ensureElectronIpc } from '@/utils/electron/ipc';
9
9
 
10
- const sidebarColors = {
11
- dark: '#000',
12
- light: '#f8f8f8',
13
- };
14
10
  export const useWatchThemeUpdate = () => {
15
- const [isAppStateInit, systemAppearance, updateElectronAppState, isMac] = useElectronStore(
16
- (s) => [
17
- s.isAppStateInit,
18
- s.appState.systemAppearance,
19
- s.updateElectronAppState,
20
- s.appState.isMac,
21
- ],
22
- );
23
- const [switchThemeMode, switchLocale] = useGlobalStore((s) => [
24
- s.switchThemeMode,
25
- s.switchLocale,
26
- ]);
27
-
28
- useWatchBroadcast('themeChanged', ({ themeMode }) => {
29
- switchThemeMode(themeMode, { skipBroadcast: true });
30
- });
11
+ const [updateElectronAppState] = useElectronStore((s) => [s.updateElectronAppState]);
12
+ const [switchLocale] = useGlobalStore((s) => [s.switchLocale]);
31
13
 
32
14
  useWatchBroadcast('localeChanged', ({ locale }) => {
33
15
  switchLocale(locale as any, { skipBroadcast: true });
@@ -36,20 +18,21 @@ export const useWatchThemeUpdate = () => {
36
18
  useWatchBroadcast('systemThemeChanged', ({ themeMode }) => {
37
19
  updateElectronAppState({ systemAppearance: themeMode });
38
20
  });
39
- const themeMode = useGlobalStore(systemStatusSelectors.themeMode);
40
- useLayoutEffect(() => {
41
- ensureElectronIpc().system.setSystemThemeMode(themeMode);
42
- }, []);
43
-
44
- useLayoutEffect(() => {
45
- if (!isAppStateInit || !isMac) return;
46
- document.documentElement.style.background = 'none';
47
-
48
- const lobeApp = document.querySelector('#' + LOBE_THEME_APP_ID);
49
- if (!lobeApp) return;
50
21
 
51
- if (systemAppearance) {
52
- document.body.style.background = `color-mix(in srgb, ${sidebarColors[systemAppearance as 'dark' | 'light']} 86%, transparent)`;
53
- }
54
- }, [systemAppearance, isAppStateInit, isMac]);
22
+ const { theme } = useTheme();
23
+
24
+ useEffect(() => {
25
+ if (!isDesktop) return;
26
+ if (!theme) return;
27
+
28
+ (async () => {
29
+ try {
30
+ await ensureElectronIpc().system.updateThemeModeHandler(
31
+ theme as 'dark' | 'light' | 'system',
32
+ );
33
+ } catch {
34
+ // Ignore errors in non-electron environment
35
+ }
36
+ })();
37
+ }, [theme]);
55
38
  };
@@ -2,12 +2,13 @@
2
2
 
3
3
  import { Avatar, Flexbox, Icon, Skeleton, Text, Tooltip } from '@lobehub/ui';
4
4
  import { Switch } from 'antd';
5
- import { createStaticStyles, cssVar, cx, useThemeMode } from 'antd-style';
5
+ import { createStaticStyles, cssVar, cx } from 'antd-style';
6
6
  import { Bot, Loader2 } from 'lucide-react';
7
7
  import { memo } from 'react';
8
8
  import { useTranslation } from 'react-i18next';
9
9
 
10
10
  import { DEFAULT_AVATAR } from '@/const/meta';
11
+ import { useIsDark } from '@/hooks/useIsDark';
11
12
  import { type LobeAgentSession } from '@/types/session';
12
13
 
13
14
  const styles = createStaticStyles(({ css }) => ({
@@ -59,7 +60,7 @@ interface AgentCardProps {
59
60
  const AgentCard = memo<AgentCardProps>(
60
61
  ({ agent, inGroup, isHost, loading, onAction, operationLoading }) => {
61
62
  const { t } = useTranslation('setting');
62
- const { isDarkMode } = useThemeMode();
63
+ const isDarkMode = useIsDark();
63
64
 
64
65
  if (loading) {
65
66
  return (
@@ -2,12 +2,13 @@
2
2
 
3
3
  import { Avatar, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
4
4
  import { Switch } from 'antd';
5
- import { createStaticStyles, cssVar, cx, useThemeMode } from 'antd-style';
5
+ import { createStaticStyles, cssVar, cx } from 'antd-style';
6
6
  import { Bot, Loader2 } from 'lucide-react';
7
7
  import { memo } from 'react';
8
8
  import { useTranslation } from 'react-i18next';
9
9
 
10
10
  import { DEFAULT_SUPERVISOR_AVATAR } from '@/const/meta';
11
+ import { useIsDark } from '@/hooks/useIsDark';
11
12
 
12
13
  const styles = createStaticStyles(({ css }) => ({
13
14
  container: css`
@@ -53,7 +54,7 @@ interface HostMemberCardProps {
53
54
  }
54
55
 
55
56
  const HostMemberCard = memo<HostMemberCardProps>(({ checked, loading, onToggle }) => {
56
- const { isDarkMode } = useThemeMode();
57
+ const isDarkMode = useIsDark();
57
58
  const { t } = useTranslation('setting');
58
59
 
59
60
  const title = t('settingGroupMembers.host.title');
@@ -3,11 +3,13 @@
3
3
  import { DiffAction, LITEXML_DIFFNODE_ALL_COMMAND } from '@lobehub/editor';
4
4
  import { Block, Icon } from '@lobehub/ui';
5
5
  import { Button, Space } from 'antd';
6
- import { createStaticStyles, cssVar, cx, useThemeMode } from 'antd-style';
6
+ import { createStaticStyles, cssVar, cx } from 'antd-style';
7
7
  import { Check, X } from 'lucide-react';
8
8
  import { memo, useEffect, useState } from 'react';
9
9
  import { useTranslation } from 'react-i18next';
10
10
 
11
+ import { useIsDark } from '@/hooks/useIsDark';
12
+
11
13
  import { usePageEditorStore } from './store';
12
14
 
13
15
  const styles = createStaticStyles(({ css }) => ({
@@ -36,7 +38,7 @@ const styles = createStaticStyles(({ css }) => ({
36
38
 
37
39
  const DiffAllToolbar = memo(() => {
38
40
  const { t } = useTranslation('editor');
39
- const { isDarkMode } = useThemeMode();
41
+ const isDarkMode = useIsDark();
40
42
  const [editor, performSave] = usePageEditorStore((s) => [s.editor, s.performSave]);
41
43
  const [hasPendingDiffs, setHasPendingDiffs] = useState(false);
42
44
 
@@ -1,65 +1,54 @@
1
- import { ActionIcon, Dropdown, type DropdownProps, Icon } from '@lobehub/ui';
1
+ import { ActionIcon, DropdownMenu, type DropdownMenuProps, Icon } from '@lobehub/ui';
2
2
  import { Monitor, Moon, Sun } from 'lucide-react';
3
+ import { useTheme as useNextThemesTheme } from 'next-themes';
3
4
  import { FC, useMemo } from 'react';
4
5
  import { useTranslation } from 'react-i18next';
5
6
 
6
- import { type MenuProps } from '@/components/Menu';
7
- import { useGlobalStore } from '@/store/global';
8
- import { systemStatusSelectors } from '@/store/global/selectors';
9
-
10
7
  const themeIcons = {
11
- auto: Monitor,
12
8
  dark: Moon,
13
9
  light: Sun,
10
+ system: Monitor,
14
11
  };
15
12
 
16
- const ThemeButton: FC<{ placement?: DropdownProps['placement']; size?: number }> = ({
13
+ const ThemeButton: FC<{ placement?: DropdownMenuProps['placement']; size?: number }> = ({
17
14
  placement,
18
15
  size,
19
16
  }) => {
20
- const [themeMode, switchThemeMode] = useGlobalStore((s) => [
21
- systemStatusSelectors.themeMode(s),
22
- s.switchThemeMode,
23
- ]);
17
+ const { setTheme, theme } = useNextThemesTheme();
24
18
 
25
19
  const { t } = useTranslation('setting');
26
20
 
27
- const items: MenuProps['items'] = useMemo(
21
+ const items = useMemo<DropdownMenuProps['items']>(
28
22
  () => [
29
23
  {
30
- icon: <Icon icon={themeIcons.auto} />,
31
- key: 'auto',
24
+ icon: <Icon icon={themeIcons.system} />,
25
+ key: 'system',
32
26
  label: t('settingCommon.themeMode.auto'),
33
- onClick: () => switchThemeMode('auto'),
27
+ onClick: () => setTheme('system'),
34
28
  },
35
29
  {
36
30
  icon: <Icon icon={themeIcons.light} />,
37
31
  key: 'light',
38
32
  label: t('settingCommon.themeMode.light'),
39
- onClick: () => switchThemeMode('light'),
33
+ onClick: () => setTheme('light'),
40
34
  },
41
35
  {
42
36
  icon: <Icon icon={themeIcons.dark} />,
43
37
  key: 'dark',
44
38
  label: t('settingCommon.themeMode.dark'),
45
- onClick: () => switchThemeMode('dark'),
39
+ onClick: () => setTheme('dark'),
46
40
  },
47
41
  ],
48
- [t],
42
+ [setTheme, t],
49
43
  );
50
44
 
51
45
  return (
52
- <Dropdown
53
- arrow={false}
54
- menu={{
55
- items,
56
- selectable: true,
57
- selectedKeys: [themeMode],
58
- }}
59
- placement={placement}
60
- >
61
- <ActionIcon icon={themeIcons[themeMode]} size={size || { blockSize: 32, size: 16 }} />
62
- </Dropdown>
46
+ <DropdownMenu items={items} placement={placement}>
47
+ <ActionIcon
48
+ icon={themeIcons[(theme as 'dark' | 'light' | 'system') || 'system']}
49
+ size={size || { blockSize: 32, size: 16 }}
50
+ />
51
+ </DropdownMenu>
63
52
  );
64
53
  };
65
54
 
@@ -0,0 +1,11 @@
1
+ import { useTheme as useNextThemesTheme } from 'next-themes';
2
+
3
+ /**
4
+ * Hook to check if the current theme is dark
5
+ * @returns boolean - true if current theme is dark, false otherwise
6
+ */
7
+ export const useIsDark = (): boolean => {
8
+ const { resolvedTheme } = useNextThemesTheme();
9
+
10
+ return resolvedTheme === 'dark';
11
+ };
@@ -3,7 +3,9 @@
3
3
  import { dark } from '@clerk/themes';
4
4
  import { type ElementsConfig, type Theme } from '@clerk/types';
5
5
  import { BRANDING_URL } from '@lobechat/business-const';
6
- import { createStaticStyles, cssVar, cx, useThemeMode } from 'antd-style';
6
+ import { createStaticStyles, cssVar, cx } from 'antd-style';
7
+
8
+ import { useIsDark } from '@/hooks/useIsDark';
7
9
 
8
10
  const prefixCls = 'cl';
9
11
 
@@ -95,7 +97,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
95
97
  })) as Partial<Record<keyof ElementsConfig, any>>;
96
98
 
97
99
  export const useAppearance = () => {
98
- const { isDarkMode } = useThemeMode();
100
+ const isDarkMode = useIsDark();
99
101
 
100
102
  const navbarStyle = cx(styles.navbar, isDarkMode && (styles as any).navbar_dark);
101
103
  const scrollBoxStyle = cx(styles.scrollBox, isDarkMode && (styles as any).scrollBox_dark);
@@ -2,12 +2,13 @@
2
2
 
3
3
  import { BRANDING_NAME } from '@lobechat/business-const';
4
4
  import { Block, Modal, Text } from '@lobehub/ui';
5
- import { createStaticStyles, cx, useThemeMode } from 'antd-style';
5
+ import { createStaticStyles, cx } from 'antd-style';
6
6
  import { memo } from 'react';
7
7
  import { Trans, useTranslation } from 'react-i18next';
8
8
 
9
9
  import { PRIVACY_URL, TERMS_URL } from '@/const/url';
10
10
  import AuthCard from '@/features/AuthCard';
11
+ import { useIsDark } from '@/hooks/useIsDark';
11
12
 
12
13
  const styles = createStaticStyles(({ css }) => ({
13
14
  container: css`
@@ -34,7 +35,7 @@ interface MarketAuthConfirmModalProps {
34
35
  const MarketAuthConfirmModal = memo<MarketAuthConfirmModalProps>(
35
36
  ({ open, onConfirm, onCancel }) => {
36
37
  const { t } = useTranslation('marketAuth');
37
- const { isDarkMode } = useThemeMode();
38
+ const isDarkMode = useIsDark();
38
39
 
39
40
  const footer = (
40
41
  <Text align={'center'} as={'div'} fontSize={13} type={'secondary'}>
@@ -8,7 +8,7 @@ import {
8
8
  ThemeProvider,
9
9
  } from '@lobehub/ui';
10
10
  import { message as antdMessage } from 'antd';
11
- import { type ThemeAppearance, createStaticStyles, cx, useTheme } from 'antd-style';
11
+ import { createStaticStyles, cx, useTheme } from 'antd-style';
12
12
  import 'antd/dist/reset.css';
13
13
  import { AppConfigContext } from 'antd/es/app/context';
14
14
  import * as motion from 'motion/react-m';
@@ -17,13 +17,10 @@ import Link from 'next/link';
17
17
  import { type ReactNode, memo, useEffect, useMemo, useState } from 'react';
18
18
 
19
19
  import AntdStaticMethods from '@/components/AntdStaticMethods';
20
- import {
21
- LOBE_THEME_APPEARANCE,
22
- LOBE_THEME_NEUTRAL_COLOR,
23
- LOBE_THEME_PRIMARY_COLOR,
24
- } from '@/const/theme';
20
+ import { LOBE_THEME_NEUTRAL_COLOR, LOBE_THEME_PRIMARY_COLOR } from '@/const/theme';
25
21
  import { isDesktop } from '@/const/version';
26
22
  import { TITLE_BAR_HEIGHT } from '@/features/ElectronTitlebar';
23
+ import { useIsDark } from '@/hooks/useIsDark';
27
24
  import { getUILocaleAndResources } from '@/libs/getUILocaleAndResources';
28
25
  import { useGlobalStore } from '@/store/global';
29
26
  import { systemStatusSelectors } from '@/store/global/selectors';
@@ -92,7 +89,6 @@ export interface AppThemeProps {
92
89
  children?: ReactNode;
93
90
  customFontFamily?: string;
94
91
  customFontURL?: string;
95
- defaultAppearance?: ThemeAppearance;
96
92
  defaultNeutralColor?: NeutralColors;
97
93
  defaultPrimaryColor?: PrimaryColors;
98
94
  globalCDN?: boolean;
@@ -101,16 +97,16 @@ export interface AppThemeProps {
101
97
  const AppTheme = memo<AppThemeProps>(
102
98
  ({
103
99
  children,
104
- defaultAppearance,
105
100
  defaultPrimaryColor,
106
101
  defaultNeutralColor,
107
102
  globalCDN,
108
103
  customFontURL,
109
104
  customFontFamily,
110
105
  }) => {
111
- const themeMode = useGlobalStore(systemStatusSelectors.themeMode);
112
106
  const language = useGlobalStore(systemStatusSelectors.language);
113
- const theme = useTheme();
107
+ const antdTheme = useTheme();
108
+ const isDark = useIsDark();
109
+
114
110
  const [primaryColor, neutralColor, animationMode] = useUserStore((s) => [
115
111
  userGeneralSettingsSelectors.primaryColor(s),
116
112
  userGeneralSettingsSelectors.neutralColor(s),
@@ -154,29 +150,29 @@ const AppTheme = memo<AppThemeProps>(
154
150
  antdMessage.config({ top: messageTop });
155
151
  }, [messageTop]);
156
152
 
153
+ const currentAppearence = isDark ? 'dark' : 'light';
154
+
157
155
  return (
158
156
  <AppConfigContext.Provider value={appConfig}>
159
157
  <ThemeProvider
160
- appearance={themeMode !== 'auto' ? themeMode : undefined}
158
+ appearance={currentAppearence}
161
159
  className={cx(styles.app, styles.scrollbar, styles.scrollbarPolyfill)}
162
160
  customTheme={{
163
161
  neutralColor: neutralColor ?? defaultNeutralColor,
164
162
  primaryColor: primaryColor ?? defaultPrimaryColor,
165
163
  }}
166
- defaultAppearance={defaultAppearance}
167
- onAppearanceChange={(appearance) => {
168
- if (themeMode !== 'auto') return;
169
-
170
- setCookie(LOBE_THEME_APPEARANCE, appearance);
171
- }}
164
+ defaultAppearance={currentAppearence}
165
+ defaultThemeMode={currentAppearence}
172
166
  theme={{
167
+ cssVar: { key: 'lobe-vars' },
173
168
  token: {
174
- fontFamily: customFontFamily ? `${customFontFamily},${theme.fontFamily}` : undefined,
169
+ fontFamily: customFontFamily
170
+ ? `${customFontFamily},${antdTheme.fontFamily}`
171
+ : undefined,
175
172
  motion: animationMode !== 'disabled',
176
173
  motionUnit: animationMode === 'agile' ? 0.05 : 0.1,
177
174
  },
178
175
  }}
179
- themeMode={themeMode}
180
176
  >
181
177
  {!!customFontURL && <FontLoader url={customFontURL} />}
182
178
  <GlobalStyle />
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+
3
+ import { ThemeProvider as NextThemesProvider } from 'next-themes';
4
+ import { type ReactNode } from 'react';
5
+
6
+ interface NextThemeProviderProps {
7
+ children: ReactNode;
8
+ }
9
+
10
+ export default function NextThemeProvider({ children }: NextThemeProviderProps) {
11
+ return (
12
+ <NextThemesProvider
13
+ attribute="data-theme"
14
+ defaultTheme="system"
15
+ disableTransitionOnChange
16
+ enableSystem
17
+ forcedTheme={undefined}
18
+ >
19
+ {children}
20
+ </NextThemesProvider>
21
+ );
22
+ }
@@ -1,24 +1,29 @@
1
1
  'use client';
2
2
 
3
- import { StyleProvider, extractStaticStyle } from 'antd-style';
3
+ import { StyleProvider } from 'antd-style';
4
4
  import { useServerInsertedHTML } from 'next/navigation';
5
- import { type PropsWithChildren, useRef } from 'react';
5
+ import { type PropsWithChildren } from 'react';
6
6
 
7
- const StyleRegistry = ({ children }: PropsWithChildren) => {
8
- const isInsert = useRef(false);
7
+ import { isDesktop } from '@/const/version';
9
8
 
9
+ const StyleRegistry = ({ children }: PropsWithChildren) => {
10
10
  useServerInsertedHTML(() => {
11
- // avoid duplicate css insert
12
- // refs: https://github.com/vercel/next.js/discussions/49354#discussioncomment-6279917
13
- if (isInsert.current) return;
14
-
15
- isInsert.current = true;
16
-
17
- // @ts-ignore
18
- return extractStaticStyle().map((item) => item.style);
11
+ return (
12
+ <style
13
+ dangerouslySetInnerHTML={{
14
+ __html: `
15
+ html body {background: #f8f8f8;}
16
+ html[data-theme="dark"] body { background-color: #000; }
17
+ ${isDesktop ? 'html body, html { background: none; }' : ''}
18
+ ${isDesktop ? 'html[data-theme="dark"] body { background: color-mix(in srgb, #000 86%, transparent); }' : ''}
19
+ ${isDesktop ? 'html[data-theme="light"] body { background: color-mix(in srgb, #f8f8f8 86%, transparent); }' : ''}
20
+ `,
21
+ }}
22
+ />
23
+ );
19
24
  });
20
25
 
21
- return <StyleProvider cache={extractStaticStyle.cache}>{children}</StyleProvider>;
26
+ return <StyleProvider>{children}</StyleProvider>;
22
27
  };
23
28
 
24
29
  export default StyleRegistry;
@@ -17,12 +17,12 @@ import AppTheme from './AppTheme';
17
17
  import { GroupWizardProvider } from './GroupWizardProvider';
18
18
  import ImportSettings from './ImportSettings';
19
19
  import Locale from './Locale';
20
+ import NextThemeProvider from './NextThemeProvider';
20
21
  import QueryProvider from './Query';
21
22
  import StoreInitialization from './StoreInitialization';
22
23
  import StyleRegistry from './StyleRegistry';
23
24
 
24
25
  interface GlobalLayoutProps {
25
- appearance: string;
26
26
  children: ReactNode;
27
27
  isMobile: boolean;
28
28
  locale: string;
@@ -36,7 +36,7 @@ const GlobalLayout = async ({
36
36
  neutralColor,
37
37
  primaryColor,
38
38
  locale: userLocale,
39
- appearance,
39
+
40
40
  isMobile,
41
41
  variants,
42
42
  }: GlobalLayoutProps) => {
@@ -45,44 +45,46 @@ const GlobalLayout = async ({
45
45
  // get default feature flags to use with ssr
46
46
  const serverFeatureFlags = getServerFeatureFlagsValue();
47
47
  const serverConfig = await getServerGlobalConfig();
48
+
48
49
  return (
49
50
  <StyleRegistry>
50
51
  <Locale antdLocale={antdLocale} defaultLang={userLocale}>
51
- <AppTheme
52
- customFontFamily={appEnv.CUSTOM_FONT_FAMILY}
53
- customFontURL={appEnv.CUSTOM_FONT_URL}
54
- defaultAppearance={appearance}
55
- defaultNeutralColor={neutralColor as any}
56
- defaultPrimaryColor={primaryColor as any}
57
- globalCDN={appEnv.CDN_USE_GLOBAL}
58
- >
59
- <ServerConfigStoreProvider
60
- featureFlags={serverFeatureFlags}
61
- isMobile={isMobile}
62
- segmentVariants={variants}
63
- serverConfig={serverConfig}
52
+ <NextThemeProvider>
53
+ <AppTheme
54
+ customFontFamily={appEnv.CUSTOM_FONT_FAMILY}
55
+ customFontURL={appEnv.CUSTOM_FONT_URL}
56
+ defaultNeutralColor={neutralColor as any}
57
+ defaultPrimaryColor={primaryColor as any}
58
+ globalCDN={appEnv.CDN_USE_GLOBAL}
64
59
  >
65
- <QueryProvider>
66
- <GroupWizardProvider>
67
- <DragUploadProvider>
68
- <LazyMotion features={domMax}>
69
- <TooltipGroup layoutAnimation={false}>
70
- <LobeAnalyticsProviderWrapper>{children}</LobeAnalyticsProviderWrapper>
71
- </TooltipGroup>
72
- <ModalHost />
73
- <ContextMenuHost />
74
- </LazyMotion>
75
- </DragUploadProvider>
76
- </GroupWizardProvider>
77
- </QueryProvider>
78
- <StoreInitialization />
79
- <Suspense>
80
- {ENABLE_BUSINESS_FEATURES ? <ReferralProvider /> : null}
81
- <ImportSettings />
82
- {process.env.NODE_ENV === 'development' && <DevPanel />}
83
- </Suspense>
84
- </ServerConfigStoreProvider>
85
- </AppTheme>
60
+ <ServerConfigStoreProvider
61
+ featureFlags={serverFeatureFlags}
62
+ isMobile={isMobile}
63
+ segmentVariants={variants}
64
+ serverConfig={serverConfig}
65
+ >
66
+ <QueryProvider>
67
+ <GroupWizardProvider>
68
+ <DragUploadProvider>
69
+ <LazyMotion features={domMax}>
70
+ <TooltipGroup layoutAnimation={false}>
71
+ <LobeAnalyticsProviderWrapper>{children}</LobeAnalyticsProviderWrapper>
72
+ </TooltipGroup>
73
+ <ModalHost />
74
+ <ContextMenuHost />
75
+ </LazyMotion>
76
+ </DragUploadProvider>
77
+ </GroupWizardProvider>
78
+ </QueryProvider>
79
+ <StoreInitialization />
80
+ <Suspense>
81
+ {ENABLE_BUSINESS_FEATURES ? <ReferralProvider /> : null}
82
+ <ImportSettings />
83
+ {process.env.NODE_ENV === 'development' && <DevPanel />}
84
+ </Suspense>
85
+ </ServerConfigStoreProvider>
86
+ </AppTheme>
87
+ </NextThemeProvider>
86
88
  </Locale>
87
89
  </StyleRegistry>
88
90
  );
@@ -1,5 +1,4 @@
1
1
  import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
2
- import { parseDefaultThemeFromCountry } from '@lobechat/utils/server';
3
2
  import debug from 'debug';
4
3
  import { type NextRequest, NextResponse } from 'next/server';
5
4
  import { UAParser } from 'ua-parser-js';
@@ -8,7 +7,6 @@ import urlJoin from 'url-join';
8
7
  import { auth } from '@/auth';
9
8
  import { OAUTH_AUTHORIZED } from '@/const/auth';
10
9
  import { LOBE_LOCALE_COOKIE } from '@/const/locale';
11
- import { LOBE_THEME_APPEARANCE } from '@/const/theme';
12
10
  import { isDesktop } from '@/const/version';
13
11
  import { appEnv } from '@/envs/app';
14
12
  import { authEnv } from '@/envs/auth';
@@ -39,10 +37,6 @@ export function defineConfig() {
39
37
  return NextResponse.next();
40
38
  }
41
39
 
42
- // 1. Read user preferences from cookies
43
- const theme = (request.cookies.get(LOBE_THEME_APPEARANCE)?.value ||
44
- parseDefaultThemeFromCountry(request)) as 'dark' | 'light';
45
-
46
40
  // locale has three levels
47
41
  // 1. search params
48
42
  // 2. cookie
@@ -67,17 +61,14 @@ export function defineConfig() {
67
61
  deviceType: device.type,
68
62
  hasCookies: {
69
63
  locale: !!request.cookies.get(LOBE_LOCALE_COOKIE)?.value,
70
- theme: !!request.cookies.get(LOBE_THEME_APPEARANCE)?.value,
71
64
  },
72
65
  locale,
73
- theme,
74
66
  });
75
67
 
76
68
  // 2. Create normalized preference values
77
69
  const route = RouteVariants.serializeVariants({
78
70
  isMobile: device.type === 'mobile',
79
71
  locale,
80
- theme,
81
72
  });
82
73
 
83
74
  logDefault('Serialized route variant: %s', route);
@@ -99,8 +90,8 @@ export function defineConfig() {
99
90
 
100
91
  // refs: https://github.com/lobehub/lobe-chat/pull/5866
101
92
  // new handle segment rewrite: /${route}${originalPathname}
102
- // / -> /zh-CN__0__dark
103
- // /discover -> /zh-CN__0__dark/discover
93
+ // / -> /zh-CN__0
94
+ // /discover -> /zh-CN__0/discover
104
95
  // All SPA routes that use react-router-dom should be rewritten to just /${route}
105
96
  const spaRoutes = [
106
97
  '/chat',
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * ComfyUI framework constants configuration
3
- * Unified management of hardcoded values with environment variable overrides / 统一管理硬编码值,支持环境变量覆盖
3
+ * Unified management of hardcoded values with environment variable overrides
4
4
  */
5
5
 
6
6
  /**
7
- * Default configuration / 默认配置
8
- * 注意:BASE_URL不再处理环境变量,由构造函数统一处理优先级
7
+ * Default configuration
8
+ * Note: BASE_URL no longer handles environment variables, priority is uniformly handled by constructor
9
9
  */
10
10
  export const COMFYUI_DEFAULTS = {
11
11
  BASE_URL: 'http://localhost:8000',
@@ -14,8 +14,8 @@ export const COMFYUI_DEFAULTS = {
14
14
  } as const;
15
15
 
16
16
  /**
17
- * FLUX model configuration / FLUX 模型配置
18
- * Removed over-engineered dynamic T5 selection, maintain simple fixed configuration / 移除过度工程化的动态T5选择,保持简单固定配置
17
+ * FLUX model configuration
18
+ * Removed over-engineered dynamic T5 selection, maintain simple fixed configuration
19
19
  */
20
20
  export const FLUX_MODEL_CONFIG = {
21
21
  FILENAME_PREFIXES: {
@@ -40,8 +40,8 @@ export const SD_MODEL_CONFIG = {
40
40
  } as const;
41
41
 
42
42
  /**
43
- * Default workflow node parameters / 工作流节点默认参数
44
- * Based on 2024 community best practices configuration / 基于 2024 年社区最佳实践配置
43
+ * Default workflow node parameters
44
+ * Based on 2024 community best practices configuration
45
45
  */
46
46
 
47
47
  /**