Co-authored-by: Kagura Chen <daniyuu19@sjtu.edu.cn> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
7643cb8a75
commit
884aa7c7f1
@@ -19,6 +19,7 @@ import { Settings } from './pages/Settings';
|
||||
import { Setup } from './pages/Setup';
|
||||
import { useSettingsStore } from './stores/settings';
|
||||
import { useGatewayStore } from './stores/gateway';
|
||||
import { useProviderStore } from './stores/providers';
|
||||
import { applyGatewayTransportPreference } from './lib/api-client';
|
||||
|
||||
|
||||
@@ -94,6 +95,7 @@ function App() {
|
||||
const language = useSettingsStore((state) => state.language);
|
||||
const setupComplete = useSettingsStore((state) => state.setupComplete);
|
||||
const initGateway = useGatewayStore((state) => state.init);
|
||||
const initProviders = useProviderStore((state) => state.init);
|
||||
|
||||
useEffect(() => {
|
||||
initSettings();
|
||||
@@ -111,6 +113,11 @@ function App() {
|
||||
initGateway();
|
||||
}, [initGateway]);
|
||||
|
||||
// Initialize provider snapshot on mount
|
||||
useEffect(() => {
|
||||
initProviders();
|
||||
}, [initProviders]);
|
||||
|
||||
// Redirect to setup wizard if not complete
|
||||
useEffect(() => {
|
||||
if (!setupComplete && !location.pathname.startsWith('/setup')) {
|
||||
|
||||
@@ -30,8 +30,9 @@ interface ProviderState {
|
||||
defaultAccountId: string | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
|
||||
|
||||
// Actions
|
||||
init: () => Promise<void>;
|
||||
refreshProviderSnapshot: () => Promise<void>;
|
||||
createAccount: (account: ProviderAccount, apiKey?: string) => Promise<void>;
|
||||
removeAccount: (accountId: string) => Promise<void>;
|
||||
@@ -74,7 +75,11 @@ export const useProviderStore = create<ProviderState>((set, get) => ({
|
||||
defaultAccountId: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
|
||||
|
||||
init: async () => {
|
||||
await get().refreshProviderSnapshot();
|
||||
},
|
||||
|
||||
refreshProviderSnapshot: async () => {
|
||||
set({ loading: true, error: null });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user