mirror of
https://github.com/handsomezhuzhu/AeroStart.git
synced 2026-02-20 12:00:15 +00:00
Implement a modern, customizable browser start page with comprehensive features: - Multi-theme support with 8 preset color schemes - Custom wallpaper system supporting images and videos with multiple fit modes - Integrated search functionality with 5 major search engines (Google, Baidu, Bing, DuckDuckGo, Bilibili) - Real-time clock component with 12/24 hour format options - Dynamic background blur effect during search for enhanced focus - Complete i18n system with English and Chinese language support - Responsive design with smooth animations and transitions - Local storage integration for persistent user preferences - Context menu system for quick settings access - Toast notification system for user feedback - Error boundary for robust error handling Tech Stack: - React 19 with TypeScript - Vite 6 for build tooling - Tailwind CSS for styling - Local storage for data persistence Project Structure: - Core components: Clock, SearchBox, SettingsModal, ThemeSettings, WallpaperManager - Utility modules: storage management, search suggestions - Context providers: Toast notifications, i18n - Type definitions and constants configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import React, { createContext, useContext, ReactNode } from 'react';
|
|
import { Language, Translation } from './types';
|
|
import { en } from './locales/en';
|
|
import { zh } from './locales/zh';
|
|
|
|
interface I18nContextType {
|
|
language: Language;
|
|
t: Translation;
|
|
setLanguage: (lang: Language) => void;
|
|
}
|
|
|
|
const I18nContext = createContext<I18nContextType | undefined>(undefined);
|
|
|
|
const translations: Record<Language, Translation> = {
|
|
en,
|
|
zh,
|
|
};
|
|
|
|
interface I18nProviderProps {
|
|
children: ReactNode;
|
|
language: Language;
|
|
onLanguageChange: (lang: Language) => void;
|
|
}
|
|
|
|
export const I18nProvider: React.FC<I18nProviderProps> = ({
|
|
children,
|
|
language,
|
|
onLanguageChange
|
|
}) => {
|
|
const t = translations[language];
|
|
|
|
return (
|
|
<I18nContext.Provider value={{ language, t, setLanguage: onLanguageChange }}>
|
|
{children}
|
|
</I18nContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useTranslation = () => {
|
|
const context = useContext(I18nContext);
|
|
if (!context) {
|
|
throw new Error('useTranslation must be used within an I18nProvider');
|
|
}
|
|
return context;
|
|
};
|