From 37e90cebfa2bca5d0a4be83f39bde3986f90affe Mon Sep 17 00:00:00 2001 From: Innei Date: Sun, 1 Mar 2026 22:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(desktop):=20stub=20better-au?= =?UTF-8?q?th=20client=20for=20Electron=20renderer=20(#12563)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * πŸ› fix(desktop): stub better-auth client for Electron and improve drag regions Add auth-client.desktop.ts noop stub so the Electron renderer build skips the real better-auth dependency that was crashing module evaluation and preventing React from mounting. Also fix drag-bar regions in splash.html and error.html, and add dev:desktop convenience script. * ♻️ refactor(desktop): lazy-init better-auth client with remote server URL Replace noop stub with Proxy-based lazy initialization that creates the real better-auth client on first use, using the configured remote server URL from the electron store as baseURL. * πŸ”§ fix(desktop): update Proxy target in lazyProp for better-auth client initialization Change the Proxy target in the lazyProp function from a noop stub to a function, ensuring the apply trap works correctly for lazy initialization of the better-auth client. Signed-off-by: Innei * πŸ› fix(profile): restrict SSO providers display to non-desktop view Update the condition for rendering the SSO Providers Row in the Profile Settings to only show when the user is logged in and not on a desktop device. This change improves the user interface by preventing unnecessary display on desktop screens. Signed-off-by: Innei --------- Signed-off-by: Innei --- apps/desktop/resources/error.html | 14 ++++- apps/desktop/resources/splash.html | 13 ++++- package.json | 1 + src/libs/better-auth/auth-client.desktop.ts | 58 ++++++++++++++++++++ src/routes/(main)/settings/profile/index.tsx | 2 +- 5 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 src/libs/better-auth/auth-client.desktop.ts diff --git a/apps/desktop/resources/error.html b/apps/desktop/resources/error.html index 781aebb4f8..663f9cbc67 100644 --- a/apps/desktop/resources/error.html +++ b/apps/desktop/resources/error.html @@ -5,10 +5,18 @@ LobeHub - 连ζŽ₯ι”™θ―― +
⚠️

Connection Error

diff --git a/apps/desktop/resources/splash.html b/apps/desktop/resources/splash.html index cb29472c32..5fd4cb9032 100644 --- a/apps/desktop/resources/splash.html +++ b/apps/desktop/resources/splash.html @@ -5,10 +5,18 @@ LobeHub +
(), + genericOAuthClient(), + magicLinkClient(), + ], + }); + } + return _client; +} + +function lazyProp(key: string): any { + // Target must be a function for the Proxy apply trap to work + return new Proxy(function () {}, { + apply(_t, thisArg, args) { + return Reflect.apply(getClient()[key], thisArg, args); + }, + get(_t, prop, receiver) { + const target = getClient()[key]; + const value = Reflect.get(target, prop, receiver); + return typeof value === 'function' ? value.bind(target) : value; + }, + }); +} + +export const changeEmail = lazyProp('changeEmail'); +export const linkSocial = lazyProp('linkSocial'); +export const oauth2 = lazyProp('oauth2'); +export const accountInfo = lazyProp('accountInfo'); +export const listAccounts = lazyProp('listAccounts'); +export const requestPasswordReset = lazyProp('requestPasswordReset'); +export const resetPassword = lazyProp('resetPassword'); +export const sendVerificationEmail = lazyProp('sendVerificationEmail'); +export const signIn = lazyProp('signIn'); +export const signOut = lazyProp('signOut'); +export const signUp = lazyProp('signUp'); +export const unlinkAccount = lazyProp('unlinkAccount'); +export const useSession = lazyProp('useSession'); diff --git a/src/routes/(main)/settings/profile/index.tsx b/src/routes/(main)/settings/profile/index.tsx index 57b1da744b..74a05c8442 100644 --- a/src/routes/(main)/settings/profile/index.tsx +++ b/src/routes/(main)/settings/profile/index.tsx @@ -131,7 +131,7 @@ const ProfileSetting = ({ mobile }: ProfileSettingProps) => { )} {/* SSO Providers Row */} - {isLogin && ( + {isLogin && !isDesktop && ( <>