From 645de4248e34e33ccf321fca2014d4ce39e2e23d Mon Sep 17 00:00:00 2001 From: aurinex Date: Sun, 14 Dec 2025 22:22:05 +0500 Subject: [PATCH] minor fix --- src/renderer/App.css | 13 +++++++++++ src/renderer/pages/Settings.tsx | 41 ++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/renderer/App.css b/src/renderer/App.css index 8f6963a..d70d0e6 100644 --- a/src/renderer/App.css +++ b/src/renderer/App.css @@ -12,6 +12,19 @@ url('../../assets/fonts/benzin-bold.svg#benzin-bold') format('svg'); /* Chrome < 4, Legacy iOS */ } +:root { + --ui-scale: 1; +} + +#root { + transform: scale(var(--ui-scale)); + transform-origin: top left; + + /* компенсация, чтобы после scale не появлялись пустые области/скроллы */ + width: calc(100% / var(--ui-scale)); + height: calc(100% / var(--ui-scale)); +} + body { position: relative; color: white; diff --git a/src/renderer/pages/Settings.tsx b/src/renderer/pages/Settings.tsx index 826ed37..cf5ba49 100644 --- a/src/renderer/pages/Settings.tsx +++ b/src/renderer/pages/Settings.tsx @@ -157,8 +157,18 @@ const NotificationPositionPicker = ({ ); }; +const mapNotifPosition = ( + p: SettingsState['notificationPosition'], +): NotificationPosition => { + const [vertical, horizontal] = p.split('-') as ['top' | 'bottom', 'left' | 'center' | 'right']; + return { vertical, horizontal }; +}; const Settings = () => { + const [lastSavedSettings, setLastSavedSettings] = useState(() => { + if (typeof window === 'undefined') return defaultSettings; + return safeParseSettings(localStorage.getItem(STORAGE_KEY)) ?? defaultSettings; + }); const [notifOpen, setNotifOpen] = useState(false); const [notifMsg, setNotifMsg] = useState(''); const [notifSeverity, setNotifSeverity] = useState< @@ -176,22 +186,22 @@ const Settings = () => { }); const dirty = useMemo(() => { - if (typeof window === 'undefined') return false; - const saved = safeParseSettings(localStorage.getItem(STORAGE_KEY)) ?? defaultSettings; - return JSON.stringify(saved) !== JSON.stringify(settings); - }, [settings]); + return JSON.stringify(settings) !== JSON.stringify(lastSavedSettings); + }, [settings, lastSavedSettings]); const save = () => { try { localStorage.setItem(STORAGE_KEY, JSON.stringify(settings)); + setLastSavedSettings(settings); + window.dispatchEvent(new CustomEvent('settings-updated')); // если уведомления выключены — НЕ показываем нотификацию if (!isNotificationsEnabled()) return; setNotifMsg('Настройки успешно сохранены!'); setNotifSeverity('info'); - setNotifPos(getNotifPositionFromSettings()); + setNotifPos(mapNotifPosition(settings.notificationPosition)); setNotifOpen(true); } catch (e) { console.error('Не удалось сохранить настройки', e); @@ -200,6 +210,8 @@ const Settings = () => { const reset = () => { setSettings(defaultSettings); + setLastSavedSettings(defaultSettings); + try { localStorage.setItem(STORAGE_KEY, JSON.stringify(defaultSettings)); } catch (e) { @@ -208,28 +220,21 @@ const Settings = () => { }; const checkNotif = () => { + if (!settings.notifications) return; // если выключены — не показываем + setNotifMsg('Проверка уведомления!'); setNotifSeverity('info'); - setNotifPos(getNotifPositionFromSettings()); + setNotifPos(mapNotifPosition(settings.notificationPosition)); // 👈 важно setNotifOpen(true); - } + }; - // Apply a few settings instantly useEffect(() => { if (typeof document === 'undefined') return; - // UI scale (простая версия) - document.documentElement.style.zoom = `${settings.uiScale}%`; - - // Reduce motion + const scale = settings.uiScale / 100; + document.documentElement.style.setProperty('--ui-scale', String(scale)); document.body.classList.toggle('reduce-motion', settings.reduceMotion); - - // Blur effects (можно использовать этот класс в sx, если захочешь) document.body.classList.toggle('no-blur', !settings.blurEffects); - - // Persist - save(); - // eslint-disable-next-line react-hooks/exhaustive-deps }, [settings.uiScale, settings.reduceMotion, settings.blurEffects]); const SectionTitle = ({ children }: { children: string }) => (