🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat: enhance desktop onboarding with sign out and localization (#11033)
Innei34a631266866
diff --git a/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts b/apps/desktop/src/main/controllers/RemoteServerConfigCtr.tsindex 5fd9a6e6f3e..5d772e2d86f 100644--- a/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts+++ b/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts@@ -96,6 +96,8 @@ export default class RemoteServerConfigCtr extends ControllerModule {const merged = this.normalizeConfig({ ...prev, ...config });storeManager.set('dataSyncConfig', merged);+ this.broadcastRemoteServerConfigUpdated();+return true;}@@ -113,9 +115,16 @@ export default class RemoteServerConfigCtr extends ControllerModule {// Clear tokens (if any)await this.clearTokens();+ this.broadcastRemoteServerConfigUpdated();+return true;}+ private broadcastRemoteServerConfigUpdated() {+ logger.debug('Broadcasting remoteServerConfigUpdated event to all windows');+ this.app.browserManager.broadcastToAllWindows('remoteServerConfigUpdated', undefined);+ }+/*** Encrypted tokens* Stored in memory for quick access, loaded from persistent storage on init.diff --git a/apps/desktop/src/main/controllers/__tests__/RemoteServerConfigCtr.test.ts b/apps/desktop/src/main/controllers/__tests__/RemoteServerConfigCtr.test.tsindex 77e63cb19a7..6f98aa17ce7 100644--- a/apps/desktop/src/main/controllers/__tests__/RemoteServerConfigCtr.test.ts+++ b/apps/desktop/src/main/controllers/__tests__/RemoteServerConfigCtr.test.ts@@ -43,7 +43,12 @@ const mockStoreManager = {set: vi.fn(),};+const mockBrowserManager = {+ broadcastToAllWindows: vi.fn(),+};+const mockApp = {+ browserManager: mockBrowserManager,storeManager: mockStoreManager,} as unknown as App;diff --git a/apps/desktop/src/main/core/infrastructure/BackendProxyProtocolManager.ts b/apps/desktop/src/main/core/infrastructure/BackendProxyProtocolManager.tsindex fff433a8d97..b27eda6b062 100644--- a/apps/desktop/src/main/core/infrastructure/BackendProxyProtocolManager.ts+++ b/apps/desktop/src/main/core/infrastructure/BackendProxyProtocolManager.ts@@ -1,5 +1,6 @@-import type { Session } from 'electron';+import { BrowserWindow, type Session } from 'electron';+import { isDev } from '@/const/env';import { createLogger } from '@/utils/logger';interface BackendProxyProtocolManagerOptions {@@ -30,6 +31,15 @@ export class BackendProxyProtocolManager {private readonly handledSessions = new WeakSet<Session>();private readonly logger = createLogger('core:BackendProxyProtocolManager');+ private notifyAuthorizationRequired() {+ const allWindows = BrowserWindow.getAllWindows();+ for (const win of allWindows) {+ if (!win.isDestroyed()) {+ win.webContents.send('authorizationRequired');+ }+ }+ }+registerWithRemoteBaseUrl(session: Session,options: BackendProxyProtocolManagerRemoteBaseOptions,@@ -85,7 +95,9 @@ export class BackendProxyProtocolManager {const headers = new Headers(request.headers);const token = await options.getAccessToken();- if (token) headers.set('Oidc-Auth', token);+ if (token) {+ headers.set('Oidc-Auth', token);+ }// eslint-disable-next-line no-undefconst requestInit: RequestInit & { duplex?: 'half' } = {@@ -126,10 +138,18 @@ export class BackendProxyProtocolManager {responseHeaders.set('Access-Control-Allow-Credentials', 'true');}+ if (isDev) {+ responseHeaders.set('x-dev-oidc-auth', token);+ }+responseHeaders.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');responseHeaders.set('Access-Control-Allow-Headers', '*');responseHeaders.set('X-Src-Url', rewrittenUrl);+ if (!token && upstreamResponse.status === 401) {+ this.notifyAuthorizationRequired();+ }+return new Response(upstreamResponse.body, {headers: responseHeaders,status: upstreamResponse.status,diff --git a/apps/desktop/src/main/core/infrastructure/__tests__/BackendProxyProtocolManager.test.ts b/apps/desktop/src/main/core/infrastructure/__tests__/BackendProxyProtocolManager.test.tsindex 9f21ab78a3e..36173c00cbb 100644--- a/apps/desktop/src/main/core/infrastructure/__tests__/BackendProxyProtocolManager.test.ts+++ b/apps/desktop/src/main/core/infrastructure/__tests__/BackendProxyProtocolManager.test.ts@@ -21,6 +21,13 @@ const { mockProtocol, protocolHandlerRef } = vi.hoisted(() => {};});+vi.mock('electron-is', () => ({+ dev: vi.fn(() => false),+ macOS: vi.fn(() => false),+ windows: vi.fn(() => false),+ linux: vi.fn(() => true),+}));+vi.mock('@/utils/logger', () => ({createLogger: () => ({debug: vi.fn(),diff --git a/apps/desktop/src/main/env.ts b/apps/desktop/src/main/env.tsindex 0ce47152a62..a9314fdead9 100644--- a/apps/desktop/src/main/env.ts+++ b/apps/desktop/src/main/env.ts@@ -76,7 +76,7 @@ export const getDesktopEnv = memoize(() =>MCP_TOOL_TIMEOUT: envNumber(60_000),// cloud server url (can be overridden for selfhost/dev)- OFFICIAL_CLOUD_SERVER: z.string().optional().default('https://lobechat.com'),+ OFFICIAL_CLOUD_SERVER: z.string().optional().default('https://app.lobehub.com'),},clientPrefix: 'PUBLIC_',client: {},diff --git a/locales/en-US/desktop-onboarding.json b/locales/en-US/desktop-onboarding.jsonnew file mode 100644index 00000000000..f8ffb6f8da7--- /dev/null+++ b/locales/en-US/desktop-onboarding.json@@ -0,0 +1,68 @@+{+ "navigation.next": "Continue",+ "screen1.description": "AI-powered productivity platform with intelligent agents",+ "screen1.navigation.next": "Start Setting Up",+ "screen1.slogan.line1": "Built for you",+ "screen1.slogan.line2": "the Super Individual",+ "screen2.badge": "Features",+ "screen2.description": "Advanced AI capabilities tailored to your workflow",+ "screen2.features.1.subtitle": "Image Generation",+ "screen2.features.1.title": "Create What your feel",+ "screen2.features.2.subtitle": "MCP Marketplace",+ "screen2.features.2.title": "Discover, Connect, Extend",+ "screen2.features.3.subtitle": "Smart Web Search",+ "screen2.features.3.title": "World Knowledge Ready",+ "screen2.features.4.subtitle": "Cross-Platform Sync",+ "screen2.features.4.title": "Your Workspace, Anywhere",+ "screen2.features.5.subtitle": "Artifacts",+ "screen2.features.5.title": "AI Meets Visual Creation",+ "screen2.features.6.subtitle": "Multi AI Providers",+ "screen2.features.6.title": "One Platform, All Models",+ "screen2.title": "Everything You Need",+ "screen3.actions.grantAccess": "Grant Access",+ "screen3.actions.granted": "Access Granted",+ "screen3.actions.openSettings": "Open Settings",+ "screen3.badge": "Permissions",+ "screen3.description": "Grant the following permissions to experience LobeHub's full capabilities",+ "screen3.permissions.1.description": "Send system notifications for task completions, AI responses, and important updates when the app is running in background",+ "screen3.permissions.1.title": "Notification Permission",+ "screen3.permissions.2.description": "Access documents and files to enable AI analysis, knowledge base creation, and document processing workflows",+ "screen3.permissions.2.title": "File & Folder Access",+ "screen3.permissions.3.description": "Capture screen content and audio input for voice interactions, screen analysis, and multimodal AI assistance",+ "screen3.permissions.3.title": "Screen & Audio Recording",+ "screen3.permissions.4.description": "Enable system-level automation and enhanced integration for seamless AI workflow execution across applications",+ "screen3.permissions.4.title": "Accessibility Settings",+ "screen3.title": "Enable Full Experience",+ "screen4.badge": "Privacy",+ "screen4.description": "Choose how you want to use LobeHub.",+ "screen4.footerNote": "You can always change this later in the settings.",+ "screen4.navigation.next": "Continue",+ "screen4.privacy.description": "If you enable Privacy Mode, none of your questions or conversations will ever be stored by us.",+ "screen4.privacy.items.1": "No data collection",+ "screen4.privacy.items.2": "No usage analytics",+ "screen4.privacy.items.3": "All processing stays local",+ "screen4.privacy.title": "Privacy Mode",+ "screen4.share.description": "To make LobeHub better, this option lets us collect usage data. This includes:",+ "screen4.share.items.1": "Performance metrics",+ "screen4.share.items.2": "Model usage patterns",+ "screen4.share.items.3": "Feature interactions",+ "screen4.share.title": "Help Improve LobeHub",+ "screen4.title": "Data Preferences",+ "screen5.actions.connectToServer": "Connect to Server",+ "screen5.actions.connecting": "Connecting...",+ "screen5.actions.signInCloud": "Sign in to LobeHub Cloud",+ "screen5.actions.signingIn": "Signing in...",+ "screen5.actions.signOut": "Sign out",+ "screen5.actions.signingOut": "Signing out...",+ "screen5.actions.tryAgain": "Try Again",+ "screen5.badge": "Sign in",+ "screen5.description": "Sign in to sync your AI agents, settings, and conversations across all devices.",+ "screen5.errors.desktopOnlyOidc": "OIDC authorization is only available in the desktop app runtime.",+ "screen5.methods.cloud.description": "Authorization by Official cloud-based version",+ "screen5.methods.cloud.name": "LobeHub Cloud",+ "screen5.methods.selfhost.description": "Connect to your own LobeHub server instance",+ "screen5.methods.selfhost.name": "Self-hosted Instance",+ "screen5.navigation.next": "Start Using LobeHub",+ "screen5.selfhost.endpointPlaceholder": "Endpoint URL (Example: https://your-server.com)",+ "screen5.title": "Connect Your Account"+}\ No newline at end of filediff --git a/locales/zh-CN/desktop-onboarding.json b/locales/zh-CN/desktop-onboarding.jsonnew file mode 100644index 00000000000..7a33a7f4d37--- /dev/null+++ b/locales/zh-CN/desktop-onboarding.json@@ -0,0 +1,68 @@+{+ "navigation.next": "继续",+ "screen1.description": "AI 驱动的生产力平台,内置智能助理",+ "screen1.navigation.next": "开始设置",+ "screen1.slogan.line1": "为你而生",+ "screen1.slogan.line2": "超级个体",+ "screen2.badge": "功能亮点",+ "screen2.description": "为你的工作流量身打造的高级 AI 能力",+ "screen2.features.1.subtitle": "图像生成",+ "screen2.features.1.title": "把灵感变成画面",+ "screen2.features.2.subtitle": "MCP 市场",+ "screen2.features.2.title": "发现 · 连接 · 扩展",+ "screen2.features.3.subtitle": "智能网页搜索",+ "screen2.features.3.title": "世界知识随时可用",+ "screen2.features.4.subtitle": "跨端同步",+ "screen2.features.4.title": "你的空间,随时随地",+ "screen2.features.5.subtitle": "Artifacts",+ "screen2.features.5.title": "AI 与视觉创作相遇",+ "screen2.features.6.subtitle": "多模型服务商",+ "screen2.features.6.title": "一个平台,连接所有模型",+ "screen2.title": "你需要的一切",+ "screen3.actions.grantAccess": "授予权限",+ "screen3.actions.granted": "已授权",+ "screen3.actions.openSettings": "打开设置",+ "screen3.badge": "权限",+ "screen3.description": "授予以下权限,以体验 LobeHub 的完整能力",+ "screen3.permissions.1.description": "在应用后台运行时,为任务完成、助理回复和重要更新发送系统通知",+ "screen3.permissions.1.title": "通知权限",+ "screen3.permissions.2.description": "访问文档与文件,用于 AI 分析、知识库构建与文档处理工作流",+ "screen3.permissions.2.title": "文件与文件夹访问",+ "screen3.permissions.3.description": "获取屏幕内容与音频输入,用于语音交互、屏幕分析与多模态协助",+ "screen3.permissions.3.title": "屏幕与音频录制",+ "screen3.permissions.4.description": "启用系统级自动化与深度集成,让工作流在不同应用间顺畅执行",+ "screen3.permissions.4.title": "辅助功能权限",+ "screen3.title": "开启完整体验",+ "screen4.badge": "隐私",+ "screen4.description": "选择你希望如何使用 LobeHub。",+ "screen4.footerNote": "你可以随时在设置里更改。",+ "screen4.navigation.next": "继续",+ "screen4.privacy.description": "启用隐私模式后,你的问题与对话不会被我们存储。",+ "screen4.privacy.items.1": "不收集数据",+ "screen4.privacy.items.2": "不做使用分析",+ "screen4.privacy.items.3": "处理尽量在本地完成",+ "screen4.privacy.title": "隐私模式",+ "screen4.share.description": "为了让 LobeHub 变得更好,我们会收集匿名使用数据,包括:",+ "screen4.share.items.1": "性能指标",+ "screen4.share.items.2": "模型使用情况",+ "screen4.share.items.3": "功能交互数据",+ "screen4.share.title": "帮助改进 LobeHub",+ "screen4.title": "数据偏好",+ "screen5.actions.connectToServer": "连接服务器",+ "screen5.actions.connecting": "正在连接…",+ "screen5.actions.signInCloud": "登录 LobeHub Cloud",+ "screen5.actions.signingIn": "正在登录…",+ "screen5.actions.signOut": "返回并退出登录",+ "screen5.actions.signingOut": "正在退出…",+ "screen5.actions.tryAgain": "重试",+ "screen5.badge": "登录",+ "screen5.description": "登录后可在所有设备间同步你的 AI 助理、设置和对话。",+ "screen5.errors.desktopOnlyOidc": "OIDC 授权仅在桌面端运行时可用。",+ "screen5.methods.cloud.description": "通过官方云端版本进行授权",+ "screen5.methods.cloud.name": "LobeHub Cloud",+ "screen5.methods.selfhost.description": "连接到你自己的 LobeHub 服务实例",+ "screen5.methods.selfhost.name": "自托管实例",+ "screen5.navigation.next": "开始使用 LobeHub",+ "screen5.selfhost.endpointPlaceholder": "Endpoint URL(示例:https://your-server.com)",+ "screen5.title": "连接你的账号"+}\ No newline at end of filediff --git a/packages/electron-client-ipc/src/events/remoteServer.ts b/packages/electron-client-ipc/src/events/remoteServer.tsindex 8825f8273c0..a4f29fad74a 100644--- a/packages/electron-client-ipc/src/events/remoteServer.ts+++ b/packages/electron-client-ipc/src/events/remoteServer.ts@@ -9,5 +9,6 @@ export interface RemoteServerBroadcastEvents {authorizationFailed: (params: { error: string }) => void;authorizationRequired: (params: void) => void;authorizationSuccessful: (params: void) => void;+ remoteServerConfigUpdated: (params: void) => void;tokenRefreshed: (params: void) => void;}diff --git a/packages/utils/src/server/auth.ts b/packages/utils/src/server/auth.tsindex 8ab26f5e7c4..77451ed5551 100644--- a/packages/utils/src/server/auth.ts+++ b/packages/utils/src/server/auth.ts@@ -1,8 +1,6 @@import { headers } from 'next/headers';import { enableBetterAuth, enableClerk, enableNextAuth } from '@/const/auth';-import { DESKTOP_USER_ID } from '@/const/desktop';-import { isDesktop } from '@/const/version';export const getUserAuth = async () => {if (enableClerk) {@@ -38,10 +36,6 @@ export const getUserAuth = async () => {return { nextAuth: session, userId };}- if (isDesktop) {- return { userId: DESKTOP_USER_ID };- }-throw new Error('Auth method is not enabled');};diff --git a/src/app/[variants]/(main)/desktop-onboarding/index.tsx b/src/app/[variants]/(main)/desktop-onboarding/index.tsxindex 81a131182d1..10bc3071d6f 100644--- a/src/app/[variants]/(main)/desktop-onboarding/index.tsx+++ b/src/app/[variants]/(main)/desktop-onboarding/index.tsx@@ -44,7 +44,8 @@ const DesktopOnboarding = () => {<OnboardingContainerWithThemeonComplete={() => {setDesktopOnboardingCompleted();- navigate('/', { replace: true });+ // Use hard reload instead of SPA navigation to ensure the app boots with the new desktop state.+ window.location.replace('/');}}/>);diff --git a/src/app/[variants]/router/desktopRouter.config.tsx b/src/app/[variants]/router/desktopRouter.config.tsxindex c1301148a72..7f22d3295cd 100644--- a/src/app/[variants]/router/desktopRouter.config.tsx+++ b/src/app/[variants]/router/desktopRouter.config.tsx@@ -389,11 +389,7 @@ export const desktopRoutes: RouteConfig[] = [path: '/',},// Onboarding route (outside main layout)- {- element: dynamicElement(() => import('../onboarding'), 'Desktop > Onboarding'),- errorElement: <ErrorBoundary resetPath="/" />,- path: '/onboarding',- },+...BusinessDesktopRoutesWithoutMainLayout,];@@ -404,4 +400,10 @@ if (isDesktop) {errorElement: <ErrorBoundary resetPath="/" />,path: '/desktop-onboarding',});+} else {+ desktopRoutes.push({+ element: dynamicElement(() => import('../onboarding'), 'Desktop > Onboarding'),+ errorElement: <ErrorBoundary resetPath="/" />,+ path: '/onboarding',+ });}diff --git a/src/features/DesktopNavigationBridge/index.tsx b/src/features/DesktopNavigationBridge/index.tsxindex aa04bde7fef..9f315a498a5 100644--- a/src/features/DesktopNavigationBridge/index.tsx+++ b/src/features/DesktopNavigationBridge/index.tsx@@ -4,6 +4,8 @@ import { useWatchBroadcast } from '@lobechat/electron-client-ipc';import { memo, useCallback } from 'react';import { useNavigate } from 'react-router-dom';+import { clearDesktopOnboardingCompleted } from '@/features/DesktopOnboarding/storage';+const DesktopNavigationBridge = memo(() => {const navigate = useNavigate();@@ -17,6 +19,13 @@ const DesktopNavigationBridge = memo(() => {useWatchBroadcast('navigate', handleNavigate);+ const handleAuthorizationRequired = useCallback(() => {+ clearDesktopOnboardingCompleted();+ navigate('/desktop-onboarding#5', { replace: true });+ }, [navigate]);++ useWatchBroadcast('authorizationRequired', handleAuthorizationRequired);+return null;});diff --git a/src/features/DesktopOnboarding/Navigation.tsx b/src/features/DesktopOnboarding/Navigation.tsxindex 6ec9db9137e..328c5a2a670 100644--- a/src/features/DesktopOnboarding/Navigation.tsx+++ b/src/features/DesktopOnboarding/Navigation.tsx@@ -3,6 +3,7 @@ import { createStaticStyles, cx } from 'antd-style';import { ChevronLeft, ChevronRight } from 'lucide-react';import * as motion from 'motion/react-m';import React from 'react';+import { useTranslation } from 'react-i18next';import { getThemeToken } from './styles/theme';@@ -57,6 +58,9 @@ const styles = createStaticStyles(({ css, cssVar }) => ({navigationButton: css`position: relative;z-index: 2;+ &:not(:disabled) > * {+ color: #000 !important;+ }`,// 导航按钮区域 - 已整合到 content 中,不再需要@@ -151,7 +155,7 @@ export const Navigation: React.FC<NavigationProps> = ({canGoNext,canGoPrev,prevButtonText = '',- nextButtonText = 'Continue',+ nextButtonText,showPrevButton = true,showNextButton = true,nextButtonDisabled = false,@@ -160,6 +164,9 @@ export const Navigation: React.FC<NavigationProps> = ({animationDuration = 1,animationDelay = 0,}) => {+ const { t } = useTranslation('desktop-onboarding');+ const resolvedNextButtonText = nextButtonText ?? t('navigation.next');+// 导航内容组件 - 单行布局const navigationContent = (<>@@ -214,7 +221,7 @@ export const Navigation: React.FC<NavigationProps> = ({onClick={onNext}type="primary">- {nextButtonText}+ {resolvedNextButtonText}{canGoNext && !nextButtonDisabled && <ChevronRight size={16} />}</Button>) : (diff --git a/src/features/DesktopOnboarding/OnboardingContainer.tsx b/src/features/DesktopOnboarding/OnboardingContainer.tsxindex 280254a5553..03e125b8ec3 100644--- a/src/features/DesktopOnboarding/OnboardingContainer.tsx+++ b/src/features/DesktopOnboarding/OnboardingContainer.tsx@@ -34,7 +34,7 @@ const styles = createStaticStyles(({ css }) => ({color: #fff;- background-color: ${cssVar.colorBgBase};+ background-color: #000;`,content: css`diff --git a/src/features/DesktopOnboarding/screens/Screen1.tsx b/src/features/DesktopOnboarding/screens/Screen1.tsxindex 8857070ce37..a50fd5f2bd7 100644--- a/src/features/DesktopOnboarding/screens/Screen1.tsx+++ b/src/features/DesktopOnboarding/screens/Screen1.tsx@@ -1,6 +1,7 @@import { createStaticStyles } from 'antd-style';import { AnimatePresence, motion } from 'motion/react';import { useEffect, useRef, useState } from 'react';+import { useTranslation } from 'react-i18next';import { LogoBrand } from '../common/LogoBrand';import { layoutStyles, mediaStyles, typographyStyles } from '../styles';@@ -33,6 +34,7 @@ interface Screen1Props {}export const Screen1 = ({ onScreenConfigChange }: Screen1Props) => {+ const { t } = useTranslation('desktop-onboarding');const [animationPhase, setAnimationPhase] = useState<'playing' | 'transitioning' | 'finished'>('playing',);@@ -91,7 +93,7 @@ export const Screen1 = ({ onScreenConfigChange }: Screen1Props) => {// 启用动画animationDuration: 1,- nextButtonText: 'Start Setting Up',+ nextButtonText: t('screen1.navigation.next'),showNextButton: true,@@ -126,7 +128,7 @@ export const Screen1 = ({ onScreenConfigChange }: Screen1Props) => {if (onScreenConfigChange) {onScreenConfigChange(CONFIG.screenConfig);}- }, [onScreenConfigChange]);+ }, [onScreenConfigChange, t]);useEffect(() => {const video = videoRef.current;@@ -292,8 +294,8 @@ export const Screen1 = ({ onScreenConfigChange }: Screen1Props) => {duration: CONFIG.animations.slogan.duration,}}>- Built for you <br />- the Super Individual+ {t('screen1.slogan.line1')} <br />+ {t('screen1.slogan.line2')}</motion.h1>{/* 说明文字 */}@@ -309,7 +311,7 @@ export const Screen1 = ({ onScreenConfigChange }: Screen1Props) => {duration: CONFIG.animations.description.duration,}}>- AI-powered productivity platform with intelligent agents+ {t('screen1.description')}</motion.p></motion.div>)}diff --git a/src/features/DesktopOnboarding/screens/Screen2.tsx b/src/features/DesktopOnboarding/screens/Screen2.tsxindex a1db2ec1f11..d0843425f83 100644--- a/src/features/DesktopOnboarding/screens/Screen2.tsx+++ b/src/features/DesktopOnboarding/screens/Screen2.tsx@@ -3,6 +3,7 @@ import { createStaticStyles, cx } from 'antd-style';import { Flower, Globe, Image, RefreshCw } from 'lucide-react';import { motion } from 'motion/react';import { useEffect } from 'react';+import { useTranslation } from 'react-i18next';import { TitleSection } from '../common/TitleSection';import { layoutStyles } from '../styles';@@ -97,57 +98,45 @@ const cardBg4 = new URL('../assets/card-bg-4.webp', import.meta.url).href;const cardBg5 = new URL('../assets/card-bg-5.webp', import.meta.url).href;const cardBg6 = new URL('../assets/card-bg-6.webp', import.meta.url).href;-// 卡片数据-const features = [+// 卡片数据(文案由 i18n 提供)+const featureMetas = [{backgroundImage: cardBg1,color: themeToken.colorPurple,icon: Image,id: 1,- subtitle: 'Image Generation',- title: 'Create What your feel',},{backgroundImage: cardBg2,color: themeToken.colorYellow,icon: MCP,id: 2,- subtitle: 'MCP Marketplace',- title: 'Discover, Connect, Extend',},{backgroundImage: cardBg3,color: themeToken.colorBlue,icon: Globe,id: 3,- subtitle: 'Smart Web Search',- title: 'World Knowledge Ready',},{backgroundImage: cardBg4,color: themeToken.colorBlue,icon: RefreshCw,id: 4,- subtitle: 'Cross-Platform Sync',- title: 'Your Workspace, Anywhere',},{backgroundImage: cardBg5,color: themeToken.colorGreen,icon: Flower,id: 5,- subtitle: 'Artifacts',- title: 'AI Meets Visual Creation',},{backgroundImage: cardBg6,color: themeToken.colorPurple,icon: RefreshCw,id: 6,- subtitle: 'Multi AI Providers',- title: 'One Platform, All Models',},-];+] as const;interface Screen2Props {onScreenConfigChange?: (config: {@@ -164,23 +153,24 @@ interface Screen2Props {}export const Screen2 = ({ onScreenConfigChange }: Screen2Props) => {- // 屏幕特定的配置- const CONFIG = {- screenConfig: {- navigation: {- animate: false,- showNextButton: true,- showPrevButton: true,- },- },- };+ const { t } = useTranslation('desktop-onboarding');// 通知父组件屏幕配置useEffect(() => {if (onScreenConfigChange) {+ // 屏幕特定的配置+ const CONFIG = {+ screenConfig: {+ navigation: {+ animate: false,+ showNextButton: true,+ showPrevButton: true,+ },+ },+ };onScreenConfigChange(CONFIG.screenConfig);}- }, [onScreenConfigChange]);+ }, [onScreenConfigChange, t]);return (<div className={layoutStyles.fullScreen}>@@ -189,14 +179,14 @@ export const Screen2 = ({ onScreenConfigChange }: Screen2Props) => {{/* 标题部分 */}<TitleSectionanimated={true}- badge="Features"- description="Advanced AI capabilities tailored to your workflow"- title="Everything You Need"+ badge={t('screen2.badge')}+ description={t('screen2.description')}+ title={t('screen2.title')}/>{/* 卡片网格 */}<div className={cx(styles.cardGrid, layoutStyles.contentSection)}>- {features.map((feature, index) => {+ {featureMetas.map((feature, index) => {const cssVariables: Record<string, string> = {'--card-bg-image': `url(${feature.backgroundImage})`,'--icon-color': feature.color,@@ -223,13 +213,17 @@ export const Screen2 = ({ onScreenConfigChange }: Screen2Props) => {{/* 图标和小标题行 */}<div className={styles.cardHeader}><feature.icon className={styles.cardIcon} />- <span className={styles.cardSubtitle}>{feature.subtitle}</span>+ <span className={styles.cardSubtitle}>+ {t(`screen2.features.${feature.id}.subtitle`)}+ </span></div>{/* 大标题 */}<h3className={styles.cardTitle}- dangerouslySetInnerHTML={{ __html: feature.title }}+ dangerouslySetInnerHTML={{+ __html: t(`screen2.features.${feature.id}.title`),+ }}/></div></motion.div>diff --git a/src/features/DesktopOnboarding/screens/Screen3.tsx b/src/features/DesktopOnboarding/screens/Screen3.tsxindex 1b7de0da1ad..61e550f3899 100644--- a/src/features/DesktopOnboarding/screens/Screen3.tsx+++ b/src/features/DesktopOnboarding/screens/Screen3.tsx@@ -2,6 +2,7 @@ import { createStaticStyles, cx } from 'antd-style';import { Bell, Check, FolderOpen, Mic, MonitorCog } from 'lucide-react';import { motion } from 'motion/react';import { CSSProperties, useCallback, useEffect, useState } from 'react';+import { useTranslation } from 'react-i18next';import { ensureElectronIpc } from '@/utils/electron/ipc';@@ -21,15 +22,13 @@ const screen3Styles = createStaticStyles(({ css, cssVar }) => ({gap: 4px;`,-// 图标样式-icon: css`+ icon: css`color: var(--permission-icon-color, currentColor);`,-// 图标容器-iconWrapper: css`+ iconWrapper: css`display: flex;flex-shrink: 0;align-items: center;@@ -94,17 +93,18 @@ iconWrapper: css`&.granted {cursor: not-allowed;- border-color: rgba(255, 255, 255, 8%);+ border-color: ${themeToken.colorGreen};- color: rgba(255, 255, 255, 40%);+ /* Use currentColor so the icon and text both become "success green" */+ color: ${themeToken.colorGreen};- opacity: 0.6;- background: rgba(255, 255, 255, 3%);+ opacity: 1;+ background: color-mix(in srgb, ${themeToken.colorGreen} 12%, transparent);&:hover {transform: none;- border-color: rgba(255, 255, 255, 8%);- background: rgba(255, 255, 255, 3%);+ border-color: ${themeToken.colorGreen};+ background: color-mix(in srgb, ${themeToken.colorGreen} 12%, transparent);}}`,@@ -146,49 +146,43 @@ iconWrapper: css``,}));-// 权限数据-const initialPermissions = [+const permissionMetas = [{- buttonText: 'Grant Access',- description:- 'Send system notifications for task completions, AI responses, and important updates when the app is running in background',- granted: false,+ descriptionKey: 'screen3.permissions.1.description',icon: Bell,iconColor: themeToken.colorYellow,id: 1,- title: 'Notification Permission',+ titleKey: 'screen3.permissions.1.title',},{- buttonText: 'Grant Access',- description:- 'Access documents and files to enable AI analysis, knowledge base creation, and document processing workflows',- granted: false,+ descriptionKey: 'screen3.permissions.2.description',icon: FolderOpen,iconColor: themeToken.colorGreen,id: 2,- title: 'File & Folder Access',+ titleKey: 'screen3.permissions.2.title',},{- buttonText: 'Grant Access',- description:- 'Capture screen content and audio input for voice interactions, screen analysis, and multimodal AI assistance',- granted: false,+ descriptionKey: 'screen3.permissions.3.description',icon: Mic,iconColor: themeToken.colorBlue,id: 3,- title: 'Screen & Audio Recording',+ titleKey: 'screen3.permissions.3.title',},{- buttonText: 'Grant Access',- description:- 'Enable system-level automation and enhanced integration for seamless AI workflow execution across applications',- granted: false,+ descriptionKey: 'screen3.permissions.4.description',icon: MonitorCog,iconColor: themeToken.colorPurple,id: 4,- title: 'Accessibility Settings',+ titleKey: 'screen3.permissions.4.title',},-];+] as const;++type PermissionMeta = (typeof permissionMetas)[number];+type PermissionButtonKey = 'screen3.actions.grantAccess' | 'screen3.actions.openSettings';+type PermissionItem = PermissionMeta & {+ buttonKey: PermissionButtonKey;+ granted: boolean;+};interface Screen3Props {onScreenConfigChange?: (config: {@@ -210,6 +204,7 @@ interface Screen3Props {}export const Screen3 = ({ onScreenConfigChange }: Screen3Props) => {+ const { t } = useTranslation('desktop-onboarding');// 屏幕特定的配置const CONFIG = {screenConfig: {@@ -221,7 +216,13 @@ export const Screen3 = ({ onScreenConfigChange }: Screen3Props) => {},};- const [permissions, setPermissions] = useState(initialPermissions);+ const [permissions, setPermissions] = useState<PermissionItem[]>(() =>+ permissionMetas.map((p) => ({+ ...p,+ buttonKey: 'screen3.actions.grantAccess',+ granted: false,+ })),+ );const checkAllPermissions = useCallback(async () => {const ipc = ensureElectronIpc();@@ -243,7 +244,7 @@ export const Screen3 = ({ onScreenConfigChange }: Screen3Props) => {prev.map((p) => {if (p.id === 1) return { ...p, granted: notifStatus === 'authorized' };// Full Disk Access cannot be checked programmatically, so it remains manual- if (p.id === 2) return { ...p, buttonText: 'Open Settings', granted: false };+ if (p.id === 2) return { ...p, buttonKey: 'screen3.actions.openSettings', granted: false };if (p.id === 3)return { ...p, granted: micStatus === 'granted' && screenStatus === 'granted' };if (p.id === 4) return { ...p, granted: accessibilityStatus };@@ -324,9 +325,9 @@ export const Screen3 = ({ onScreenConfigChange }: Screen3Props) => {{/* 标题部分 */}<TitleSectionanimated={true}- badge="Permissions"- description="Grant the following permissions to experience LobeHub's full capabilities"- title="Enable Full Experience"+ badge={t('screen3.badge')}+ description={t('screen3.description')}+ title={t('screen3.title')}/>{/* 权限列表 */}@@ -353,8 +354,8 @@ export const Screen3 = ({ onScreenConfigChange }: Screen3Props) => {{/* 内容 */}<div className={screen3Styles.content}>- <h3 className={screen3Styles.itemTitle}>{permission.title}</h3>- <p className={screen3Styles.itemDescription}>{permission.description}</p>+ <h3 className={screen3Styles.itemTitle}>{t(permission.titleKey)}</h3>+ <p className={screen3Styles.itemDescription}>{t(permission.descriptionKey)}</p></div>{/* 按钮 */}@@ -367,10 +368,10 @@ export const Screen3 = ({ onScreenConfigChange }: Screen3Props) => {{permission.granted && permission.id !== 2 ? (<><Check size={16} />- Access Granted+ {t('screen3.actions.granted')}</>) : (- permission.buttonText+ t(permission.buttonKey))}</button></motion.div>diff --git a/src/features/DesktopOnboarding/screens/Screen4.tsx b/src/features/DesktopOnboarding/screens/Screen4.tsxindex 61681e00f74..14e40d32679 100644--- a/src/features/DesktopOnboarding/screens/Screen4.tsx+++ b/src/features/DesktopOnboarding/screens/Screen4.tsx@@ -2,6 +2,7 @@ import { createStaticStyles, cx } from 'antd-style';import { CheckCircle, HeartHandshake, Shield } from 'lucide-react';import { motion } from 'motion/react';import { useCallback, useEffect } from 'react';+import { useTranslation } from 'react-i18next';import { useUserStore } from '@/store/user';import { userGeneralSettingsSelectors } from '@/store/user/selectors';@@ -176,6 +177,7 @@ interface Screen4Props {}export const Screen4 = ({ onScreenConfigChange }: Screen4Props) => {+ const { t } = useTranslation('desktop-onboarding');const telemetryEnabled = useUserStore(userGeneralSettingsSelectors.telemetry);const updateGeneralConfig = useUserStore((s) => s.updateGeneralConfig);const selectedMode: DataMode = telemetryEnabled ? 'share' : 'privacy';@@ -185,7 +187,7 @@ export const Screen4 = ({ onScreenConfigChange }: Screen4Props) => {screenConfig: {navigation: {animate: false,- nextButtonText: 'Continue',+ nextButtonText: t('screen4.navigation.next'),showNextButton: true,showPrevButton: true,},@@ -207,7 +209,7 @@ export const Screen4 = ({ onScreenConfigChange }: Screen4Props) => {if (onScreenConfigChange) {onScreenConfigChange(CONFIG.screenConfig);}- }, [onScreenConfigChange]);+ }, [onScreenConfigChange, t]);return (<div className={layoutStyles.fullScreen}>@@ -216,9 +218,9 @@ export const Screen4 = ({ onScreenConfigChange }: Screen4Props) => {{/* 标题部分 */}<TitleSectionanimated={true}- badge="Privacy"- description="Choose how you want to use LobeHub."- title="Data Preferences"+ badge={t('screen4.badge')}+ description={t('screen4.description')}+ title={t('screen4.title')}/>{/* 选项卡区域 */}@@ -238,17 +240,17 @@ export const Screen4 = ({ onScreenConfigChange }: Screen4Props) => {<div className={screen4Styles.cardHeader}><HeartHandshake color={themeToken.colorGreen} size={48} />- <h3 className={screen4Styles.cardTitle}>Help Improve LobeHub</h3>+ <h3 className={screen4Styles.cardTitle}>{t('screen4.share.title')}</h3></div><p className={screen4Styles.cardDescription}>- To make LobeHub better, this option lets us collect usage data. This includes:+ {t('screen4.share.description')}</p><ul className={screen4Styles.featureList}>- <li>Performance metrics</li>- <li>Model usage patterns</li>- <li>Feature interactions</li>+ <li>{t('screen4.share.items.1')}</li>+ <li>{t('screen4.share.items.2')}</li>+ <li>{t('screen4.share.items.3')}</li></ul></div>@@ -261,18 +263,17 @@ export const Screen4 = ({ onScreenConfigChange }: Screen4Props) => {<div className={screen4Styles.cardHeader}><Shield color={themeToken.colorBlue} size={48} />- <h3 className={screen4Styles.cardTitle}>Privacy Mode</h3>+ <h3 className={screen4Styles.cardTitle}>{t('screen4.privacy.title')}</h3></div><p className={screen4Styles.cardDescription}>- If you enable Privacy Mode, none of your questions or conversations will ever be- stored by us.+ {t('screen4.privacy.description')}</p><ul className={screen4Styles.featureList}>- <li>No data collection</li>- <li>No usage analytics</li>- <li>All processing stays local</li>+ <li>{t('screen4.privacy.items.1')}</li>+ <li>{t('screen4.privacy.items.2')}</li>+ <li>{t('screen4.privacy.items.3')}</li></ul></div></motion.div>@@ -284,7 +285,7 @@ export const Screen4 = ({ onScreenConfigChange }: Screen4Props) => {initial={{ opacity: 0 }}transition={{ delay: 0.5, duration: 0.5 }}>- You can always change this later in the settings.+ {t('screen4.footerNote')}</motion.p></div></div>diff --git a/src/features/DesktopOnboarding/screens/Screen5.tsx b/src/features/DesktopOnboarding/screens/Screen5.tsxindex 4c470567ee3..8765789a9e0 100644--- a/src/features/DesktopOnboarding/screens/Screen5.tsx+++ b/src/features/DesktopOnboarding/screens/Screen5.tsx@@ -3,6 +3,7 @@ import { createStaticStyles, cx } from 'antd-style';import { Cloud, Server } from 'lucide-react';import { motion } from 'motion/react';import { useEffect, useState } from 'react';+import { useTranslation } from 'react-i18next';import { isDesktop } from '@/const/version';import { useElectronStore } from '@/store/electron';@@ -230,6 +231,35 @@ const screen4Styles = createStaticStyles(({ css, cssVar }) => ({transform: translateY(0);}`,++ // 退出登录按钮(次要操作)+ signOutButton: css`+ cursor: pointer;++ display: inline-flex;+ align-items: center;+ justify-content: center;++ margin-block-start: 16px;+ padding-block: 10px;+ padding-inline: 28px;+ border: 1px solid rgba(255, 255, 255, 18%);+ border-radius: ${cssVar.borderRadius};++ font-size: ${cssVar.fontSize};+ font-weight: 600;+ color: rgba(255, 255, 255, 85%);++ background: rgba(255, 255, 255, 4%);++ &:hover {+ background: rgba(255, 255, 255, 8%);+ }++ &:active {+ background: rgba(255, 255, 255, 6%);+ }+ `,}));// 登录方式类型@@ -238,21 +268,20 @@ type LoginMethod = 'cloud' | 'selfhost';// 登录状态类型type LoginStatus = 'idle' | 'loading' | 'success' | 'error';-// 登录方式配置-const loginMethods = {+const loginMethodMetas = {cloud: {- description: 'Authorization by Official cloud-based version',+ descriptionKey: 'screen5.methods.cloud.description',icon: Cloud,id: 'cloud' as LoginMethod,- name: 'LobeHub Cloud',+ nameKey: 'screen5.methods.cloud.name',},selfhost: {- description: 'Connect to your own LobeHub server instance',+ descriptionKey: 'screen5.methods.selfhost.description',icon: Server,id: 'selfhost' as LoginMethod,- name: 'Self-hosted Instance',+ nameKey: 'screen5.methods.selfhost.name',},-};+} as const satisfies Record<LoginMethod, unknown>;interface Screen5Props {onScreenConfigChange?: (config: {@@ -274,11 +303,13 @@ interface Screen5Props {}export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {+ const { t } = useTranslation('desktop-onboarding');const [currentMethod, setCurrentMethod] = useState<LoginMethod>('cloud');const [endpoint, setEndpoint] = useState('');const [cloudLoginStatus, setCloudLoginStatus] = useState<LoginStatus>('idle');const [selfhostLoginStatus, setSelfhostLoginStatus] = useState<LoginStatus>('idle');const [remoteError, setRemoteError] = useState<string | null>(null);+ const [isSigningOut, setIsSigningOut] = useState(false);const [dataSyncConfig,@@ -288,6 +319,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {connectRemoteServer,refreshServerConfig,clearRemoteServerSyncError,+ disconnectRemoteServer,] = useElectronStore((s) => [s.dataSyncConfig,s.isConnectingServer,@@ -296,6 +328,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {s.connectRemoteServer,s.refreshServerConfig,s.clearRemoteServerSyncError,+ s.disconnectRemoteServer,]);// Ensure remote server config is loaded early (desktop only hook)@@ -331,7 +364,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {animate: false,nextButtonDisabled: !canStart(),nextButtonHighlight: true,- nextButtonText: 'Start Using LobeHub',+ nextButtonText: t('screen5.navigation.next'),showNextButton: true,showPrevButton: true,},@@ -343,7 +376,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {if (onScreenConfigChange) {onScreenConfigChange(CONFIG.screenConfig);}- }, [onScreenConfigChange, currentMethod, cloudLoginStatus, selfhostLoginStatus]);+ }, [onScreenConfigChange, currentMethod, cloudLoginStatus, selfhostLoginStatus, t]);// 处理登录方式切换const handleMethodChange = (method: LoginMethod) => {@@ -361,7 +394,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {const handleCloudLogin = async () => {// Desktop runtime guardif (!isDesktop) {- setRemoteError('OIDC authorization is only available in the desktop app runtime.');+ setRemoteError(t('screen5.errors.desktopOnlyOidc'));setCloudLoginStatus('error');return;}@@ -381,7 +414,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {const handleSelfhostConnect = async () => {// Desktop runtime guardif (!isDesktop) {- setRemoteError('OIDC authorization is only available in the desktop app runtime.');+ setRemoteError(t('screen5.errors.desktopOnlyOidc'));setSelfhostLoginStatus('error');return;}@@ -411,6 +444,25 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {}};+ // 退出登录(断开远程同步授权)并回到登录选择+ const handleSignOut = async () => {+ if (isSigningOut) return;++ setIsSigningOut(true);+ setRemoteError(null);+ clearRemoteServerSyncError();++ try {+ await disconnectRemoteServer();+ await refreshServerConfig();+ } finally {+ setCloudLoginStatus('idle');+ setSelfhostLoginStatus('idle');+ setEndpoint('');+ setIsSigningOut(false);+ }+ };+// Sync local UI status with real remote configuseEffect(() => {if (isCloudAuthed) setCloudLoginStatus('success');@@ -464,13 +516,36 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {// 渲染不同登录方式的内容const renderLoginContent = () => {- const method = loginMethods[currentMethod];+ const method = loginMethodMetas[currentMethod];+ const methodName = t(method.nameKey);+ const methodDescription = t(method.descriptionKey);switch (currentMethod) {case 'cloud': {// 如果已有登录结果,显示结果页面if (cloudLoginStatus === 'success') {- return <AuthResult animated={true} key="cloud-result" success={true} />;+ return (+ <>+ <AuthResult animated={true} key="cloud-result" success={true} />+ {remoteError && <p className={screen4Styles.errorText}>{remoteError}</p>}+ <motion.button+ animate={{ opacity: 1, y: 0 }}+ className={cx(+ screen4Styles.signOutButton,+ (isSigningOut || isConnectingServer) && screen4Styles.loadingButton,+ )}+ disabled={isSigningOut || isConnectingServer}+ initial={{ opacity: 0, y: 30 }}+ key="cloud-signout"+ onClick={handleSignOut}+ transition={{ delay: 0.3, duration: 0.5 }}+ whileHover={{ scale: 1.02 }}+ whileTap={{ scale: 0.98 }}+ >+ {isSigningOut ? t('screen5.actions.signingOut') : t('screen5.actions.signOut')}+ </motion.button>+ </>+ );}// 如果登录失败,显示失败结果但允许重新登录@@ -490,7 +565,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {whileHover={{ scale: 1.02 }}whileTap={{ scale: 0.98 }}>- Try Again+ {t('screen5.actions.tryAgain')}</motion.button></>);@@ -517,7 +592,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {key="cloud-desc"transition={{ delay: 0.4, duration: 0.5 }}>- {method.description}+ {methodDescription}</motion.p>{/* 登录按钮 */}@@ -535,7 +610,9 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {whileHover={{ scale: 1.02 }}whileTap={{ scale: 0.98 }}>- {cloudLoginStatus === 'loading' ? 'Signing in...' : 'Sign in to LobeHub Cloud'}+ {cloudLoginStatus === 'loading'+ ? t('screen5.actions.signingIn')+ : t('screen5.actions.signInCloud')}</motion.button></>);@@ -544,7 +621,28 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {case 'selfhost': {// 如果连接成功,显示成功结果页面if (selfhostLoginStatus === 'success') {- return <AuthResult animated={true} key="selfhost-result" success={true} />;+ return (+ <>+ <AuthResult animated={true} key="selfhost-result" success={true} />+ {remoteError && <p className={screen4Styles.errorText}>{remoteError}</p>}+ <motion.button+ animate={{ opacity: 1, y: 0 }}+ className={cx(+ screen4Styles.signOutButton,+ (isSigningOut || isConnectingServer) && screen4Styles.loadingButton,+ )}+ disabled={isSigningOut || isConnectingServer}+ initial={{ opacity: 0, y: 30 }}+ key="selfhost-signout"+ onClick={handleSignOut}+ transition={{ delay: 0.3, duration: 0.5 }}+ whileHover={{ scale: 1.02 }}+ whileTap={{ scale: 0.98 }}+ >+ {isSigningOut ? t('screen5.actions.signingOut') : t('screen5.actions.signOut')}+ </motion.button>+ </>+ );}// 如果连接失败,显示失败结果但允许重新连接@@ -564,7 +662,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {whileHover={{ scale: 1.02 }}whileTap={{ scale: 0.98 }}>- Try Again+ {t('screen5.actions.tryAgain')}</motion.button></>);@@ -581,8 +679,8 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {transition={{ delay: 0.3, duration: 0.5 }}><Server color={themeToken.colorGreen} size={80} />- <h2 className={screen4Styles.serviceTitle}>{method.name}</h2>- <p className={screen4Styles.authDescription}>{method.description}</p>+ <h2 className={screen4Styles.serviceTitle}>{methodName}</h2>+ <p className={screen4Styles.authDescription}>{methodDescription}</p></motion.div>{/* Endpoint 输入框 */}@@ -594,7 +692,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {initial={{ opacity: 0, y: 30 }}key="selfhost-input"onChange={(e) => setEndpoint(e.target.value)}- placeholder="Endpoint URL (Example: https://your-server.com)"+ placeholder={t('screen5.selfhost.endpointPlaceholder')}transition={{ delay: 0.5, duration: 0.5 }}type="text"value={endpoint}@@ -617,7 +715,9 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {whileHover={{ scale: 1.02 }}whileTap={{ scale: 0.98 }}>- {selfhostLoginStatus === 'loading' ? 'Connecting...' : 'Connect to Server'}+ {selfhostLoginStatus === 'loading'+ ? t('screen5.actions.connecting')+ : t('screen5.actions.connectToServer')}</motion.button></div></>@@ -637,9 +737,9 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {{/* 标题部分 */}<TitleSectionanimated={true}- badge="Sign in"- description="Sign in to sync your AI agents, settings, and conversations across all devices."- title="Connect Your Account"+ badge={t('screen5.badge')}+ description={t('screen5.description')}+ title={t('screen5.title')}/>{/* 登录区域 */}@@ -656,7 +756,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {transition={{ delay: 0.7, duration: 0.5 }}><div className={screen4Styles.methodOptions}>- {Object.values(loginMethods).map((method) => (+ {Object.values(loginMethodMetas).map((method) => (<motion.divclassName={cx(screen4Styles.methodCard,@@ -668,7 +768,7 @@ export const Screen5 = ({ onScreenConfigChange }: Screen5Props) => {whileTap={{ scale: 0.98 }}>{method.icon && <method.icon size={20} />}- <span className={screen4Styles.methodCardText}>{method.name}</span>+ <span className={screen4Styles.methodCardText}>{t(method.nameKey)}</span></motion.div>))}</div>diff --git a/src/layout/GlobalProvider/Query.tsx b/src/layout/GlobalProvider/Query.tsxindex e427bfdd8fa..07769b92883 100644--- a/src/layout/GlobalProvider/Query.tsx+++ b/src/layout/GlobalProvider/Query.tsx@@ -1,5 +1,6 @@'use client';+import { useWatchBroadcast } from '@lobechat/electron-client-ipc';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import React, { type PropsWithChildren, useEffect, useState } from 'react';import { SWRConfig, useSWRConfig } from 'swr';@@ -19,6 +20,15 @@ const SWRMutateInitializer = ({ children }: PropsWithChildren) => {setScopedMutate(mutate);}, [mutate]);+ useWatchBroadcast('remoteServerConfigUpdated', () => {+ try {+ const result = mutate((key) => true, undefined, { revalidate: true });+ void result?.catch?.(() => {});+ } catch {+ // Ignore: SWR cache may not be ready yet in early boot.+ }+ });+// eslint-disable-next-line react/jsx-no-useless-fragmentreturn <>{children}</>;};diff --git a/src/layout/GlobalProvider/StoreInitialization.tsx b/src/layout/GlobalProvider/StoreInitialization.tsxindex 5d2586d224f..aafd502ad94 100644--- a/src/layout/GlobalProvider/StoreInitialization.tsx+++ b/src/layout/GlobalProvider/StoreInitialization.tsx@@ -1,7 +1,6 @@'use client';import { INBOX_SESSION_ID, enableNextAuth } from '@lobechat/const';-import { usePathname } from 'next/navigation';import { memo } from 'react';import { useTranslation } from 'react-i18next';import { createStoreUpdater } from 'zustand-utils';@@ -15,14 +14,15 @@ import { useGlobalStore } from '@/store/global';import { useServerConfigStore } from '@/store/serverConfig';import { serverConfigSelectors } from '@/store/serverConfig/selectors';import { useUserStore } from '@/store/user';-import { authSelectors, onboardingSelectors } from '@/store/user/selectors';+import { authSelectors } from '@/store/user/selectors';import { useUserMemoryStore } from '@/store/userMemory';+import { useUserStateRedirect } from './useUserStateRedirect';+const StoreInitialization = memo(() => {// prefetch error ns to avoid don't show error content correctlyuseTranslation('error');- const pathname = usePathname();const [isLogin, isSignedIn, useInitUserState] = useUserStore((s) => [authSelectors.isLogin(s),s.isSignedIn,@@ -70,21 +70,11 @@ const StoreInitialization = memo(() => {// init user memory identities (for chat context injection)useInitIdentities(isLoginOnInit);+ const onUserStateSuccess = useUserStateRedirect();+// init user stateuseInitUserState(isLoginOnInit, serverConfig, {- onSuccess: (state) => {- if (!state.isInWaitList && !pathname?.includes('/waitlist')) {- window.location.href = '/waitlist';- return;- }-- // Skip redirect if already on onboarding page- if (pathname?.includes('/onboarding')) return;-- if (onboardingSelectors.needsOnboarding(state)) {- window.location.href = '/onboarding';- }- },+ onSuccess: onUserStateSuccess,});const useStoreUpdater = createStoreUpdater(useGlobalStore);diff --git a/src/layout/GlobalProvider/useUserStateRedirect.ts b/src/layout/GlobalProvider/useUserStateRedirect.tsnew file mode 100644index 00000000000..6d402d8785d--- /dev/null+++ b/src/layout/GlobalProvider/useUserStateRedirect.ts@@ -0,0 +1,100 @@+'use client';++import { usePathname } from 'next/navigation';+import { useCallback } from 'react';++import { OFFICIAL_URL } from '@lobechat/const';++import { isDesktop } from '@/const/version';+import { getDesktopOnboardingCompleted } from '@/features/DesktopOnboarding/storage';+import { useElectronStore } from '@/store/electron';+import { useUserStore } from '@/store/user';+import { onboardingSelectors } from '@/store/user/selectors';+import type { UserInitializationState } from '@/types/user';++const redirectIfNotOn = (currentPath: string | null | undefined, path: string) => {+ if (!currentPath?.startsWith(path)) {+ window.location.href = path;+ }+};++const useCurrentPathname = () => {+ const pathname = usePathname();+ return useCallback(() => {+ if (typeof window === 'undefined') return pathname;+ return window.location.pathname || pathname;+ }, [pathname]);+};++export const useDesktopUserStateRedirect = () => {+ const dataSyncConfig = useElectronStore((s) => s.dataSyncConfig);+ const logout = useUserStore((s) => s.logout);++ const handleDesktopWaitlist = useCallback(async () => {+ const waitlistBaseUrl = dataSyncConfig.remoteServerUrl || OFFICIAL_URL;+ let waitlistUrl = waitlistBaseUrl;+ try {+ waitlistUrl = new URL('/waitlist', waitlistBaseUrl).toString();+ } catch {+ // Ignore: keep fallback URL for external open attempt.+ }++ try {+ const { electronSystemService } = await import('@/services/electron/system');+ await electronSystemService.openExternalLink(waitlistUrl);+ } catch {+ // Ignore: fallback to logout flow even if IPC is unavailable.+ }++ try {+ const { remoteServerService } = await import('@/services/electron/remoteServer');+ await remoteServerService.clearRemoteServerConfig();+ } catch {+ // Ignore: fallback to logout flow even if IPC is unavailable.+ }++ await logout();+ }, [dataSyncConfig.remoteServerUrl, logout]);++ return useCallback(+ (state: UserInitializationState) => {+ if (state.isInWaitList === true) {+ void handleDesktopWaitlist();+ return;+ }++ if (!getDesktopOnboardingCompleted()) return;+ // Desktop onboarding is handled by desktop-only flow.+ },+ [handleDesktopWaitlist],+ );+};++export const useWebUserStateRedirect = (getCurrentPathname: () => string | null | undefined) =>+ useCallback(+ (state: UserInitializationState) => {+ if (state.isInWaitList === true) {+ redirectIfNotOn(getCurrentPathname(), '/waitlist');+ return;+ }++ if (!onboardingSelectors.needsOnboarding(state)) return;++ redirectIfNotOn(getCurrentPathname(), '/onboarding');+ },+ [getCurrentPathname],+ );++export const useUserStateRedirect = () => {+ const getCurrentPathname = useCurrentPathname();+ const desktopRedirect = useDesktopUserStateRedirect();+ const webRedirect = useWebUserStateRedirect(getCurrentPathname);++ return useCallback(+ (state: UserInitializationState) => {+ const redirect = isDesktop ? desktopRedirect : webRedirect;+ redirect(state);+ },+ [desktopRedirect, webRedirect],+ );+};diff --git a/src/libs/trpc/lambda/index.ts b/src/libs/trpc/lambda/index.tsindex 21f0dcc2f18..ad4007a2526 100644--- a/src/libs/trpc/lambda/index.ts+++ b/src/libs/trpc/lambda/index.ts@@ -7,8 +7,6 @@* @link https://trpc.io/docs/v11/router* @link https://trpc.io/docs/v11/procedures*/-import { DESKTOP_USER_ID } from '@/const/desktop';-import { isDesktop } from '@/const/version';import { openTelemetry } from '../middleware/openTelemetry';import { userAuth } from '../middleware/userAuth';@@ -27,11 +25,7 @@ export const router = trpc.router;**/const baseProcedure = trpc.procedure.use(openTelemetry);-export const publicProcedure = baseProcedure.use(({ next, ctx }) => {- return next({- ctx: { ...ctx, userId: isDesktop ? DESKTOP_USER_ID : ctx.userId },- });-});+export const publicProcedure = baseProcedure;// procedure that asserts that the user is logged inexport const authedProcedure = baseProcedure.use(oidcAuth).use(userAuth);diff --git a/src/libs/trpc/middleware/userAuth.ts b/src/libs/trpc/middleware/userAuth.tsindex b862df50290..e0a6e95f9bb 100644--- a/src/libs/trpc/middleware/userAuth.ts+++ b/src/libs/trpc/middleware/userAuth.ts@@ -1,20 +1,12 @@import { TRPCError } from '@trpc/server';import { enableBetterAuth, enableClerk, enableNextAuth } from '@/const/auth';-import { DESKTOP_USER_ID } from '@/const/desktop';-import { isDesktop } from '@/const/version';import { trpc } from '../lambda/init';export const userAuth = trpc.middleware(async (opts) => {const { ctx } = opts;- // 桌面端模式下,跳过默认鉴权逻辑- if (isDesktop) {- return opts.next({- ctx: { userId: DESKTOP_USER_ID },- });- }// `ctx.user` is nullableif (!ctx.userId) {if (enableClerk) {diff --git a/src/locales/default/desktop-onboarding.ts b/src/locales/default/desktop-onboarding.tsnew file mode 100644index 00000000000..88d7211f688--- /dev/null+++ b/src/locales/default/desktop-onboarding.ts@@ -0,0 +1,80 @@+export default {+ 'navigation.next': 'Continue',++ 'screen1.description': 'AI-powered productivity platform with intelligent agents',+ 'screen1.navigation.next': 'Start Setting Up',+ 'screen1.slogan.line1': 'Built for you',+ 'screen1.slogan.line2': 'the Super Individual',++ 'screen2.badge': 'Features',+ 'screen2.description': 'Advanced AI capabilities tailored to your workflow',+ 'screen2.features.1.subtitle': 'Image Generation',+ 'screen2.features.1.title': 'Create What your feel',+ 'screen2.features.2.subtitle': 'MCP Marketplace',+ 'screen2.features.2.title': 'Discover, Connect, Extend',+ 'screen2.features.3.subtitle': 'Smart Web Search',+ 'screen2.features.3.title': 'World Knowledge Ready',+ 'screen2.features.4.subtitle': 'Cross-Platform Sync',+ 'screen2.features.4.title': 'Your Workspace, Anywhere',+ 'screen2.features.5.subtitle': 'Artifacts',+ 'screen2.features.5.title': 'AI Meets Visual Creation',+ 'screen2.features.6.subtitle': 'Multi AI Providers',+ 'screen2.features.6.title': 'One Platform, All Models',+ 'screen2.title': 'Everything You Need',++ 'screen3.actions.grantAccess': 'Grant Access',+ 'screen3.actions.granted': 'Access Granted',+ 'screen3.actions.openSettings': 'Open Settings',+ 'screen3.badge': 'Permissions',+ 'screen3.description': "Grant the following permissions to experience LobeHub's full capabilities",+ 'screen3.permissions.1.description':+ 'Send system notifications for task completions, AI responses, and important updates when the app is running in background',+ 'screen3.permissions.1.title': 'Notification Permission',+ 'screen3.permissions.2.description':+ 'Access documents and files to enable AI analysis, knowledge base creation, and document processing workflows',+ 'screen3.permissions.2.title': 'File & Folder Access',+ 'screen3.permissions.3.description':+ 'Capture screen content and audio input for voice interactions, screen analysis, and multimodal AI assistance',+ 'screen3.permissions.3.title': 'Screen & Audio Recording',+ 'screen3.permissions.4.description':+ 'Enable system-level automation and enhanced integration for seamless AI workflow execution across applications',+ 'screen3.permissions.4.title': 'Accessibility Settings',+ 'screen3.title': 'Enable Full Experience',++ 'screen4.badge': 'Privacy',+ 'screen4.description': 'Choose how you want to use LobeHub.',+ 'screen4.footerNote': 'You can always change this later in the settings.',+ 'screen4.navigation.next': 'Continue',+ 'screen4.privacy.description':+ 'If you enable Privacy Mode, none of your questions or conversations will ever be stored by us.',+ 'screen4.privacy.items.1': 'No data collection',+ 'screen4.privacy.items.2': 'No usage analytics',+ 'screen4.privacy.items.3': 'All processing stays local',+ 'screen4.privacy.title': 'Privacy Mode',+ 'screen4.share.description':+ 'To make LobeHub better, this option lets us collect usage data. This includes:',+ 'screen4.share.items.1': 'Performance metrics',+ 'screen4.share.items.2': 'Model usage patterns',+ 'screen4.share.items.3': 'Feature interactions',+ 'screen4.share.title': 'Help Improve LobeHub',+ 'screen4.title': 'Data Preferences',++ 'screen5.actions.connectToServer': 'Connect to Server',+ 'screen5.actions.connecting': 'Connecting...',+ 'screen5.actions.signInCloud': 'Sign in to LobeHub Cloud',+ 'screen5.actions.signingIn': 'Signing in...',+ 'screen5.actions.signOut': 'Sign out',+ 'screen5.actions.signingOut': 'Signing out...',+ 'screen5.actions.tryAgain': 'Try Again',+ 'screen5.badge': 'Sign in',+ 'screen5.description': 'Sign in to sync your AI agents, settings, and conversations across all devices.',+ 'screen5.errors.desktopOnlyOidc': 'OIDC authorization is only available in the desktop app runtime.',+ 'screen5.methods.cloud.description': 'Authorization by Official cloud-based version',+ 'screen5.methods.cloud.name': 'LobeHub Cloud',+ 'screen5.methods.selfhost.description': 'Connect to your own LobeHub server instance',+ 'screen5.methods.selfhost.name': 'Self-hosted Instance',+ 'screen5.navigation.next': 'Start Using LobeHub',+ 'screen5.selfhost.endpointPlaceholder': 'Endpoint URL (Example: https://your-server.com)',+ 'screen5.title': 'Connect Your Account',+};+diff --git a/src/locales/default/index.ts b/src/locales/default/index.tsindex 40e42de0240..02d57baed5a 100644--- a/src/locales/default/index.ts+++ b/src/locales/default/index.ts@@ -25,6 +25,7 @@ import migration from './migration';import modelProvider from './modelProvider';import models from './models';import oauth from './oauth';+import desktopOnboarding from './desktop-onboarding';import onboarding from './onboarding';import plugin from './plugin';import portal from './portal';@@ -66,6 +67,7 @@ const resources = {modelProvider,models,oauth,+ 'desktop-onboarding': desktopOnboarding,onboarding,plugin,portal,diff --git a/src/server/routers/async/caller.ts b/src/server/routers/async/caller.tsindex 158498e387d..f3012c0c484 100644--- a/src/server/routers/async/caller.ts+++ b/src/server/routers/async/caller.ts@@ -5,10 +5,8 @@ import urlJoin from 'url-join';import { serverDBEnv } from '@/config/db';import { LOBE_CHAT_AUTH_HEADER } from '@/const/auth';-import { isDesktop } from '@/const/version';import { appEnv } from '@/envs/app';import { createAsyncCallerFactory } from '@/libs/trpc/async';-import { createAsyncContextInner } from '@/libs/trpc/async/context';import { KeyVaultsGateKeeper } from '@/server/modules/KeyVaultsEncrypt';import { asyncRouter } from './index';@@ -55,7 +53,7 @@ interface CreateCallerOptions {}/**- * 创建 caller 的工厂方法,兼容 desktop server 和 remote server 环境+ * 创建 caller 的工厂方法,使用 HTTP Client 调用* 使用方式统一成 caller.a.b() 的调用方式*/export const createAsyncCaller = async (@@ -63,52 +61,34 @@ export const createAsyncCaller = async (): Promise<UnifiedAsyncCaller> => {const { userId, jwtPayload } = options;- if (isDesktop) {- // Desktop 环境:使用 caller 直接同线程调用方法- const asyncContext = await createAsyncContextInner({- jwtPayload,- // 参考 src/libs/trpc/async/asyncAuth.ts- secret: serverDBEnv.KEY_VAULTS_SECRET,- userId,+ const httpClient = await createAsyncServerClient(userId, jwtPayload);+ const createRecursiveProxy = (client: any, path: string[]): any => {+ // The target is a dummy function, so that 'apply' can be triggered.+ return new Proxy(() => {}, {+ apply: (_target, _thisArg, args) => {+ // 'apply' is triggered by the function call `(...)`.+ // The `path` at this point is the full path to the procedure.++ // Traverse the original httpClient to get the actual procedure object.+ const procedure = path.reduce((obj, key) => (obj ? obj[key] : undefined), client);++ if (procedure && typeof procedure.mutate === 'function') {+ // If we found a valid procedure, call its mutate method.+ return procedure.mutate(...args);+ } else {+ // This should not happen if the call path is correct.+ const message = `Procedure not found or not valid at path: ${path.join('.')}`;+ throw new Error(message);+ }+ },+ get: (_, property: string) => {+ // When a property is accessed, we just extend the path and return a new proxy.+ // This handles `caller.file.parseFileToChunks`+ if (property === 'then') return undefined; // Prevent async/await issues+ return createRecursiveProxy(client, [...path, property as string]);+ },});+ };- const createCaller = createAsyncCallerFactory(asyncRouter);- const caller = createCaller(asyncContext);-- return caller;- }- // 非 Desktop 环境:使用 HTTP Client- // http client 调用方式是 client.a.b.mutate(), 我希望统一成 caller.a.b() 的调用方式- else {- const httpClient = await createAsyncServerClient(userId, jwtPayload);- const createRecursiveProxy = (client: any, path: string[]): any => {- // The target is a dummy function, so that 'apply' can be triggered.- return new Proxy(() => {}, {- apply: (target, thisArg, args) => {- // 'apply' is triggered by the function call `(...)`.- // The `path` at this point is the full path to the procedure.-- // Traverse the original httpClient to get the actual procedure object.- const procedure = path.reduce((obj, key) => (obj ? obj[key] : undefined), client);-- if (procedure && typeof procedure.mutate === 'function') {- // If we found a valid procedure, call its mutate method.- return procedure.mutate(...args);- } else {- // This should not happen if the call path is correct.- const message = `Procedure not found or not valid at path: ${path.join('.')}`;- throw new Error(message);- }- },- get: (_, property: string) => {- // When a property is accessed, we just extend the path and return a new proxy.- // This handles `caller.file.parseFileToChunks`- if (property === 'then') return undefined; // Prevent async/await issues- return createRecursiveProxy(client, [...path, property as string]);- },- });- };-- return createRecursiveProxy(httpClient, []);- }+ return createRecursiveProxy(httpClient, []);};diff --git a/src/services/electron/system.ts b/src/services/electron/system.tsindex 5951b5ef00a..e4f729ba6cc 100644--- a/src/services/electron/system.ts+++ b/src/services/electron/system.ts@@ -40,6 +40,10 @@ class ElectronSystemService {return ensureElectronIpc().windows.setWindowSize(params);}+ async openExternalLink(url: string): Promise<void> {+ return ensureElectronIpc().system.openExternalLink(url);+ }+showContextMenu = async (type: string, data?: any) => {return ensureElectronIpc().menu.showContextMenu({ data, type });};diff --git a/src/store/aiInfra/slices/aiProvider/action.ts b/src/store/aiInfra/slices/aiProvider/action.tsindex 32c61dc92b7..07c589c9b13 100644--- a/src/store/aiInfra/slices/aiProvider/action.ts+++ b/src/store/aiInfra/slices/aiProvider/action.ts@@ -1,4 +1,3 @@-import { DESKTOP_USER_ID, isDesktop } from '@lobechat/const';import { getModelPropertyWithFallback, resolveImageSinglePrice } from '@lobechat/model-runtime';import { uniqBy } from 'es-toolkit/compat';import {@@ -16,7 +15,7 @@ import { mutate, useClientDataSWR } from '@/libs/swr';import { aiProviderService } from '@/services/aiProvider';import { type AiInfraStore } from '@/store/aiInfra/store';import { useUserStore } from '@/store/user';-import { authSelectors, userProfileSelectors } from '@/store/user/selectors';+import { authSelectors } from '@/store/user/selectors';import {type AiProviderDetailItem,type AiProviderListItem,@@ -319,26 +318,11 @@ export const createAiProviderSlice: StateCreator<},),- useFetchAiProviderRuntimeState: (isLogin, isSyncActive?) => {+ useFetchAiProviderRuntimeState: (isLogin) => {const isAuthLoaded = useUserStore(authSelectors.isLoaded);- const userId = useUserStore(userProfileSelectors.userId);// Only fetch when auth is loaded and login status is explicitly defined (true or false)// Prevents unnecessary requests when login state is null/undefined- let shouldFetch = isAuthLoaded && isLogin !== null && isLogin !== undefined;-- if (isDesktop) {- if (isSyncActive) {- if (userId === undefined || userId === DESKTOP_USER_ID) {- shouldFetch = false;- } else {- shouldFetch = true;- }- } else if (userId === undefined) {- shouldFetch = false;- } else {- shouldFetch = true;- }- }+ const shouldFetch = isAuthLoaded && isLogin !== null && isLogin !== undefined;return useClientDataSWR<AiProviderRuntimeStateWithBuiltinModels | undefined>(shouldFetch ? [AiProviderSwrKey.fetchAiProviderRuntimeState, isLogin] : null,@@ -399,7 +383,6 @@ export const createAiProviderSlice: StateCreator<};},{- focusThrottleInterval: isDesktop ? 100 : undefined,onSuccess: (data) => {if (!data) return;diff --git a/src/utils/i18n/loadI18nNamespaceModule.ts b/src/utils/i18n/loadI18nNamespaceModule.tsindex bc2a9a2ec7a..43354dc4143 100644--- a/src/utils/i18n/loadI18nNamespaceModule.ts+++ b/src/utils/i18n/loadI18nNamespaceModule.ts@@ -1,3 +1,5 @@+import { isDesktop } from '@/const/version';+export interface LoadI18nNamespaceModuleParams {defaultLang: string;lng: string;@@ -8,6 +10,10 @@ export interface LoadI18nNamespaceModuleParams {export const loadI18nNamespaceModule = async (params: LoadI18nNamespaceModuleParams) => {const { defaultLang, normalizeLocale, lng, ns } = params;+ // Desktop-only namespaces should never be loaded in web runtime.+ // This is a defensive guard: the desktop router already prevents reaching those pages on web.+ if (!isDesktop && ns === 'desktop-onboarding') return { default: {} };+if (lng === defaultLang) return import(`@/locales/default/${ns}`);return import(`@/../locales/${normalizeLocale(lng)}/${ns}.json`);