fix(settings): 定时切换主题去掉时区下拉与说明文字,固定用浏览器本地时区

This commit is contained in:
opsx committed 2026-10-31 22:52:58 +08:00
1 parent c090ba0564
commit c60b827262
3 files changed
+2 -33

No files matched your search

-4
View File
@@ -137,10 +137,6 @@ export default {
dark: 'Dark',
system: 'Follow System',
auto: 'Scheduled',
timezone: 'Timezone',
timezoneAria: 'Theme schedule timezone',
browser: 'Follow browser (local)',
autoHint: 'Light from {{start}}:00–{{end}}:00 in the chosen timezone, dark otherwise; the top bar toggle always works.',
},
prefsCard: {
title: 'Appearance & Language',
-4
View File
@@ -137,10 +137,6 @@ export default {
dark: '深色',
system: '跟随系统',
auto: '定时切换',
timezone: '判定时区',
timezoneAria: '主题定时切换时区',
browser: '跟随浏览器(本地)',
autoHint: '按所选时区 {{start}}:00–{{end}}:00 浅色,其余深色;顶栏可随时手动切换。',
},
prefsCard: {
title: '外观与语言',
@@ -1,4 +1,4 @@
import { memo, useMemo } from 'react'
import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { useTheme } from 'next-themes'
import { Sun, Moon, Monitor, Clock } from 'lucide-react'
@@ -7,17 +7,8 @@ import {
DAY_START_HOUR,
DAY_END_HOUR,
setThemeAuto,
setThemeTimezone,
listTimezones,
} from '@/lib/theme-schedule'
import { useScheduledTheme } from '@/hooks/useScheduledTheme'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
type ThemeMode = 'light' | 'dark' | 'system' | 'auto'
@@ -36,8 +27,7 @@ const OPTIONS: Array<{ value: ThemeMode; labelKey: string; icon: typeof Sun }> =
export const ThemeSection = memo(function ThemeSection() {
const { theme, setTheme } = useTheme()
const { t } = useTranslation('settings')
const { auto, timezone } = useScheduledTheme()
const timezones = useMemo(() => listTimezones(), [])
const { auto } = useScheduledTheme()
const activeValue: ThemeMode = auto ? 'auto' : theme === 'system' ? 'system' : theme === 'dark' ? 'dark' : 'light'
const selectTheme = (value: ThemeMode) => {
@@ -76,19 +66,6 @@ export const ThemeSection = memo(function ThemeSection() {
)
})}
</div>
{auto && (
<Select value={timezone || 'browser'} onValueChange={(v) => setThemeTimezone(v === 'browser' ? '' : v)}>
<SelectTrigger className="h-8 w-44" aria-label={t('themeCard.timezoneAria')}>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="browser">{t('themeCard.browser')}</SelectItem>
{timezones.map((tz) => (
<SelectItem key={tz} value={tz}>{tz}</SelectItem>
))}
</SelectContent>
</Select>
)}
</div>
{auto && (
<p className="text-xs text-muted-foreground">