feat: 接入公开币种目录并统一多币种金额与语言初始化处理
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
persistPlayerBearerToken,
|
||||
readPersistedPlayerBearerToken,
|
||||
} from "@/lib/player-session";
|
||||
import type { PublicCurrencyRow } from "@/types/api/currency";
|
||||
import type { PlayerMeData } from "@/types/api/player-me";
|
||||
|
||||
export type PlayerEntryPhase = "loading" | "error" | "success";
|
||||
@@ -21,6 +22,7 @@ export type PlayerEntryStep = {
|
||||
type PlayerSessionState = {
|
||||
bearerToken: string | null;
|
||||
profile: PlayerMeData | null;
|
||||
currencies: PublicCurrencyRow[];
|
||||
phase: PlayerEntryPhase;
|
||||
progress: number;
|
||||
errorMessage: string | null;
|
||||
@@ -29,6 +31,7 @@ type PlayerSessionState = {
|
||||
restoreBearerToken: () => string | null;
|
||||
clearBearerToken: () => void;
|
||||
setProfile: (profile: PlayerMeData | null) => void;
|
||||
setCurrencies: (currencies: PublicCurrencyRow[]) => void;
|
||||
setPhase: (phase: PlayerEntryPhase) => void;
|
||||
setProgress: (progress: number) => void;
|
||||
setErrorMessage: (message: string | null) => void;
|
||||
@@ -47,6 +50,7 @@ function initialSteps(): PlayerEntryStep[] {
|
||||
export const usePlayerSessionStore = create<PlayerSessionState>((set) => ({
|
||||
bearerToken: null,
|
||||
profile: null,
|
||||
currencies: [],
|
||||
phase: "loading",
|
||||
progress: 0,
|
||||
errorMessage: null,
|
||||
@@ -83,6 +87,7 @@ export const usePlayerSessionStore = create<PlayerSessionState>((set) => ({
|
||||
},
|
||||
|
||||
setProfile: (profile) => set({ profile }),
|
||||
setCurrencies: (currencies) => set({ currencies }),
|
||||
setPhase: (phase) => set({ phase }),
|
||||
setProgress: (progress) => set({ progress: Math.max(0, Math.min(100, progress)) }),
|
||||
setErrorMessage: (errorMessage) => set({ errorMessage }),
|
||||
@@ -99,4 +104,4 @@ export const usePlayerSessionStore = create<PlayerSessionState>((set) => ({
|
||||
errorMessage: null,
|
||||
steps: initialSteps(),
|
||||
}),
|
||||
}));
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user