fix: login

This commit is contained in:
Acbox
2026-01-11 20:01:18 +08:00
parent a7e07d7467
commit 4085964be6
5 changed files with 12 additions and 12 deletions
+7 -2
View File
@@ -7,11 +7,13 @@ import { createClient as createClientApi } from '@memohome/api/client'
*/
export function createClient(context?: MemoHomeContext) {
const ctx = context || getContext()
const storage = ctx.storage
const storage = ctx.storage
const apiUrlResult = typeof storage.getApiUrl === 'function'
? storage.getApiUrl()
: (storage as unknown as Record<string, string>).apiUrl
if (apiUrlResult instanceof Promise) {
throw new Error('createClient does not support async storage. Use createClientAsync instead.')
@@ -23,13 +25,16 @@ export function createClient(context?: MemoHomeContext) {
? storage.getToken(ctx.currentUserId)
: null
// Handle async token retrieval
if (token instanceof Promise) {
throw new Error('createClient does not support async token storage. Use createClientAsync instead.')
}
const client = createClientApi(apiUrl, token ?? undefined)
return client
}