- Add apiKeyService for localStorage-based API key management - Add ApiKeyModal component for entering/updating API key - Update geminiService to use dynamic API key - Remove .env.example as API key is now user-provided - Update to gemini-2.0-flash model The API key is now stored only in the user's browser localStorage, making the app more secure and easier to deploy. https://claude.ai/code/session_01DBAyjuKW8Qtzixc64qn9KP
18 lines
429 B
TypeScript
18 lines
429 B
TypeScript
const STORAGE_KEY = 'gemini_api_key';
|
|
|
|
export const getApiKey = (): string | null => {
|
|
return localStorage.getItem(STORAGE_KEY);
|
|
};
|
|
|
|
export const setApiKey = (key: string): void => {
|
|
localStorage.setItem(STORAGE_KEY, key);
|
|
};
|
|
|
|
export const clearApiKey = (): void => {
|
|
localStorage.removeItem(STORAGE_KEY);
|
|
};
|
|
|
|
export const hasApiKey = (): boolean => {
|
|
const key = getApiKey();
|
|
return key !== null && key.length > 0;
|
|
};
|