mirror of
https://github.com/cita-777/metapi.git
synced 2026-11-02 21:38:32 +08:00
- Introduced `NormalizedContentBlock`, `NormalizedUsage`, and related types for structured data handling. - Implemented utility functions for creating and merging normalized usage statistics. - Added a new module for shared transformers to manage chat formats. feat: Implement app local state management - Created functions to clear application installation state and manage local storage keys. - Added constants for theme and user profile storage keys. test: Add tests for BrandIcon component rendering - Implemented tests to ensure BrandIcon does not force a colored background for recognized brands. test: Enhance ModelAnalysisPanel tests - Added tests for rendering token summaries with compact units in ModelAnalysisPanel. test: Add tests for ModernSelect component - Implemented tests to verify icon rendering for selected options in ModernSelect. test: Add number formatting tests - Created tests for `formatCompactTokenMetric` to validate token formatting logic. feat: Implement account creation intent handling - Added logic to handle session and API key creation intents in the Accounts page. test: Add tests for dashboard performance card - Implemented tests to verify rendering of performance metrics in the dashboard. feat: Implement default connection segment resolution - Added logic to determine initial connection segments based on platform types. test: Add tests for settings factory reset functionality - Implemented tests to verify the factory reset process and local state clearing. test: Add tests for site creation redirect logic - Implemented tests to verify redirection based on site capabilities during creation. test: Add tests for token routes refresh decision action - Implemented tests to verify refresh decision actions in TokenRoutes. test: Add tests for token routes snapshot load - Implemented tests to verify loading of cached snapshot data in TokenRoutes.
29 lines
1013 B
TypeScript
29 lines
1013 B
TypeScript
import { clearAuthSession } from './authSession.js';
|
|
|
|
export const THEME_MODE_STORAGE_KEY = 'theme_mode';
|
|
export const LEGACY_THEME_STORAGE_KEY = 'theme';
|
|
export const USER_PROFILE_STORAGE_KEY = 'user_profile';
|
|
export const FIRST_USE_DOC_REMINDER_KEY = 'metapi_first_use_docs_reminder_seen_v1';
|
|
|
|
type StorageLike = {
|
|
getItem?: (key: string) => string | null;
|
|
setItem?: (key: string, value: string) => void;
|
|
removeItem: (key: string) => void;
|
|
};
|
|
|
|
function resolveStorage(storage?: StorageLike | null): StorageLike | null {
|
|
if (storage) return storage;
|
|
if (typeof localStorage !== 'undefined') return localStorage;
|
|
return null;
|
|
}
|
|
|
|
export function clearAppInstallationState(storage?: StorageLike | null): void {
|
|
const target = resolveStorage(storage);
|
|
if (!target) return;
|
|
clearAuthSession(target as never);
|
|
target.removeItem(THEME_MODE_STORAGE_KEY);
|
|
target.removeItem(LEGACY_THEME_STORAGE_KEY);
|
|
target.removeItem(USER_PROFILE_STORAGE_KEY);
|
|
target.removeItem(FIRST_USE_DOC_REMINDER_KEY);
|
|
}
|