mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-12 15:26:55 +08:00
feat: improve user onboarding and setup UX (#1436)
* feat: add beginner onboarding and mode switching flow * chore: ignore local gh auth config * fix: restore kline fallback and align onboarding language --------- Co-authored-by: zavier-bin <zhaobbbhhh@gmail.com>
This commit is contained in:
@@ -4,6 +4,8 @@ import type {
|
||||
UpdateModelConfigRequest,
|
||||
UpdateExchangeConfigRequest,
|
||||
CreateExchangeRequest,
|
||||
BeginnerOnboardingResponse,
|
||||
CurrentBeginnerWalletResponse,
|
||||
} from '../../types'
|
||||
import { API_BASE, httpClient, CryptoService } from './helpers'
|
||||
|
||||
@@ -183,4 +185,24 @@ export const configApi = {
|
||||
if (!result.success) throw new Error('Failed to fetch server IP')
|
||||
return result.data!
|
||||
},
|
||||
|
||||
async prepareBeginnerOnboarding(): Promise<BeginnerOnboardingResponse> {
|
||||
const result = await httpClient.post<BeginnerOnboardingResponse>(
|
||||
`${API_BASE}/onboarding/beginner`
|
||||
)
|
||||
if (!result.success || !result.data) {
|
||||
throw new Error(result.message || 'Failed to prepare beginner onboarding')
|
||||
}
|
||||
return result.data
|
||||
},
|
||||
|
||||
async getCurrentBeginnerWallet(): Promise<CurrentBeginnerWalletResponse> {
|
||||
const result = await httpClient.get<CurrentBeginnerWalletResponse>(
|
||||
`${API_BASE}/onboarding/beginner/current`
|
||||
)
|
||||
if (!result.success || !result.data) {
|
||||
throw new Error(result.message || 'Failed to fetch current beginner wallet')
|
||||
}
|
||||
return result.data
|
||||
},
|
||||
}
|
||||
|
||||
28
web/src/lib/onboarding.ts
Normal file
28
web/src/lib/onboarding.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
export type UserMode = 'beginner' | 'advanced'
|
||||
|
||||
const USER_MODE_KEY = 'nofx_user_mode'
|
||||
const BEGINNER_WALLET_ADDRESS_KEY = 'nofx_beginner_wallet_address'
|
||||
|
||||
export function getUserMode(): UserMode | null {
|
||||
const value = localStorage.getItem(USER_MODE_KEY)
|
||||
if (value === 'beginner' || value === 'advanced') {
|
||||
return value
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function setUserMode(mode: UserMode) {
|
||||
localStorage.setItem(USER_MODE_KEY, mode)
|
||||
}
|
||||
|
||||
export function getPostAuthPath(mode: UserMode | null | undefined): string {
|
||||
return mode === 'beginner' ? '/welcome' : '/traders'
|
||||
}
|
||||
|
||||
export function setBeginnerWalletAddress(address: string) {
|
||||
localStorage.setItem(BEGINNER_WALLET_ADDRESS_KEY, address)
|
||||
}
|
||||
|
||||
export function getBeginnerWalletAddress(): string | null {
|
||||
return localStorage.getItem(BEGINNER_WALLET_ADDRESS_KEY)
|
||||
}
|
||||
Reference in New Issue
Block a user