增加插件,自定义座右铭

This commit is contained in:
2025-12-20 22:47:03 +08:00
parent afab936d70
commit a7556418ae
18 changed files with 3078 additions and 122 deletions

View File

@@ -29,7 +29,8 @@ const DEFAULT_SETTINGS: UserSettings = {
customWallpapers: [],
enableSearchHistory: true,
searchHistory: [],
language: 'en'
language: 'zh',
motto: '同是天涯沦落人,相逢何必曾相识'
};
type ViewMode = 'search' | 'dashboard';
@@ -232,6 +233,7 @@ const App: React.FC = () => {
<Clock
showSeconds={settings.showSeconds}
use24HourFormat={settings.use24HourFormat}
motto={settings.motto}
/>
</div>
</ErrorBoundary>

View File

@@ -4,9 +4,10 @@ import { useTranslation } from '../i18n';
interface ClockProps {
showSeconds?: boolean;
use24HourFormat?: boolean;
motto?: string;
}
const Clock: React.FC<ClockProps> = ({ showSeconds = true, use24HourFormat = true }) => {
const Clock: React.FC<ClockProps> = ({ showSeconds = true, use24HourFormat = true, motto = '同是天涯沦落人,相逢何必曾相识' }) => {
const [time, setTime] = useState(new Date());
const { language } = useTranslation();
@@ -83,8 +84,8 @@ const Clock: React.FC<ClockProps> = ({ showSeconds = true, use24HourFormat = tru
</div>
{/* Motto */}
<div className="mt-4 text-lg md:text-xl font-light text-white/70 tracking-widest uppercase">
<div className="mt-4 text-lg md:text-xl font-light text-white/70 tracking-widest uppercase text-center max-w-2xl">
{motto}
</div>
</div>
);

View File

@@ -49,6 +49,10 @@ const ThemeSettings: React.FC<ThemeSettingsProps> = ({ settings, onUpdateSetting
onUpdateSettings({ ...settings, language: lang });
};
const handleMottoChange = (e: React.ChangeEvent<HTMLInputElement>) => {
onUpdateSettings({ ...settings, motto: e.target.value });
};
return (
<div className="space-y-5">
{/* Language Selection */}
@@ -103,6 +107,18 @@ const ThemeSettings: React.FC<ThemeSettingsProps> = ({ settings, onUpdateSetting
</div>
</div>
{/* Motto Input */}
<div className="space-y-2">
<span className="text-xs font-semibold text-white/50 uppercase tracking-wider block">{t.motto}</span>
<input
type="text"
value={settings.motto || ''}
onChange={handleMottoChange}
className="w-full bg-white/10 border border-white/10 rounded-lg px-3 py-2 text-sm text-white focus:border-white/30 focus:outline-none transition-colors"
placeholder={t.enterMotto}
/>
</div>
{/* Toggle settings */}
<div className="space-y-3">
<div className="flex items-center justify-between">

View File

@@ -16,33 +16,16 @@ export const DEFAULT_BACKGROUND_IMAGE = "https://picsum.photos/1920/1080?graysca
export const PRESET_WALLPAPERS: PresetWallpaper[] = [
{
name: 'Default',
name: 'Bench',
type: 'image',
url: 'https://tc-new.z.wiki/autoupload/f/JPb3wcBYRgvdgjBZlDTRdWSEpzNQ5XwArLwhNo1hcymyl5f0KlZfm6UsKj-HyTuv/20250828/JmPj/3840X2160/light-background.png/webp'
url: '/wallpapers/bench-9964046.jpg',
thumbnail: '/wallpapers/bench-9964046.jpg'
},
{
name: 'Mountains',
name: 'People',
type: 'image',
url: 'https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?auto=format&fit=crop&w=1920&q=80',
thumbnail: 'https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?auto=format&fit=crop&w=200&q=60'
},
{
name: 'Nebula',
type: 'image',
url: 'https://images.unsplash.com/photo-1462331940025-496dfbfc7564?auto=format&fit=crop&w=1920&q=80',
thumbnail: 'https://images.unsplash.com/photo-1462331940025-496dfbfc7564?auto=format&fit=crop&w=200&q=60'
},
{
name: 'City',
type: 'image',
url: 'https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?auto=format&fit=crop&w=1920&q=80',
thumbnail: 'https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?auto=format&fit=crop&w=200&q=60'
},
{
name: 'Rain',
type: 'video',
url: 'https://assets.mixkit.co/videos/preview/mixkit-rain-falling-on-the-window-glass-1634-large.mp4',
thumbnail: 'https://images.unsplash.com/photo-1515694346937-94d85e41e6f0?auto=format&fit=crop&w=200&q=60'
url: '/wallpapers/people-10019345.jpg',
thumbnail: '/wallpapers/people-10019345.jpg'
}
];

View File

@@ -8,6 +8,8 @@ export const en: Translation = {
// Theme Settings
themeColor: 'Theme Color',
motto: 'Motto',
enterMotto: 'Enter your motto...',
showSeconds: 'Show Seconds',
use24HourFormat: '24-Hour Format',
maskBlurEffect: 'Mask Blur Effect',

View File

@@ -8,6 +8,8 @@ export const zh: Translation = {
// Theme Settings
themeColor: '主题颜色',
motto: '座右铭',
enterMotto: '输入您的座右铭...',
showSeconds: '显示秒数',
use24HourFormat: '24小时制',
maskBlurEffect: '遮罩层毛玻璃',

View File

@@ -8,6 +8,8 @@ export interface Translation {
// Theme Settings
themeColor: string;
motto: string;
enterMotto: string;
showSeconds: string;
use24HourFormat: string;
maskBlurEffect: string;

View File

@@ -3,6 +3,12 @@ import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import { ToastProvider } from './context/ToastContext';
import { registerSW } from 'virtual:pwa-register';
// Register PWA Service Worker only if not running as an extension
if (!window.location.protocol.includes('chrome-extension')) {
registerSW({ immediate: true });
}
const rootElement = document.getElementById('root');
if (!rootElement) {

View File

@@ -38,6 +38,7 @@ export interface UserSettings {
enableSearchHistory: boolean;
searchHistory: string[];
language: Language;
motto: string;
}
export type SettingsSection = 'general' | 'wallpaper' | 'search';

2
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-pwa/client" />