diff --git a/app/components/SettingsModal.jsx b/app/components/SettingsModal.jsx index 061a8f4..be54bc9 100644 --- a/app/components/SettingsModal.jsx +++ b/app/components/SettingsModal.jsx @@ -1,6 +1,7 @@ 'use client'; import { useEffect, useState } from 'react'; +import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog'; import ConfirmModal from './ConfirmModal'; import { ResetIcon, SettingsIcon } from './Icons'; @@ -20,6 +21,7 @@ export default function SettingsModal({ }) { const [sliderDragging, setSliderDragging] = useState(false); const [resetWidthConfirmOpen, setResetWidthConfirmOpen] = useState(false); + const [localSeconds, setLocalSeconds] = useState(tempSeconds); useEffect(() => { if (!sliderDragging) return; @@ -32,125 +34,143 @@ export default function SettingsModal({ }; }, [sliderDragging]); + // 外部的 tempSeconds 变更时,同步到本地显示,但不立即生效 + useEffect(() => { + setLocalSeconds(tempSeconds); + }, [tempSeconds]); + return ( -
{ + if (!open) onClose?.(); + }} > -
e.stopPropagation()}> -
- - 设置 -
- -
-
刷新频率
-
- {[30, 60, 120, 300].map((s) => ( - - ))} + +
+
+ + + 设置 +
- setTempSeconds(Number(e.target.value))} - placeholder="自定义秒数" - /> - {tempSeconds < 30 && ( -
- 最小 30 秒 -
- )} -
- {!isMobile && setContainerWidth && (
-
-
页面宽度
- {onResetContainerWidth && ( +
刷新频率
+
+ {[30, 60, 120, 300].map((s) => ( - )} -
-
- setContainerWidth(Number(e.target.value))} - onPointerDown={() => setSliderDragging(true)} - className="page-width-slider" - style={{ - flex: 1, - height: 6, - accentColor: 'var(--primary)', - }} - /> - - {Math.min(2000, Math.max(600, Number(containerWidth) || 1200))}px - + ))}
+ setLocalSeconds(Number(e.target.value))} + placeholder="自定义秒数" + /> + {localSeconds < 30 && ( +
+ 最小 30 秒 +
+ )}
- )} -
-
数据导出
-
- -
-
数据导入
-
- -
- - {importMsg && ( -
- {importMsg} + {!isMobile && setContainerWidth && ( +
+
+
页面宽度
+ {onResetContainerWidth && ( + + )} +
+
+ setContainerWidth(Number(e.target.value))} + onPointerDown={() => setSliderDragging(true)} + className="page-width-slider" + style={{ + flex: 1, + height: 6, + accentColor: 'var(--primary)', + }} + /> + + {Math.min(2000, Math.max(600, Number(containerWidth) || 1200))}px + +
)} -
-
- +
+
数据导出
+
+ +
+
数据导入
+
+ +
+ + {importMsg && ( +
+ {importMsg} +
+ )} +
+ +
+ +
-
+ {resetWidthConfirmOpen && onResetContainerWidth && ( )} -
+ ); } diff --git a/app/page.jsx b/app/page.jsx index 1a9830c..73fb29b 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -2585,9 +2585,11 @@ export default function HomePage() { await refreshAll(codes); }; - const saveSettings = (e) => { + const saveSettings = (e, secondsOverride) => { e?.preventDefault?.(); - const ms = Math.max(30, Number(tempSeconds)) * 1000; + const seconds = secondsOverride ?? tempSeconds; + const ms = Math.max(30, Number(seconds)) * 1000; + setTempSeconds(Math.round(ms / 1000)); setRefreshMs(ms); storageHelper.setItem('refreshMs', String(ms)); const w = Math.min(2000, Math.max(600, Number(containerWidth) || 1200));