diff --git a/src/App.css b/src/App.css index 9317408..8548cc1 100644 --- a/src/App.css +++ b/src/App.css @@ -133,6 +133,23 @@ overflow: hidden; } +.digital-clock-footer { + display: flex; + flex-direction: row; + align-items: baseline; + justify-content: flex-end; + margin-top: 4px; +} + +.digital-clock-timezone { + font-family: Arial, sans-serif; + font-weight: 600; + color: #fff; + text-shadow: 0 0 10px rgba(255, 255, 255, 0.5); + line-height: 1; + white-space: nowrap; +} + .style-button { padding: 10px 20px; font-size: 14px; diff --git a/src/App.tsx b/src/App.tsx index 15221fc..bd1f1df 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -23,10 +23,19 @@ function formatDate(date: Date): DateInfo { } } -function DigitalClock({ time, size, period, is24Hour, onToggleFormat, dateInfo }: { time: string; size: number; period?: string; is24Hour: boolean; onToggleFormat: () => void; dateInfo: DateInfo }) { +function getTimezoneInfo(): string { + // 获取本地时区名称,如 "Asia/Shanghai" + const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone + // 获取时区偏移,如 "GMT+8" + const offset = new Date().toLocaleTimeString('en-US', { timeZoneName: 'short' }).split(' ').pop() || '' + return `${timeZone} ${offset}` +} + +function DigitalClock({ time, size, period, is24Hour, onToggleFormat, dateInfo, timeZone }: { time: string; size: number; period?: string; is24Hour: boolean; onToggleFormat: () => void; dateInfo: DateInfo; timeZone: string }) { const fontSize = Math.floor(size * 0.95) const periodSize = Math.floor(size * 0.20) const dateSize = Math.floor(size * 0.20) + const timeZoneSize = Math.floor(size * 0.20) return (