Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e44617189a | ||
|
|
dfa1898332 | ||
|
|
a92f642a3e | ||
|
|
8176df3ca2 | ||
|
|
20a260d0cc | ||
|
|
288a96d04b | ||
|
|
f61e076e46 | ||
|
|
3a93961738 | ||
|
|
349ce51c67 |
62
CHANGELOG.md
62
CHANGELOG.md
@@ -6,6 +6,61 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.8.0] — 2026-06-09
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- На `Обзор` добавлен помощник дня: рекомендации по пропускам, питанию,
|
||||||
|
вечерним провалам, первому запуску и хорошему ритму.
|
||||||
|
- Добавлены разминка-сессии на 3/5/10 минут: приложение собирает короткий
|
||||||
|
набор действий из включённых упражнений и записывает выполнение в историю.
|
||||||
|
- Добавлена компактная недельная аналитика: активные дни, повторы, процент
|
||||||
|
закрытия, пропуски и лучший день.
|
||||||
|
- На странице `Упражнения` появились пресеты: офисная разминка, спина и шея,
|
||||||
|
минимум на день и набор после катки.
|
||||||
|
- В `Настройки` добавлен тон напоминаний: спокойный, краткий, настойчивый или
|
||||||
|
с юмором.
|
||||||
|
- Dota-долг после матча теперь предлагает разбивать большой объём на подходы:
|
||||||
|
сколько сделать сейчас и сколько можно оставить на потом.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Новый набор фич встроен в существующий `v0.6.6` / `последнее-удачное`
|
||||||
|
интерфейс без возврата к отклонённому редизайну `v0.7.0`.
|
||||||
|
|
||||||
|
## [0.7.1] — 2026-06-09
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Полный редизайн `v0.7.0` откачен: интерфейс возвращен к сохраненной
|
||||||
|
версии `последнее-удачное` / `v0.6.6`, потому что новое направление не
|
||||||
|
подошло.
|
||||||
|
- `v0.7.1` публикуется как обычное обновление, чтобы пользователи на `v0.7.0`
|
||||||
|
автоматически получили возврат к последнему удачному внешнему виду.
|
||||||
|
|
||||||
|
## [0.6.6] — 2026-06-08
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Settings получили верхнюю панель состояния: сразу видно, работают ли напоминания,
|
||||||
|
включены ли тихие часы, авто-пауза встреч и запуск вместе с Windows.
|
||||||
|
- Добавлен renderer-стенд `npm run dev:renderer` с демо-данными для безопасной
|
||||||
|
визуальной проверки UI без доступа к реальным пользовательским настройкам.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Settings перегруппированы: язык и тема теперь находятся в одном блоке “Интерфейс”,
|
||||||
|
а главный переключатель напоминаний вынесен в раздел “Напоминания”.
|
||||||
|
- Сводные карточки на вторичных страницах больше не обрезают длинные значения и
|
||||||
|
используют более спокойную сетку для десктопных ширин.
|
||||||
|
- Sidebar теперь показывает “Напоминания на паузе”, если глобальный режим остановлен.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- На главном экране дата больше не получает искусственную капитализацию.
|
||||||
|
- Цели и ближайшие действия показывают единицы измерения: например “осталось 30 раз”.
|
||||||
|
- Русский статус трекинга матчей больше не показывает английское `Setup`.
|
||||||
|
|
||||||
## [0.6.5] — 2026-06-07
|
## [0.6.5] — 2026-06-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -387,7 +442,7 @@ clearHistory/import`, Dashboard на него подписан.
|
|||||||
- **Modal focus trap + focus restore + aria-labelledby.** Tab/Shift-Tab
|
- **Modal focus trap + focus restore + aria-labelledby.** Tab/Shift-Tab
|
||||||
больше не вываливаются на нижний слой; на закрытии фокус
|
больше не вываливаются на нижний слой; на закрытии фокус
|
||||||
возвращается на триггер.
|
возвращается на триггер.
|
||||||
- **Sidebar mobile drawer:** Esc закрывает, focus trap внутри, focus
|
- **Sidebar compact drawer:** Esc закрывает, focus trap внутри, focus
|
||||||
restore на гамбургер, `role="dialog"` + `aria-modal`.
|
restore на гамбургер, `role="dialog"` + `aria-modal`.
|
||||||
- **Tray menu i18n** — пункты меню следуют `settings.language`.
|
- **Tray menu i18n** — пункты меню следуют `settings.language`.
|
||||||
- **Bilingual heatmap.** Title, легенда, weekday-лейблы и tooltip
|
- **Bilingual heatmap.** Title, легенда, weekday-лейблы и tooltip
|
||||||
@@ -527,7 +582,10 @@ days=[Mon..Fri]` теперь правильно проверяется день
|
|||||||
иконки), системный трей, автозапуск с Windows, native-уведомления,
|
иконки), системный трей, автозапуск с Windows, native-уведомления,
|
||||||
NSIS-инсталлятор, auto-update через electron-updater.
|
NSIS-инсталлятор, auto-update через electron-updater.
|
||||||
|
|
||||||
[Unreleased]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.6.5...HEAD
|
[Unreleased]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.8.0...HEAD
|
||||||
|
[0.8.0]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.7.1...v0.8.0
|
||||||
|
[0.7.1]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.7.0...v0.7.1
|
||||||
|
[0.6.6]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.6.5...v0.6.6
|
||||||
[0.6.5]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.6.4...v0.6.5
|
[0.6.5]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.6.4...v0.6.5
|
||||||
[0.6.4]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.6.3...v0.6.4
|
[0.6.4]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.6.3...v0.6.4
|
||||||
[0.6.3]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.6.2...v0.6.3
|
[0.6.3]: https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/compare/v0.6.2...v0.6.3
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
Windows desktop приложение, которое помогает делать короткие перерывы без потери фокуса: держит план дня, напоминает размяться, ведёт недельные челленджи и превращает Dota 2 статистику после матча в игровые долги.
|
Windows desktop приложение, которое помогает делать короткие перерывы без потери фокуса: держит план дня, напоминает размяться, ведёт недельные челленджи и превращает Dota 2 статистику после матча в игровые долги.
|
||||||
|
|
||||||
[](https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/releases/latest)
|
[](https://git.xn--90adajar8af4h.xn--p1ai/AnRil/laude/releases/latest)
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
|
|
||||||
## Что внутри
|
## Что внутри
|
||||||
@@ -12,10 +12,12 @@ Windows desktop приложение, которое помогает делат
|
|||||||
- **Питание** — отдельная вкладка с приёмами пищи по времени суток (завтрак/обед/ужин/перекусы), выбор дней недели, пресеты быстрого добавления. Напоминания по настенным часам, а не по интервалу.
|
- **Питание** — отдельная вкладка с приёмами пищи по времени суток (завтрак/обед/ужин/перекусы), выбор дней недели, пресеты быстрого добавления. Напоминания по настенным часам, а не по интервалу.
|
||||||
- **История и стрики** — heatmap-календарь активности, ежедневный счётчик, серия дней подряд.
|
- **История и стрики** — heatmap-календарь активности, ежедневный счётчик, серия дней подряд.
|
||||||
- **Обзор** — главный экран с ближайшим действием, планом дня, уровнем, недельными мини-челленджами и игровым долгом.
|
- **Обзор** — главный экран с ближайшим действием, планом дня, уровнем, недельными мини-челленджами и игровым долгом.
|
||||||
|
- **Помощник дня** — советы по пропускам, питанию, вечерним провалам, короткие разминка-сессии и недельная аналитика.
|
||||||
|
- **Пресеты** — готовые наборы упражнений для офиса, спины/шеи, минимального дня и нагрузки после катки.
|
||||||
- **Тихие часы** — окно времени когда напоминания подавляются (например `22:00 → 08:00`), с выбором дней недели.
|
- **Тихие часы** — окно времени когда напоминания подавляются (например `22:00 → 08:00`), с выбором дней недели.
|
||||||
- **Сделал частично** — степпер `−/+` в окне напоминания: если ты сделал 5 из 10, в историю запишется честное число.
|
- **Сделал частично** — степпер `−/+` в окне напоминания: если ты сделал 5 из 10, в историю запишется честное число.
|
||||||
- **Игровая интеграция (Dota 2)** — Game State Integration читает статистику матча, после Победа/Поражение показывает экран с «причитающимися» повторениями (например `10 смертей × 3 = 30 приседаний`).
|
- **Игровая интеграция (Dota 2)** — Game State Integration читает статистику матча, после Победа/Поражение показывает экран с «причитающимися» повторениями и помогает разбить большой долг на подходы.
|
||||||
- **Apple-style интерфейс** — Plus Jakarta Sans + Bricolage Grotesque, iOS-палитра, vibrancy sidebar, spring-анимации, светлая/тёмная/системная тема.
|
- **Фирменный desktop-интерфейс** — Plus Jakarta Sans + Bricolage Grotesque, мягкая палитра, sidebar, spring-анимации, светлая/тёмная/системная тема.
|
||||||
- **Два языка** — русский и английский, переключение мгновенное.
|
- **Два языка** — русский и английский, переключение мгновенное.
|
||||||
- **Auto-update** — приложение само скачивает новые версии из фиксированного `update-channel` (проверка каждый час, силент-ретрай при сетевых сбоях).
|
- **Auto-update** — приложение само скачивает новые версии из фиксированного `update-channel` (проверка каждый час, силент-ретрай при сетевых сбоях).
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ npm run typecheck # tsc по main + renderer
|
|||||||
npm run verify # typecheck + tests + lint + build + audit summary
|
npm run verify # typecheck + tests + lint + build + audit summary
|
||||||
npm run test # vitest в watch-режиме
|
npm run test # vitest в watch-режиме
|
||||||
npm run test:run # vitest один раз (для CI)
|
npm run test:run # vitest один раз (для CI)
|
||||||
|
npm run dev:renderer # renderer-стенд с демо-данными для UI-проверки
|
||||||
npm run build # сборка без NSIS
|
npm run build # сборка без NSIS
|
||||||
npm run dist # сборка + NSIS-инсталлятор → release/
|
npm run dist # сборка + NSIS-инсталлятор → release/
|
||||||
npm run release -- -Bump patch # bump версии + tag + push + upload в Gitea
|
npm run release -- -Bump patch # bump версии + tag + push + upload в Gitea
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "laude",
|
"name": "laude",
|
||||||
"version": "0.6.5",
|
"version": "0.8.0",
|
||||||
"description": "Разомнись — Windows desktop break and exercise reminder",
|
"description": "Разомнись — Windows desktop break and exercise reminder",
|
||||||
"main": "out/main/index.js",
|
"main": "out/main/index.js",
|
||||||
"author": "AnRil",
|
"author": "AnRil",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "electron-vite dev",
|
"dev": "electron-vite dev",
|
||||||
|
"dev:renderer": "vite --config vite.renderer.config.mjs",
|
||||||
"build": "electron-vite build",
|
"build": "electron-vite build",
|
||||||
"preview": "electron-vite preview",
|
"preview": "electron-vite preview",
|
||||||
"typecheck:node": "tsc --noEmit -p tsconfig.node.json",
|
"typecheck:node": "tsc --noEmit -p tsconfig.node.json",
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ function safeStr(v: unknown, max = 200): string | undefined {
|
|||||||
const SETTINGS_KEYS: (keyof Settings)[] = [
|
const SETTINGS_KEYS: (keyof Settings)[] = [
|
||||||
'globalEnabled',
|
'globalEnabled',
|
||||||
'notificationMode',
|
'notificationMode',
|
||||||
|
'notificationTone',
|
||||||
'soundEnabled',
|
'soundEnabled',
|
||||||
'voicePromptsEnabled',
|
'voicePromptsEnabled',
|
||||||
'meetingAutoPause',
|
'meetingAutoPause',
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import type {
|
|||||||
Theme,
|
Theme,
|
||||||
Language,
|
Language,
|
||||||
NotificationMode,
|
NotificationMode,
|
||||||
|
NotificationTone,
|
||||||
ReminderCategory
|
ReminderCategory
|
||||||
} from '@shared/types'
|
} from '@shared/types'
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ const MAX_STR_LEN = 200
|
|||||||
const VALID_THEMES: Theme[] = ['system', 'light', 'dark']
|
const VALID_THEMES: Theme[] = ['system', 'light', 'dark']
|
||||||
const VALID_LANGS: Language[] = ['ru', 'en']
|
const VALID_LANGS: Language[] = ['ru', 'en']
|
||||||
const VALID_NOTIFY: NotificationMode[] = ['toast', 'modal', 'both']
|
const VALID_NOTIFY: NotificationMode[] = ['toast', 'modal', 'both']
|
||||||
|
const VALID_TONES: NotificationTone[] = ['calm', 'brief', 'firm', 'playful']
|
||||||
const VALID_GAME_IDS: GameId[] = ['dota2']
|
const VALID_GAME_IDS: GameId[] = ['dota2']
|
||||||
const VALID_STATS: GameStat[] = [
|
const VALID_STATS: GameStat[] = [
|
||||||
'deaths',
|
'deaths',
|
||||||
@@ -416,6 +418,11 @@ export function validateSettingsPatch(raw: unknown): Partial<Settings> | null {
|
|||||||
if (v === undefined) return null
|
if (v === undefined) return null
|
||||||
out.notificationMode = v
|
out.notificationMode = v
|
||||||
}
|
}
|
||||||
|
if ('notificationTone' in raw) {
|
||||||
|
const v = oneOf(raw.notificationTone, VALID_TONES)
|
||||||
|
if (v === undefined) return null
|
||||||
|
out.notificationTone = v
|
||||||
|
}
|
||||||
if ('theme' in raw) {
|
if ('theme' in raw) {
|
||||||
const v = oneOf(raw.theme, VALID_THEMES)
|
const v = oneOf(raw.theme, VALID_THEMES)
|
||||||
if (v === undefined) return null
|
if (v === undefined) return null
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ let backendSubscribed = false
|
|||||||
export default function App(): JSX.Element {
|
export default function App(): JSX.Element {
|
||||||
const hydrated = useAppStore((s) => s.hydrated)
|
const hydrated = useAppStore((s) => s.hydrated)
|
||||||
const settings = useAppStore((s) => s.state?.settings)
|
const settings = useAppStore((s) => s.state?.settings)
|
||||||
const [mobileNavOpen, setMobileNavOpen] = useState(false)
|
const [compactNavOpen, setCompactNavOpen] = useState(false)
|
||||||
const [whatsNew, setWhatsNew] = useState<{
|
const [whatsNew, setWhatsNew] = useState<{
|
||||||
open: boolean
|
open: boolean
|
||||||
versions: string[]
|
versions: string[]
|
||||||
@@ -90,16 +90,16 @@ export default function App(): JSX.Element {
|
|||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<div className="h-screen w-screen flex flex-col bg-bg">
|
<div className="h-screen w-screen flex flex-col bg-bg">
|
||||||
<Titlebar onMenuClick={() => setMobileNavOpen(true)} />
|
<Titlebar onMenuClick={() => setCompactNavOpen(true)} />
|
||||||
<div className="flex-1 flex overflow-hidden">
|
<div className="flex-1 flex overflow-hidden">
|
||||||
<Sidebar
|
<Sidebar
|
||||||
mobileOpen={mobileNavOpen}
|
compactOpen={compactNavOpen}
|
||||||
onMobileClose={() => setMobileNavOpen(false)}
|
onCompactClose={() => setCompactNavOpen(false)}
|
||||||
/>
|
/>
|
||||||
<main className="flex-1 overflow-hidden min-w-0">
|
<main className="flex-1 overflow-hidden min-w-0">
|
||||||
{hydrated ? (
|
{hydrated ? (
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<RoutedPages onNav={() => setMobileNavOpen(false)} />
|
<RoutedPages onNav={() => setCompactNavOpen(false)} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
) : (
|
) : (
|
||||||
// Skeleton на время гидрации — settings (и язык) ещё не
|
// Skeleton на время гидрации — settings (и язык) ещё не
|
||||||
|
|||||||
@@ -16,13 +16,15 @@ import type {
|
|||||||
Meal,
|
Meal,
|
||||||
Settings,
|
Settings,
|
||||||
ChallengeResult,
|
ChallengeResult,
|
||||||
Language
|
Language,
|
||||||
|
NotificationTone
|
||||||
} from '@shared/types'
|
} from '@shared/types'
|
||||||
import { statLabel } from '@shared/types'
|
import { statLabel } from '@shared/types'
|
||||||
import { Icon } from './lib/icon'
|
import { Icon } from './lib/icon'
|
||||||
import { formatInterval } from './lib/format'
|
import { formatInterval } from './lib/format'
|
||||||
import { speak } from './lib/tts'
|
import { speak } from './lib/tts'
|
||||||
import { translate, translateN } from './i18n'
|
import { translate, translateN } from './i18n'
|
||||||
|
import { planGameDebt } from './lib/wellness'
|
||||||
|
|
||||||
type Mode =
|
type Mode =
|
||||||
| { kind: 'idle' }
|
| { kind: 'idle' }
|
||||||
@@ -193,6 +195,7 @@ export default function ReminderApp(): JSX.Element {
|
|||||||
exercise={mode.exercise}
|
exercise={mode.exercise}
|
||||||
snoozeMinutes={settings?.snoozeMinutes ?? 5}
|
snoozeMinutes={settings?.snoozeMinutes ?? 5}
|
||||||
lang={lang}
|
lang={lang}
|
||||||
|
tone={settings?.notificationTone ?? 'calm'}
|
||||||
onClose={close}
|
onClose={close}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -204,6 +207,7 @@ export default function ReminderApp(): JSX.Element {
|
|||||||
meal={mode.meal}
|
meal={mode.meal}
|
||||||
snoozeMinutes={settings?.snoozeMinutes ?? 5}
|
snoozeMinutes={settings?.snoozeMinutes ?? 5}
|
||||||
lang={lang}
|
lang={lang}
|
||||||
|
tone={settings?.notificationTone ?? 'calm'}
|
||||||
onClose={close}
|
onClose={close}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -213,6 +217,7 @@ export default function ReminderApp(): JSX.Element {
|
|||||||
summary={mode.summary}
|
summary={mode.summary}
|
||||||
done={mode.done}
|
done={mode.done}
|
||||||
lang={lang}
|
lang={lang}
|
||||||
|
tone={settings?.notificationTone ?? 'calm'}
|
||||||
onMarkDone={(id) => {
|
onMarkDone={(id) => {
|
||||||
// Дедупликация: rapid double-click может два раза вызвать
|
// Дедупликация: rapid double-click может два раза вызвать
|
||||||
// onMarkDone до того как `disabled={done}` доедет до DOM.
|
// onMarkDone до того как `disabled={done}` доедет до DOM.
|
||||||
@@ -226,8 +231,7 @@ export default function ReminderApp(): JSX.Element {
|
|||||||
void window.api.markChallengeDone(id, result.reps)
|
void window.api.markChallengeDone(id, result.reps)
|
||||||
}
|
}
|
||||||
// 2) Functional update: rapid-click race-safe.
|
// 2) Functional update: rapid-click race-safe.
|
||||||
setMode((m) =>
|
setMode((m) => {
|
||||||
{
|
|
||||||
if (m.kind !== 'match') return m
|
if (m.kind !== 'match') return m
|
||||||
const nextMode: Mode = {
|
const nextMode: Mode = {
|
||||||
kind: 'match',
|
kind: 'match',
|
||||||
@@ -236,8 +240,7 @@ export default function ReminderApp(): JSX.Element {
|
|||||||
}
|
}
|
||||||
modeRef.current = nextMode
|
modeRef.current = nextMode
|
||||||
return nextMode
|
return nextMode
|
||||||
}
|
})
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
onClose={close}
|
onClose={close}
|
||||||
/>
|
/>
|
||||||
@@ -248,11 +251,13 @@ function ExerciseReminder({
|
|||||||
exercise,
|
exercise,
|
||||||
snoozeMinutes,
|
snoozeMinutes,
|
||||||
lang,
|
lang,
|
||||||
|
tone,
|
||||||
onClose
|
onClose
|
||||||
}: {
|
}: {
|
||||||
exercise: Exercise
|
exercise: Exercise
|
||||||
snoozeMinutes: number
|
snoozeMinutes: number
|
||||||
lang: Language
|
lang: Language
|
||||||
|
tone: NotificationTone
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const t = (key: string, vars?: Record<string, string | number>): string =>
|
const t = (key: string, vars?: Record<string, string | number>): string =>
|
||||||
@@ -338,6 +343,14 @@ function ExerciseReminder({
|
|||||||
<div className="text-[13px] uppercase tracking-[0.18em] text-accent font-bold">
|
<div className="text-[13px] uppercase tracking-[0.18em] text-accent font-bold">
|
||||||
{t(`category.${exercise.category ?? 'exercise'}.cta`)}
|
{t(`category.${exercise.category ?? 'exercise'}.cta`)}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mt-3 text-[13px] text-text/65 font-medium leading-snug max-w-[260px]">
|
||||||
|
{reminderToneLine({
|
||||||
|
tone,
|
||||||
|
lang,
|
||||||
|
kind: 'exercise',
|
||||||
|
name: exercise.name
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
<h1 className="font-serif text-[30px] leading-tight tracking-tight mt-2 mb-3 font-bold">
|
<h1 className="font-serif text-[30px] leading-tight tracking-tight mt-2 mb-3 font-bold">
|
||||||
{exercise.name}
|
{exercise.name}
|
||||||
</h1>
|
</h1>
|
||||||
@@ -420,11 +433,13 @@ function MealReminder({
|
|||||||
meal,
|
meal,
|
||||||
snoozeMinutes,
|
snoozeMinutes,
|
||||||
lang,
|
lang,
|
||||||
|
tone,
|
||||||
onClose
|
onClose
|
||||||
}: {
|
}: {
|
||||||
meal: Meal
|
meal: Meal
|
||||||
snoozeMinutes: number
|
snoozeMinutes: number
|
||||||
lang: Language
|
lang: Language
|
||||||
|
tone: NotificationTone
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const t = (key: string, vars?: Record<string, string | number>): string =>
|
const t = (key: string, vars?: Record<string, string | number>): string =>
|
||||||
@@ -452,7 +467,10 @@ function MealReminder({
|
|||||||
} else if (e.key === 'Escape') {
|
} else if (e.key === 'Escape') {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
onClose()
|
onClose()
|
||||||
} else if ((e.key === ' ' || e.code === 'Space') && targetTag !== 'BUTTON') {
|
} else if (
|
||||||
|
(e.key === ' ' || e.code === 'Space') &&
|
||||||
|
targetTag !== 'BUTTON'
|
||||||
|
) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
void snooze()
|
void snooze()
|
||||||
}
|
}
|
||||||
@@ -489,6 +507,9 @@ function MealReminder({
|
|||||||
<div className="text-[13px] uppercase tracking-[0.18em] text-success font-bold">
|
<div className="text-[13px] uppercase tracking-[0.18em] text-success font-bold">
|
||||||
{t('meal.cta')}
|
{t('meal.cta')}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mt-3 text-[13px] text-text/65 font-medium leading-snug max-w-[260px]">
|
||||||
|
{reminderToneLine({ tone, lang, kind: 'meal', name: meal.name })}
|
||||||
|
</div>
|
||||||
<h1 className="font-serif text-[30px] leading-tight tracking-tight mt-2 mb-3 font-bold">
|
<h1 className="font-serif text-[30px] leading-tight tracking-tight mt-2 mb-3 font-bold">
|
||||||
{meal.name}
|
{meal.name}
|
||||||
</h1>
|
</h1>
|
||||||
@@ -520,12 +541,14 @@ function MatchSummaryView({
|
|||||||
summary,
|
summary,
|
||||||
done,
|
done,
|
||||||
lang,
|
lang,
|
||||||
|
tone,
|
||||||
onMarkDone,
|
onMarkDone,
|
||||||
onClose
|
onClose
|
||||||
}: {
|
}: {
|
||||||
summary: MatchSummary
|
summary: MatchSummary
|
||||||
done: Set<string>
|
done: Set<string>
|
||||||
lang: Language
|
lang: Language
|
||||||
|
tone: NotificationTone
|
||||||
onMarkDone: (id: string) => void
|
onMarkDone: (id: string) => void
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
@@ -539,6 +562,7 @@ function MatchSummaryView({
|
|||||||
|
|
||||||
const allDone = summary.results.every((r) => done.has(r.challengeId))
|
const allDone = summary.results.every((r) => done.has(r.challengeId))
|
||||||
const totalReps = summary.results.reduce((s, r) => s + r.reps, 0)
|
const totalReps = summary.results.reduce((s, r) => s + r.reps, 0)
|
||||||
|
const debtPlan = planGameDebt(totalReps)
|
||||||
const remainingReps = summary.results
|
const remainingReps = summary.results
|
||||||
.filter((r) => !done.has(r.challengeId))
|
.filter((r) => !done.has(r.challengeId))
|
||||||
.reduce((s, r) => s + r.reps, 0)
|
.reduce((s, r) => s + r.reps, 0)
|
||||||
@@ -601,6 +625,17 @@ function MatchSummaryView({
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
{totalReps > 0 && (
|
||||||
|
<div className="mt-3 rounded-2xl bg-surface-2 px-3 py-2 text-[12px] text-text/68 font-medium leading-snug">
|
||||||
|
{matchToneLine({ tone, lang, total: totalReps })}
|
||||||
|
<span className="block mt-1 font-mono-num text-text">
|
||||||
|
{t('match.debt_plan', {
|
||||||
|
now: debtPlan.now,
|
||||||
|
later: debtPlan.later
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-1 overflow-y-auto px-3 space-y-1.5 pb-2">
|
<div className="flex-1 overflow-y-auto px-3 space-y-1.5 pb-2">
|
||||||
@@ -713,6 +748,60 @@ function ChallengeRow({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reminderToneLine({
|
||||||
|
tone,
|
||||||
|
lang,
|
||||||
|
kind,
|
||||||
|
name
|
||||||
|
}: {
|
||||||
|
tone: NotificationTone
|
||||||
|
lang: Language
|
||||||
|
kind: 'exercise' | 'meal'
|
||||||
|
name: string
|
||||||
|
}): string {
|
||||||
|
if (lang === 'en') {
|
||||||
|
if (tone === 'brief') return kind === 'meal' ? 'Eat now.' : 'Do it now.'
|
||||||
|
if (tone === 'firm') return `No delay: ${name}.`
|
||||||
|
if (tone === 'playful')
|
||||||
|
return kind === 'meal' ? 'Fuel break.' : 'Tiny win time.'
|
||||||
|
return kind === 'meal'
|
||||||
|
? 'A calm food break fits here.'
|
||||||
|
: 'A short reset fits here.'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tone === 'brief')
|
||||||
|
return kind === 'meal' ? 'Поесть сейчас.' : 'Сделай сейчас.'
|
||||||
|
if (tone === 'firm') return `Не откладываем: ${name}.`
|
||||||
|
if (tone === 'playful')
|
||||||
|
return kind === 'meal' ? 'Дозаправка.' : 'Маленькая победа.'
|
||||||
|
return kind === 'meal'
|
||||||
|
? 'Спокойный перерыв на еду здесь к месту.'
|
||||||
|
: 'Короткая перезагрузка здесь к месту.'
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchToneLine({
|
||||||
|
tone,
|
||||||
|
lang,
|
||||||
|
total
|
||||||
|
}: {
|
||||||
|
tone: NotificationTone
|
||||||
|
lang: Language
|
||||||
|
total: number
|
||||||
|
}): string {
|
||||||
|
if (lang === 'en') {
|
||||||
|
if (tone === 'brief') return `${total} reps. Split it.`
|
||||||
|
if (tone === 'firm')
|
||||||
|
return `Close the match debt in small sets: ${total} reps.`
|
||||||
|
if (tone === 'playful') return `The match left a receipt: ${total} reps.`
|
||||||
|
return `No need to do everything at once. Split ${total} reps into sets.`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tone === 'brief') return `${total} повторов. Разбиваем.`
|
||||||
|
if (tone === 'firm') return `Закрываем долг подходами: ${total} повторов.`
|
||||||
|
if (tone === 'playful') return `Катка оставила чек: ${total} повторов.`
|
||||||
|
return `Не нужно делать всё одним куском. Разбей ${total} повторов на подходы.`
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CLDR-минимум для русского склонения «раз». 1 раз / 2 раза / 5 раз.
|
* CLDR-минимум для русского склонения «раз». 1 раз / 2 раза / 5 раз.
|
||||||
* Не тащим сюда полную плюрализацию из i18n — это TTS-only фраза.
|
* Не тащим сюда полную плюрализацию из i18n — это TTS-only фраза.
|
||||||
|
|||||||
@@ -40,9 +40,10 @@ export function InsightGrid({
|
|||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={['grid grid-cols-1 sm:grid-cols-3 gap-3 mb-8', className].join(
|
className={[
|
||||||
' '
|
'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 mb-8',
|
||||||
)}
|
className
|
||||||
|
].join(' ')}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
@@ -85,10 +86,10 @@ export function InsightCard({
|
|||||||
{icon}
|
{icon}
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className="text-[12px] uppercase tracking-[0.06em] text-text/50 font-bold truncate">
|
<div className="text-[12px] uppercase tracking-[0.06em] text-text/50 font-bold leading-tight">
|
||||||
{label}
|
{label}
|
||||||
</div>
|
</div>
|
||||||
<div className="font-display text-[22px] font-bold leading-none mt-1 truncate">
|
<div className="font-display text-[22px] font-bold leading-tight mt-1 break-words">
|
||||||
{value}
|
{value}
|
||||||
</div>
|
</div>
|
||||||
{hint && (
|
{hint && (
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
X
|
X
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useT } from '../i18n'
|
import { useT } from '../i18n'
|
||||||
|
import { useAppStore } from '../store/appStore'
|
||||||
|
|
||||||
type Item = {
|
type Item = {
|
||||||
to: string
|
to: string
|
||||||
@@ -50,28 +51,28 @@ const items: Item[] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
mobileOpen?: boolean
|
compactOpen?: boolean
|
||||||
onMobileClose?: () => void
|
onCompactClose?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Sidebar({
|
export function Sidebar({
|
||||||
mobileOpen = false,
|
compactOpen = false,
|
||||||
onMobileClose
|
onCompactClose
|
||||||
}: Props): JSX.Element {
|
}: Props): JSX.Element {
|
||||||
const { t } = useT()
|
const { t } = useT()
|
||||||
const drawerRef = useRef<HTMLElement | null>(null)
|
const drawerRef = useRef<HTMLElement | null>(null)
|
||||||
const lastFocusedRef = useRef<HTMLElement | null>(null)
|
const lastFocusedRef = useRef<HTMLElement | null>(null)
|
||||||
|
|
||||||
// Esc closes + focus trap while the mobile drawer is open. Mirrors the
|
// Esc closes + focus trap while the compact drawer is open. Mirrors the
|
||||||
// pattern used in Modal.tsx.
|
// pattern used in Modal.tsx for keyboard users.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mobileOpen) return undefined
|
if (!compactOpen) return undefined
|
||||||
lastFocusedRef.current = document.activeElement as HTMLElement | null
|
lastFocusedRef.current = document.activeElement as HTMLElement | null
|
||||||
|
|
||||||
const onKeyDown = (e: KeyboardEvent): void => {
|
const onKeyDown = (e: KeyboardEvent): void => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
onMobileClose?.()
|
onCompactClose?.()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (e.key !== 'Tab') return
|
if (e.key !== 'Tab') return
|
||||||
@@ -104,7 +105,7 @@ export function Sidebar({
|
|||||||
const target = lastFocusedRef.current
|
const target = lastFocusedRef.current
|
||||||
if (target && document.body.contains(target)) target.focus()
|
if (target && document.body.contains(target)) target.focus()
|
||||||
}
|
}
|
||||||
}, [mobileOpen, onMobileClose])
|
}, [compactOpen, onCompactClose])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -113,7 +114,7 @@ export function Sidebar({
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{mobileOpen && (
|
{compactOpen && (
|
||||||
<motion.div
|
<motion.div
|
||||||
className="md:hidden fixed inset-0 z-50 flex"
|
className="md:hidden fixed inset-0 z-50 flex"
|
||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
@@ -123,7 +124,7 @@ export function Sidebar({
|
|||||||
>
|
>
|
||||||
<motion.div
|
<motion.div
|
||||||
className="absolute inset-0 bg-black/30 backdrop-blur-md"
|
className="absolute inset-0 bg-black/30 backdrop-blur-md"
|
||||||
onClick={onMobileClose}
|
onClick={onCompactClose}
|
||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
exit={{ opacity: 0 }}
|
exit={{ opacity: 0 }}
|
||||||
@@ -141,13 +142,13 @@ export function Sidebar({
|
|||||||
transition={{ type: 'spring', stiffness: 420, damping: 38 }}
|
transition={{ type: 'spring', stiffness: 420, damping: 38 }}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
onClick={onMobileClose}
|
onClick={onCompactClose}
|
||||||
className="absolute top-3 right-3 w-8 h-8 grid place-items-center rounded-full bg-surface-2 hover:bg-hairline/25 text-text/60 transition-colors active:scale-90"
|
className="absolute top-3 right-3 w-8 h-8 grid place-items-center rounded-full bg-surface-2 hover:bg-hairline/25 text-text/60 transition-colors active:scale-90"
|
||||||
aria-label={t('btn.close')}
|
aria-label={t('btn.close')}
|
||||||
>
|
>
|
||||||
<X size={14} strokeWidth={2.5} />
|
<X size={14} strokeWidth={2.5} />
|
||||||
</button>
|
</button>
|
||||||
<SidebarContent onNav={onMobileClose} />
|
<SidebarContent onNav={onCompactClose} />
|
||||||
</motion.aside>
|
</motion.aside>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
@@ -158,6 +159,7 @@ export function Sidebar({
|
|||||||
|
|
||||||
function SidebarContent({ onNav }: { onNav?: () => void }): JSX.Element {
|
function SidebarContent({ onNav }: { onNav?: () => void }): JSX.Element {
|
||||||
const { t } = useT()
|
const { t } = useT()
|
||||||
|
const running = useAppStore((s) => s.state?.settings.globalEnabled ?? true)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="px-5 pt-7 pb-6">
|
<div className="px-5 pt-7 pb-6">
|
||||||
@@ -214,10 +216,17 @@ function SidebarContent({ onNav }: { onNav?: () => void }): JSX.Element {
|
|||||||
<div className="mt-auto px-5 pb-5">
|
<div className="mt-auto px-5 pb-5">
|
||||||
<div className="flex items-center gap-2 text-[11px] text-text/45">
|
<div className="flex items-center gap-2 text-[11px] text-text/45">
|
||||||
<span className="relative flex h-1.5 w-1.5">
|
<span className="relative flex h-1.5 w-1.5">
|
||||||
|
{running && (
|
||||||
<span className="absolute inline-flex h-full w-full rounded-full bg-success opacity-60 animate-ping" />
|
<span className="absolute inline-flex h-full w-full rounded-full bg-success opacity-60 animate-ping" />
|
||||||
<span className="relative inline-flex rounded-full h-1.5 w-1.5 bg-success" />
|
)}
|
||||||
|
<span
|
||||||
|
className={[
|
||||||
|
'relative inline-flex rounded-full h-1.5 w-1.5',
|
||||||
|
running ? 'bg-success' : 'bg-warning'
|
||||||
|
].join(' ')}
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
{t('sidebar.status_tracking')}
|
{running ? t('sidebar.status_tracking') : t('sidebar.status_paused')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export const ru: Dict = {
|
|||||||
'nav.settings': 'Настройки',
|
'nav.settings': 'Настройки',
|
||||||
'sidebar.slogan': 'Лёгкий перерыв без потери фокуса',
|
'sidebar.slogan': 'Лёгкий перерыв без потери фокуса',
|
||||||
'sidebar.status_tracking': 'Активность отслеживается',
|
'sidebar.status_tracking': 'Активность отслеживается',
|
||||||
|
'sidebar.status_paused': 'Напоминания на паузе',
|
||||||
'titlebar.menu_aria': 'Меню',
|
'titlebar.menu_aria': 'Меню',
|
||||||
'titlebar.minimize_aria': 'Свернуть',
|
'titlebar.minimize_aria': 'Свернуть',
|
||||||
'titlebar.maximize_aria': 'Развернуть',
|
'titlebar.maximize_aria': 'Развернуть',
|
||||||
@@ -98,7 +99,7 @@ export const ru: Dict = {
|
|||||||
'dashboard.stat.tracking': 'Трекинг матчей',
|
'dashboard.stat.tracking': 'Трекинг матчей',
|
||||||
'dashboard.stat.tracking.on': 'On',
|
'dashboard.stat.tracking.on': 'On',
|
||||||
'dashboard.stat.tracking.off': 'Off',
|
'dashboard.stat.tracking.off': 'Off',
|
||||||
'dashboard.stat.tracking.pending': 'Setup',
|
'dashboard.stat.tracking.pending': 'Настройка',
|
||||||
'dashboard.stat.tracking.subtitle_on': 'в реальном времени',
|
'dashboard.stat.tracking.subtitle_on': 'в реальном времени',
|
||||||
'dashboard.stat.tracking.subtitle_off': 'выключен',
|
'dashboard.stat.tracking.subtitle_off': 'выключен',
|
||||||
'dashboard.stat.tracking.subtitle_pending':
|
'dashboard.stat.tracking.subtitle_pending':
|
||||||
@@ -110,7 +111,7 @@ export const ru: Dict = {
|
|||||||
'Запущен Zoom / Teams / Webex / Slack-huddle. Напоминания возобновятся, когда встреча закончится.',
|
'Запущен Zoom / Teams / Webex / Slack-huddle. Напоминания возобновятся, когда встреча закончится.',
|
||||||
'dashboard.plan.title': 'Ближайший шаг',
|
'dashboard.plan.title': 'Ближайший шаг',
|
||||||
'dashboard.plan.subtitle': 'Что сделать сейчас, дневные цели и питание',
|
'dashboard.plan.subtitle': 'Что сделать сейчас, дневные цели и питание',
|
||||||
'dashboard.plan.due_count': '{n} ждёт',
|
'dashboard.plan.due_count': '{n} к выполнению',
|
||||||
'dashboard.plan.all_caught_up': 'всё спокойно',
|
'dashboard.plan.all_caught_up': 'всё спокойно',
|
||||||
'dashboard.plan.next_action': 'Следующее действие',
|
'dashboard.plan.next_action': 'Следующее действие',
|
||||||
'dashboard.plan.kind.exercise': 'упражнение',
|
'dashboard.plan.kind.exercise': 'упражнение',
|
||||||
@@ -125,7 +126,7 @@ export const ru: Dict = {
|
|||||||
'dashboard.plan.clear.hint': 'Можно отдохнуть или добавить новое действие',
|
'dashboard.plan.clear.hint': 'Можно отдохнуть или добавить новое действие',
|
||||||
'dashboard.plan.goals': 'Дневные цели',
|
'dashboard.plan.goals': 'Дневные цели',
|
||||||
'dashboard.plan.goals.progress': '{done}/{goal}',
|
'dashboard.plan.goals.progress': '{done}/{goal}',
|
||||||
'dashboard.plan.goals.remaining': 'осталось {n}',
|
'dashboard.plan.goals.remaining': 'осталось {n} раз',
|
||||||
'dashboard.plan.goals.hint': 'прогресс по упражнениям с дневной целью',
|
'dashboard.plan.goals.hint': 'прогресс по упражнениям с дневной целью',
|
||||||
'dashboard.plan.goals.empty':
|
'dashboard.plan.goals.empty':
|
||||||
'Добавь дневную цель в упражнении, чтобы видеть прогресс',
|
'Добавь дневную цель в упражнении, чтобы видеть прогресс',
|
||||||
@@ -143,10 +144,52 @@ export const ru: Dict = {
|
|||||||
'dashboard.plan.recovery.steady.none': 'держим спокойный темп',
|
'dashboard.plan.recovery.steady.none': 'держим спокойный темп',
|
||||||
'dashboard.plan.up_next': 'Дальше',
|
'dashboard.plan.up_next': 'Дальше',
|
||||||
'dashboard.plan.item.remaining': 'осталось {n}',
|
'dashboard.plan.item.remaining': 'осталось {n}',
|
||||||
|
'dashboard.plan.item.remaining_reps': 'осталось {n} раз',
|
||||||
'dashboard.plan.item.reps': '{n} раз',
|
'dashboard.plan.item.reps': '{n} раз',
|
||||||
'dashboard.empty.title': 'Программа пуста',
|
'dashboard.empty.title': 'Программа пуста',
|
||||||
'dashboard.empty.hint': 'Добавь первое упражнение, чтобы начать',
|
'dashboard.empty.hint': 'Добавь первое упражнение, чтобы начать',
|
||||||
|
|
||||||
|
// Smart work / sessions / analytics
|
||||||
|
'smart.kicker': 'Помощник дня',
|
||||||
|
'smart.title': 'Что улучшить сейчас',
|
||||||
|
'insight.default.title': 'День идёт ровно',
|
||||||
|
'insight.default.desc':
|
||||||
|
'Срочных корректировок нет. Держи короткие перерывы и не копи всё на вечер.',
|
||||||
|
'insight.first_run.title': 'Начни с пресета',
|
||||||
|
'insight.first_run.desc':
|
||||||
|
'Выбери готовую программу на странице упражнений — так быстрее, чем собирать всё вручную.',
|
||||||
|
'insight.too_many_skips.title': 'Много пропусков',
|
||||||
|
'insight.too_many_skips.desc':
|
||||||
|
'{n} пропусков за неделю. Снизь нагрузку или запускай короткую сессию вместо полного плана.',
|
||||||
|
'insight.late_slump.title': 'Вечером сложнее',
|
||||||
|
'insight.late_slump.desc':
|
||||||
|
'{n} вечерних пропусков. Лучше закрыть базу до 18:00 или разбить долг на подходы.',
|
||||||
|
'insight.empty_meals.title': 'Питание не настроено',
|
||||||
|
'insight.empty_meals.desc':
|
||||||
|
'Добавь завтрак, обед или перекус, чтобы день был стабильнее.',
|
||||||
|
'insight.good_rhythm.title': 'Ритм хороший',
|
||||||
|
'insight.good_rhythm.desc':
|
||||||
|
'Закрываемость {pct}%. Можно слегка поднять цель или оставить темп как есть.',
|
||||||
|
'session.kicker': 'Разминка-сессия',
|
||||||
|
'session.title': 'Запустить коротко',
|
||||||
|
'session.3.title': 'Быстрый сброс',
|
||||||
|
'session.5.title': 'Нормальная пауза',
|
||||||
|
'session.10.title': 'Полная разминка',
|
||||||
|
'session.empty': 'Добавь упражнения или пресет, чтобы запускать сессии.',
|
||||||
|
'analytics.kicker': 'Аналитика',
|
||||||
|
'analytics.title': 'Неделя в цифрах',
|
||||||
|
'analytics.active_days': 'Дни',
|
||||||
|
'analytics.active_days.hint': 'с активностью',
|
||||||
|
'analytics.done_reps': 'Повторы',
|
||||||
|
'analytics.done_reps.hint': 'сделано',
|
||||||
|
'analytics.completion': 'Закрытие',
|
||||||
|
'analytics.completion.hint': 'done / skip',
|
||||||
|
'analytics.skips': 'Пропуски',
|
||||||
|
'analytics.skips.hint': 'за неделю',
|
||||||
|
'analytics.best_day': 'Лучший день',
|
||||||
|
'analytics.best_day.hint': '{day}',
|
||||||
|
'analytics.best_day.empty': 'пока нет',
|
||||||
|
|
||||||
// Momentum / today redesign
|
// Momentum / today redesign
|
||||||
'momentum.level.title': 'Уровень',
|
'momentum.level.title': 'Уровень',
|
||||||
'momentum.level.number': 'уровень {n}',
|
'momentum.level.number': 'уровень {n}',
|
||||||
@@ -201,6 +244,17 @@ export const ru: Dict = {
|
|||||||
'exercises.section.disabled': 'Выключенные · {n}',
|
'exercises.section.disabled': 'Выключенные · {n}',
|
||||||
'exercises.row.meta': '{reps} раз · {interval}',
|
'exercises.row.meta': '{reps} раз · {interval}',
|
||||||
'exercises.empty': 'Программа пуста — добавь первое упражнение',
|
'exercises.empty': 'Программа пуста — добавь первое упражнение',
|
||||||
|
'exercises.presets.title': 'Пресеты',
|
||||||
|
'exercises.presets.add': 'Добавить',
|
||||||
|
'preset.office.title': 'Офисная разминка',
|
||||||
|
'preset.office.desc': 'Шея, глаза и приседания для обычного рабочего дня.',
|
||||||
|
'preset.back.title': 'Спина и шея',
|
||||||
|
'preset.back.desc':
|
||||||
|
'Осанка, лопатки и лёгкие наклоны без спортивного режима.',
|
||||||
|
'preset.minimum.title': 'Минимум на день',
|
||||||
|
'preset.minimum.desc': 'Самый мягкий старт: вода и короткая мини-разминка.',
|
||||||
|
'preset.after_match.title': 'После катки',
|
||||||
|
'preset.after_match.desc': 'База под игровые долги: приседания и отжимания.',
|
||||||
|
|
||||||
// Meals (приёмы пищи)
|
// Meals (приёмы пищи)
|
||||||
'meals.kicker': 'Режим питания',
|
'meals.kicker': 'Режим питания',
|
||||||
@@ -314,11 +368,29 @@ export const ru: Dict = {
|
|||||||
'settings.insight.theme.hint': 'Визуальный режим интерфейса',
|
'settings.insight.theme.hint': 'Визуальный режим интерфейса',
|
||||||
'settings.insight.language': 'Язык',
|
'settings.insight.language': 'Язык',
|
||||||
'settings.insight.language.hint': 'Применяется без перезапуска',
|
'settings.insight.language.hint': 'Применяется без перезапуска',
|
||||||
|
'settings.status.kicker': 'Состояние',
|
||||||
|
'settings.status.title.on': 'Напоминания работают',
|
||||||
|
'settings.status.title.off': 'Напоминания остановлены',
|
||||||
|
'settings.status.hint.paused':
|
||||||
|
'Перерывы не будут появляться, пока ты снова не запустишь напоминания.',
|
||||||
|
'settings.status.hint.quiet':
|
||||||
|
'Напоминания работают, но тихие часы {from}-{to} могут временно их скрывать.',
|
||||||
|
'settings.status.hint.autostart':
|
||||||
|
'После перезагрузки приложение не запустится само.',
|
||||||
|
'settings.status.hint.ready':
|
||||||
|
'Приложение запустится с Windows и будет мягко вести расписание перерывов.',
|
||||||
|
'settings.status.reminders': 'Напоминания',
|
||||||
|
'settings.status.quiet': 'Тихие часы',
|
||||||
|
'settings.status.meetings': 'Встречи',
|
||||||
|
'settings.status.autostart': 'Windows',
|
||||||
|
'settings.status.on': 'Вкл',
|
||||||
|
'settings.status.off': 'Выкл',
|
||||||
'settings.section.reminders': 'Напоминания',
|
'settings.section.reminders': 'Напоминания',
|
||||||
'settings.section.quiet': 'Тихие часы',
|
'settings.section.quiet': 'Тихие часы',
|
||||||
'settings.section.window': 'Окно и трей',
|
'settings.section.window': 'Окно и трей',
|
||||||
'settings.section.appearance': 'Внешний вид',
|
'settings.section.appearance': 'Внешний вид',
|
||||||
'settings.section.language': 'Язык',
|
'settings.section.language': 'Язык',
|
||||||
|
'settings.section.interface': 'Интерфейс',
|
||||||
'settings.section.updates': 'Обновления',
|
'settings.section.updates': 'Обновления',
|
||||||
'settings.section.data': 'Данные',
|
'settings.section.data': 'Данные',
|
||||||
'settings.section.diagnostics': 'Диагностика',
|
'settings.section.diagnostics': 'Диагностика',
|
||||||
@@ -364,6 +436,15 @@ export const ru: Dict = {
|
|||||||
'settings.notification_mode.modal': 'Окно поверх всех',
|
'settings.notification_mode.modal': 'Окно поверх всех',
|
||||||
'settings.notification_mode.toast': 'Системное уведомление',
|
'settings.notification_mode.toast': 'Системное уведомление',
|
||||||
'settings.notification_mode.both': 'Окно и уведомление',
|
'settings.notification_mode.both': 'Окно и уведомление',
|
||||||
|
'settings.notification_tone.label': 'Тон напоминаний',
|
||||||
|
'settings.notification_tone.hint':
|
||||||
|
'Как формулировать подсказки в окне напоминания',
|
||||||
|
'settings.notification_tone.calm': 'Спокойно',
|
||||||
|
'settings.notification_tone.brief': 'Кратко',
|
||||||
|
'settings.notification_tone.firm': 'Настойчиво',
|
||||||
|
'settings.notification_tone.playful': 'С юмором',
|
||||||
|
'settings.global.label': 'Напоминания включены',
|
||||||
|
'settings.global.hint': 'Главный режим работы приложения',
|
||||||
'settings.sound.label': 'Звук уведомления',
|
'settings.sound.label': 'Звук уведомления',
|
||||||
'settings.sound.hint': 'Короткий сигнал при срабатывании',
|
'settings.sound.hint': 'Короткий сигнал при срабатывании',
|
||||||
'settings.voice.label': 'Голосовая подсказка',
|
'settings.voice.label': 'Голосовая подсказка',
|
||||||
@@ -510,6 +591,7 @@ export const ru: Dict = {
|
|||||||
'match.summary.remaining': '{n} осталось',
|
'match.summary.remaining': '{n} осталось',
|
||||||
'match.total': 'Всего',
|
'match.total': 'Всего',
|
||||||
'match.total_reps_suffix': 'повторов',
|
'match.total_reps_suffix': 'повторов',
|
||||||
|
'match.debt_plan': 'Сейчас {now}, позже {later}',
|
||||||
|
|
||||||
// Format helpers
|
// Format helpers
|
||||||
'fmt.now': 'сейчас',
|
'fmt.now': 'сейчас',
|
||||||
@@ -532,6 +614,7 @@ export const en: Dict = {
|
|||||||
'nav.settings': 'Settings',
|
'nav.settings': 'Settings',
|
||||||
'sidebar.slogan': 'A small break without losing focus',
|
'sidebar.slogan': 'A small break without losing focus',
|
||||||
'sidebar.status_tracking': 'Activity tracking is on',
|
'sidebar.status_tracking': 'Activity tracking is on',
|
||||||
|
'sidebar.status_paused': 'Reminders paused',
|
||||||
'titlebar.menu_aria': 'Menu',
|
'titlebar.menu_aria': 'Menu',
|
||||||
'titlebar.minimize_aria': 'Minimize',
|
'titlebar.minimize_aria': 'Minimize',
|
||||||
'titlebar.maximize_aria': 'Maximize',
|
'titlebar.maximize_aria': 'Maximize',
|
||||||
@@ -654,10 +737,52 @@ export const en: Dict = {
|
|||||||
'dashboard.plan.recovery.steady.none': 'keep a calm pace',
|
'dashboard.plan.recovery.steady.none': 'keep a calm pace',
|
||||||
'dashboard.plan.up_next': 'Up next',
|
'dashboard.plan.up_next': 'Up next',
|
||||||
'dashboard.plan.item.remaining': '{n} left',
|
'dashboard.plan.item.remaining': '{n} left',
|
||||||
|
'dashboard.plan.item.remaining_reps': '{n} reps left',
|
||||||
'dashboard.plan.item.reps': '{n} reps',
|
'dashboard.plan.item.reps': '{n} reps',
|
||||||
'dashboard.empty.title': 'Program is empty',
|
'dashboard.empty.title': 'Program is empty',
|
||||||
'dashboard.empty.hint': 'Add your first exercise to start',
|
'dashboard.empty.hint': 'Add your first exercise to start',
|
||||||
|
|
||||||
|
// Smart work / sessions / analytics
|
||||||
|
'smart.kicker': 'Day assistant',
|
||||||
|
'smart.title': 'What to improve now',
|
||||||
|
'insight.default.title': 'The day is steady',
|
||||||
|
'insight.default.desc':
|
||||||
|
'No urgent adjustments. Keep breaks short and avoid leaving everything for the evening.',
|
||||||
|
'insight.first_run.title': 'Start with a preset',
|
||||||
|
'insight.first_run.desc':
|
||||||
|
'Pick a ready-made program on the Exercises page; it is faster than building one manually.',
|
||||||
|
'insight.too_many_skips.title': 'Many skips',
|
||||||
|
'insight.too_many_skips.desc':
|
||||||
|
'{n} skips this week. Lower the load or run a short session instead of the full plan.',
|
||||||
|
'insight.late_slump.title': 'Evenings are harder',
|
||||||
|
'insight.late_slump.desc':
|
||||||
|
'{n} evening skips. Close the basics before 18:00 or split debt into sets.',
|
||||||
|
'insight.empty_meals.title': 'Meals are not configured',
|
||||||
|
'insight.empty_meals.desc':
|
||||||
|
'Add breakfast, lunch or a snack to keep the day steadier.',
|
||||||
|
'insight.good_rhythm.title': 'Good rhythm',
|
||||||
|
'insight.good_rhythm.desc':
|
||||||
|
'{pct}% completion. You can slightly raise a target or keep the pace.',
|
||||||
|
'session.kicker': 'Warm-up session',
|
||||||
|
'session.title': 'Run a short one',
|
||||||
|
'session.3.title': 'Quick reset',
|
||||||
|
'session.5.title': 'Normal pause',
|
||||||
|
'session.10.title': 'Full warm-up',
|
||||||
|
'session.empty': 'Add exercises or a preset to run sessions.',
|
||||||
|
'analytics.kicker': 'Analytics',
|
||||||
|
'analytics.title': 'Week in numbers',
|
||||||
|
'analytics.active_days': 'Days',
|
||||||
|
'analytics.active_days.hint': 'with activity',
|
||||||
|
'analytics.done_reps': 'Reps',
|
||||||
|
'analytics.done_reps.hint': 'done',
|
||||||
|
'analytics.completion': 'Completion',
|
||||||
|
'analytics.completion.hint': 'done / skip',
|
||||||
|
'analytics.skips': 'Skips',
|
||||||
|
'analytics.skips.hint': 'this week',
|
||||||
|
'analytics.best_day': 'Best day',
|
||||||
|
'analytics.best_day.hint': '{day}',
|
||||||
|
'analytics.best_day.empty': 'none yet',
|
||||||
|
|
||||||
// Momentum / today redesign
|
// Momentum / today redesign
|
||||||
'momentum.level.title': 'Level',
|
'momentum.level.title': 'Level',
|
||||||
'momentum.level.number': 'level {n}',
|
'momentum.level.number': 'level {n}',
|
||||||
@@ -712,6 +837,17 @@ export const en: Dict = {
|
|||||||
'exercises.section.disabled': 'Disabled · {n}',
|
'exercises.section.disabled': 'Disabled · {n}',
|
||||||
'exercises.row.meta': '{reps} reps · {interval}',
|
'exercises.row.meta': '{reps} reps · {interval}',
|
||||||
'exercises.empty': 'Program is empty — add your first exercise',
|
'exercises.empty': 'Program is empty — add your first exercise',
|
||||||
|
'exercises.presets.title': 'Presets',
|
||||||
|
'exercises.presets.add': 'Add',
|
||||||
|
'preset.office.title': 'Office warm-up',
|
||||||
|
'preset.office.desc': 'Neck, eyes and squats for a normal workday.',
|
||||||
|
'preset.back.title': 'Back and neck',
|
||||||
|
'preset.back.desc':
|
||||||
|
'Posture, shoulder blades and easy bends without gym mode.',
|
||||||
|
'preset.minimum.title': 'Daily minimum',
|
||||||
|
'preset.minimum.desc': 'The softest start: water and one mini warm-up.',
|
||||||
|
'preset.after_match.title': 'After match',
|
||||||
|
'preset.after_match.desc': 'A base for game debt: squats and push-ups.',
|
||||||
|
|
||||||
// Meals
|
// Meals
|
||||||
'meals.kicker': 'Eating schedule',
|
'meals.kicker': 'Eating schedule',
|
||||||
@@ -825,11 +961,29 @@ export const en: Dict = {
|
|||||||
'settings.insight.theme.hint': 'Visual interface mode',
|
'settings.insight.theme.hint': 'Visual interface mode',
|
||||||
'settings.insight.language': 'Language',
|
'settings.insight.language': 'Language',
|
||||||
'settings.insight.language.hint': 'Applied without restart',
|
'settings.insight.language.hint': 'Applied without restart',
|
||||||
|
'settings.status.kicker': 'Status',
|
||||||
|
'settings.status.title.on': 'Reminders are running',
|
||||||
|
'settings.status.title.off': 'Reminders are paused',
|
||||||
|
'settings.status.hint.paused':
|
||||||
|
'Breaks will not appear until reminders are started again.',
|
||||||
|
'settings.status.hint.quiet':
|
||||||
|
'Reminders are running, but quiet hours {from}-{to} can hide them temporarily.',
|
||||||
|
'settings.status.hint.autostart':
|
||||||
|
'The app will not start automatically after reboot.',
|
||||||
|
'settings.status.hint.ready':
|
||||||
|
'The app will start with Windows and keep the break schedule moving.',
|
||||||
|
'settings.status.reminders': 'Reminders',
|
||||||
|
'settings.status.quiet': 'Quiet hours',
|
||||||
|
'settings.status.meetings': 'Meetings',
|
||||||
|
'settings.status.autostart': 'Windows',
|
||||||
|
'settings.status.on': 'On',
|
||||||
|
'settings.status.off': 'Off',
|
||||||
'settings.section.reminders': 'Reminders',
|
'settings.section.reminders': 'Reminders',
|
||||||
'settings.section.quiet': 'Quiet hours',
|
'settings.section.quiet': 'Quiet hours',
|
||||||
'settings.section.window': 'Window & tray',
|
'settings.section.window': 'Window & tray',
|
||||||
'settings.section.appearance': 'Appearance',
|
'settings.section.appearance': 'Appearance',
|
||||||
'settings.section.language': 'Language',
|
'settings.section.language': 'Language',
|
||||||
|
'settings.section.interface': 'Interface',
|
||||||
'settings.section.updates': 'Updates',
|
'settings.section.updates': 'Updates',
|
||||||
'settings.section.data': 'Data',
|
'settings.section.data': 'Data',
|
||||||
'settings.section.diagnostics': 'Diagnostics',
|
'settings.section.diagnostics': 'Diagnostics',
|
||||||
@@ -875,6 +1029,14 @@ export const en: Dict = {
|
|||||||
'settings.notification_mode.modal': 'Window on top',
|
'settings.notification_mode.modal': 'Window on top',
|
||||||
'settings.notification_mode.toast': 'System notification',
|
'settings.notification_mode.toast': 'System notification',
|
||||||
'settings.notification_mode.both': 'Window and notification',
|
'settings.notification_mode.both': 'Window and notification',
|
||||||
|
'settings.notification_tone.label': 'Reminder tone',
|
||||||
|
'settings.notification_tone.hint': 'How reminder-window hints are phrased',
|
||||||
|
'settings.notification_tone.calm': 'Calm',
|
||||||
|
'settings.notification_tone.brief': 'Brief',
|
||||||
|
'settings.notification_tone.firm': 'Firm',
|
||||||
|
'settings.notification_tone.playful': 'Playful',
|
||||||
|
'settings.global.label': 'Reminders enabled',
|
||||||
|
'settings.global.hint': 'Main operating mode for the app',
|
||||||
'settings.sound.label': 'Notification sound',
|
'settings.sound.label': 'Notification sound',
|
||||||
'settings.sound.hint': 'Short beep on trigger',
|
'settings.sound.hint': 'Short beep on trigger',
|
||||||
'settings.voice.label': 'Voice prompt',
|
'settings.voice.label': 'Voice prompt',
|
||||||
@@ -1017,6 +1179,7 @@ export const en: Dict = {
|
|||||||
'match.summary.remaining': '{n} left',
|
'match.summary.remaining': '{n} left',
|
||||||
'match.total': 'Total',
|
'match.total': 'Total',
|
||||||
'match.total_reps_suffix': 'reps',
|
'match.total_reps_suffix': 'reps',
|
||||||
|
'match.debt_plan': 'Now {now}, later {later}',
|
||||||
|
|
||||||
// Format helpers
|
// Format helpers
|
||||||
'fmt.now': 'now',
|
'fmt.now': 'now',
|
||||||
|
|||||||
597
src/renderer/src/lib/dev-api.ts
Normal file
597
src/renderer/src/lib/dev-api.ts
Normal file
@@ -0,0 +1,597 @@
|
|||||||
|
import {
|
||||||
|
DEFAULT_SETTINGS,
|
||||||
|
nextMealOccurrence,
|
||||||
|
type AppState,
|
||||||
|
type Challenge,
|
||||||
|
type DiagnosticsInfo,
|
||||||
|
type Exercise,
|
||||||
|
type GameId,
|
||||||
|
type GameStatus,
|
||||||
|
type HistoryEntry,
|
||||||
|
type Meal,
|
||||||
|
type RendererErrorReport,
|
||||||
|
type Settings,
|
||||||
|
type Tick,
|
||||||
|
type UpdaterStatus
|
||||||
|
} from '@shared/types'
|
||||||
|
|
||||||
|
type Api = Window['api']
|
||||||
|
type Handler<T> = (payload: T) => void
|
||||||
|
|
||||||
|
const now = Date.now()
|
||||||
|
|
||||||
|
let state: AppState = {
|
||||||
|
exercises: [
|
||||||
|
{
|
||||||
|
id: 'dev-ex-squats',
|
||||||
|
name: 'Приседания',
|
||||||
|
reps: 10,
|
||||||
|
icon: 'Activity',
|
||||||
|
intervalMinutes: 30,
|
||||||
|
enabled: true,
|
||||||
|
nextFireAt: now - 90_000,
|
||||||
|
lastDoneAt: now - 2 * 60 * 60 * 1000,
|
||||||
|
category: 'exercise',
|
||||||
|
dailyGoal: 40,
|
||||||
|
adaptive: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dev-ex-eyes',
|
||||||
|
name: 'Отдых глазам 20-20-20',
|
||||||
|
reps: 1,
|
||||||
|
icon: 'Eye',
|
||||||
|
intervalMinutes: 20,
|
||||||
|
enabled: true,
|
||||||
|
nextFireAt: now + 9 * 60_000,
|
||||||
|
category: 'eyes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dev-ex-water',
|
||||||
|
name: 'Стакан воды',
|
||||||
|
reps: 1,
|
||||||
|
icon: 'GlassWater',
|
||||||
|
intervalMinutes: 60,
|
||||||
|
enabled: true,
|
||||||
|
nextFireAt: now + 26 * 60_000,
|
||||||
|
category: 'hydration',
|
||||||
|
dailyGoal: 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dev-ex-posture',
|
||||||
|
name: 'Проверь осанку',
|
||||||
|
reps: 1,
|
||||||
|
icon: 'PersonStanding',
|
||||||
|
intervalMinutes: 25,
|
||||||
|
enabled: false,
|
||||||
|
nextFireAt: now + 25 * 60_000,
|
||||||
|
category: 'posture'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meals: [
|
||||||
|
{
|
||||||
|
id: 'dev-meal-breakfast',
|
||||||
|
name: 'Завтрак',
|
||||||
|
time: '08:00',
|
||||||
|
icon: 'Coffee',
|
||||||
|
enabled: true,
|
||||||
|
days: [],
|
||||||
|
nextFireAt: nextMealOccurrence('08:00', [], now),
|
||||||
|
lastDoneAt: now - 5 * 60 * 60 * 1000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dev-meal-lunch',
|
||||||
|
name: 'Обед',
|
||||||
|
time: '13:00',
|
||||||
|
icon: 'UtensilsCrossed',
|
||||||
|
enabled: true,
|
||||||
|
days: [],
|
||||||
|
nextFireAt: nextMealOccurrence('13:00', [], now)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dev-meal-dinner',
|
||||||
|
name: 'Ужин',
|
||||||
|
time: '19:00',
|
||||||
|
icon: 'Soup',
|
||||||
|
enabled: false,
|
||||||
|
days: [],
|
||||||
|
nextFireAt: nextMealOccurrence('19:00', [], now)
|
||||||
|
}
|
||||||
|
],
|
||||||
|
settings: {
|
||||||
|
...DEFAULT_SETTINGS,
|
||||||
|
lastSeenVersion: '0.6.5'
|
||||||
|
},
|
||||||
|
challenges: [
|
||||||
|
{
|
||||||
|
id: 'dev-ch-deaths',
|
||||||
|
name: 'За смерти в Dota',
|
||||||
|
gameId: 'dota2',
|
||||||
|
stat: 'deaths',
|
||||||
|
multiplier: 3,
|
||||||
|
exerciseName: 'Приседания',
|
||||||
|
icon: 'Activity',
|
||||||
|
enabled: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dev-ch-kills',
|
||||||
|
name: 'За убийства',
|
||||||
|
gameId: 'dota2',
|
||||||
|
stat: 'kills',
|
||||||
|
multiplier: 1,
|
||||||
|
exerciseName: 'Отжимания',
|
||||||
|
icon: 'Dumbbell',
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
gamesEnabled: { dota2: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
let history: HistoryEntry[] = [
|
||||||
|
{
|
||||||
|
ts: now - 2 * 60 * 60 * 1000,
|
||||||
|
exerciseId: 'dev-ex-squats',
|
||||||
|
action: 'done',
|
||||||
|
reps: 10,
|
||||||
|
name: 'Приседания',
|
||||||
|
source: 'reminder'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ts: now - 5 * 60 * 60 * 1000,
|
||||||
|
exerciseId: 'meal:dev-meal-breakfast',
|
||||||
|
action: 'done',
|
||||||
|
reps: 1,
|
||||||
|
name: 'Завтрак',
|
||||||
|
source: 'meal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ts: now - 26 * 60 * 60 * 1000,
|
||||||
|
exerciseId: 'dev-ex-eyes',
|
||||||
|
action: 'done',
|
||||||
|
reps: 1,
|
||||||
|
name: 'Отдых глазам 20-20-20',
|
||||||
|
source: 'reminder'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ts: now - 48 * 60 * 60 * 1000,
|
||||||
|
exerciseId: 'dev-ex-squats',
|
||||||
|
action: 'done',
|
||||||
|
reps: 10,
|
||||||
|
name: 'Приседания',
|
||||||
|
source: 'reminder'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
let games: GameStatus[] = [
|
||||||
|
{
|
||||||
|
id: 'dota2',
|
||||||
|
name: 'Dota 2',
|
||||||
|
installed: true,
|
||||||
|
installPath:
|
||||||
|
'C:\\Program Files (x86)\\Steam\\steamapps\\common\\dota 2 beta',
|
||||||
|
integrationActive: false,
|
||||||
|
launchOption: '-gamestateintegration',
|
||||||
|
launchOptionStatus: 'queued',
|
||||||
|
steamRunning: true,
|
||||||
|
enabled: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
let updaterStatus: UpdaterStatus = {
|
||||||
|
kind: 'not-available',
|
||||||
|
currentVersion: '0.6.5',
|
||||||
|
lastCheckedAt: now - 12 * 60_000
|
||||||
|
}
|
||||||
|
|
||||||
|
const stateHandlers = new Set<Handler<AppState>>()
|
||||||
|
const tickHandlers = new Set<Handler<Tick[]>>()
|
||||||
|
const historyHandlers = new Set<Handler<void>>()
|
||||||
|
const gamesHandlers = new Set<Handler<GameStatus[]>>()
|
||||||
|
const updaterHandlers = new Set<Handler<UpdaterStatus>>()
|
||||||
|
const themeHandlers = new Set<Handler<'light' | 'dark'>>()
|
||||||
|
const emptyUnsub = (): void => undefined
|
||||||
|
let tickTimer: number | undefined
|
||||||
|
|
||||||
|
function cloneState(): AppState {
|
||||||
|
return structuredClone(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
function emitState(): void {
|
||||||
|
const snapshot = cloneState()
|
||||||
|
stateHandlers.forEach((handler) => handler(snapshot))
|
||||||
|
}
|
||||||
|
|
||||||
|
function emitHistory(): void {
|
||||||
|
historyHandlers.forEach((handler) => handler())
|
||||||
|
}
|
||||||
|
|
||||||
|
function emitGames(): void {
|
||||||
|
const snapshot = structuredClone(games)
|
||||||
|
gamesHandlers.forEach((handler) => handler(snapshot))
|
||||||
|
}
|
||||||
|
|
||||||
|
function emitUpdater(): void {
|
||||||
|
updaterHandlers.forEach((handler) => handler(updaterStatus))
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushHistory(entry: HistoryEntry): void {
|
||||||
|
history = [entry, ...history]
|
||||||
|
emitHistory()
|
||||||
|
}
|
||||||
|
|
||||||
|
function findExercise(id: string): Exercise {
|
||||||
|
const exercise = state.exercises.find((item) => item.id === id)
|
||||||
|
if (!exercise) throw new Error(`Unknown exercise ${id}`)
|
||||||
|
return exercise
|
||||||
|
}
|
||||||
|
|
||||||
|
function findMeal(id: string): Meal {
|
||||||
|
const meal = state.meals.find((item) => item.id === id)
|
||||||
|
if (!meal) throw new Error(`Unknown meal ${id}`)
|
||||||
|
return meal
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextId(prefix: string): string {
|
||||||
|
return `${prefix}-${Math.random().toString(36).slice(2, 9)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscribe<T>(set: Set<Handler<T>>, handler: Handler<T>): () => void {
|
||||||
|
set.add(handler)
|
||||||
|
return () => set.delete(handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildTicks(): Tick[] {
|
||||||
|
return state.exercises.map((exercise) => ({
|
||||||
|
exerciseId: exercise.id,
|
||||||
|
enabled: exercise.enabled,
|
||||||
|
msUntilFire: exercise.nextFireAt - Date.now()
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (import.meta.hot) {
|
||||||
|
import.meta.hot.dispose(() => {
|
||||||
|
if (tickTimer !== undefined) window.clearInterval(tickTimer)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function installDevApi(): void {
|
||||||
|
if (window.api || !import.meta.env.DEV) return
|
||||||
|
|
||||||
|
const api: Api = {
|
||||||
|
getState: async () => cloneState(),
|
||||||
|
addExercise: async (input) => {
|
||||||
|
const exercise: Exercise = {
|
||||||
|
...input,
|
||||||
|
id: nextId('dev-ex'),
|
||||||
|
nextFireAt: Date.now() + input.intervalMinutes * 60_000
|
||||||
|
}
|
||||||
|
state = { ...state, exercises: [...state.exercises, exercise] }
|
||||||
|
emitState()
|
||||||
|
return structuredClone(exercise)
|
||||||
|
},
|
||||||
|
updateExercise: async (id, patch) => {
|
||||||
|
let updated = findExercise(id)
|
||||||
|
state = {
|
||||||
|
...state,
|
||||||
|
exercises: state.exercises.map((exercise) => {
|
||||||
|
if (exercise.id !== id) return exercise
|
||||||
|
updated = { ...exercise, ...patch, id }
|
||||||
|
return updated
|
||||||
|
})
|
||||||
|
}
|
||||||
|
emitState()
|
||||||
|
return structuredClone(updated)
|
||||||
|
},
|
||||||
|
deleteExercise: async (id) => {
|
||||||
|
const before = state.exercises.length
|
||||||
|
state = {
|
||||||
|
...state,
|
||||||
|
exercises: state.exercises.filter((exercise) => exercise.id !== id)
|
||||||
|
}
|
||||||
|
emitState()
|
||||||
|
return state.exercises.length !== before
|
||||||
|
},
|
||||||
|
toggleExercise: async (id, enabled) => {
|
||||||
|
return api.updateExercise(id, { enabled })
|
||||||
|
},
|
||||||
|
markDone: async (id, actualReps) => {
|
||||||
|
const exercise = findExercise(id)
|
||||||
|
const updated = await api.updateExercise(id, {
|
||||||
|
lastDoneAt: Date.now(),
|
||||||
|
nextFireAt: Date.now() + exercise.intervalMinutes * 60_000
|
||||||
|
})
|
||||||
|
pushHistory({
|
||||||
|
ts: Date.now(),
|
||||||
|
exerciseId: id,
|
||||||
|
action: 'done',
|
||||||
|
actualReps,
|
||||||
|
reps: exercise.reps,
|
||||||
|
name: exercise.name,
|
||||||
|
source: 'reminder'
|
||||||
|
})
|
||||||
|
return updated
|
||||||
|
},
|
||||||
|
snooze: async (id, minutes) => {
|
||||||
|
return api.updateExercise(id, {
|
||||||
|
nextFireAt: Date.now() + minutes * 60_000
|
||||||
|
})
|
||||||
|
},
|
||||||
|
skip: async (id) => {
|
||||||
|
const exercise = findExercise(id)
|
||||||
|
const updated = await api.updateExercise(id, {
|
||||||
|
nextFireAt: Date.now() + exercise.intervalMinutes * 60_000
|
||||||
|
})
|
||||||
|
pushHistory({
|
||||||
|
ts: Date.now(),
|
||||||
|
exerciseId: id,
|
||||||
|
action: 'skip',
|
||||||
|
reps: exercise.reps,
|
||||||
|
name: exercise.name,
|
||||||
|
source: 'reminder'
|
||||||
|
})
|
||||||
|
return updated
|
||||||
|
},
|
||||||
|
addMeal: async (input) => {
|
||||||
|
const meal: Meal = {
|
||||||
|
...input,
|
||||||
|
id: nextId('dev-meal'),
|
||||||
|
nextFireAt: nextMealOccurrence(input.time, input.days, Date.now())
|
||||||
|
}
|
||||||
|
state = { ...state, meals: [...state.meals, meal] }
|
||||||
|
emitState()
|
||||||
|
return structuredClone(meal)
|
||||||
|
},
|
||||||
|
updateMeal: async (id, patch) => {
|
||||||
|
let updated = findMeal(id)
|
||||||
|
state = {
|
||||||
|
...state,
|
||||||
|
meals: state.meals.map((meal) => {
|
||||||
|
if (meal.id !== id) return meal
|
||||||
|
updated = { ...meal, ...patch, id }
|
||||||
|
if (
|
||||||
|
(patch.time !== undefined ||
|
||||||
|
patch.days !== undefined ||
|
||||||
|
patch.enabled !== undefined) &&
|
||||||
|
patch.nextFireAt === undefined
|
||||||
|
) {
|
||||||
|
updated.nextFireAt = nextMealOccurrence(
|
||||||
|
updated.time,
|
||||||
|
updated.days,
|
||||||
|
Date.now()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return updated
|
||||||
|
})
|
||||||
|
}
|
||||||
|
emitState()
|
||||||
|
return structuredClone(updated)
|
||||||
|
},
|
||||||
|
deleteMeal: async (id) => {
|
||||||
|
const before = state.meals.length
|
||||||
|
state = { ...state, meals: state.meals.filter((meal) => meal.id !== id) }
|
||||||
|
emitState()
|
||||||
|
return state.meals.length !== before
|
||||||
|
},
|
||||||
|
toggleMeal: async (id, enabled) => api.updateMeal(id, { enabled }),
|
||||||
|
markMealDone: async (id) => {
|
||||||
|
const meal = findMeal(id)
|
||||||
|
const updated = await api.updateMeal(id, {
|
||||||
|
lastDoneAt: Date.now(),
|
||||||
|
nextFireAt: nextMealOccurrence(meal.time, meal.days, Date.now())
|
||||||
|
})
|
||||||
|
pushHistory({
|
||||||
|
ts: Date.now(),
|
||||||
|
exerciseId: `meal:${id}`,
|
||||||
|
action: 'done',
|
||||||
|
reps: 1,
|
||||||
|
name: meal.name,
|
||||||
|
source: 'meal'
|
||||||
|
})
|
||||||
|
return updated
|
||||||
|
},
|
||||||
|
updateSettings: async (patch: Partial<Settings>) => {
|
||||||
|
state = { ...state, settings: { ...state.settings, ...patch } }
|
||||||
|
if (patch.theme === 'light' || patch.theme === 'dark') {
|
||||||
|
themeHandlers.forEach((handler) =>
|
||||||
|
handler(patch.theme as 'light' | 'dark')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
emitState()
|
||||||
|
return structuredClone(state.settings)
|
||||||
|
},
|
||||||
|
getAccentColor: async () => '#ff6b35',
|
||||||
|
getOsTheme: async () => 'light',
|
||||||
|
getAppVersion: async () => '0.6.5',
|
||||||
|
getMeetingActive: async () => false,
|
||||||
|
getDiagnostics: async () => diagnostics(),
|
||||||
|
openLogsFolder: async () => ({ ok: true }),
|
||||||
|
copyDiagnostics: async () => diagnostics(),
|
||||||
|
reportRendererError: async (report: RendererErrorReport) => {
|
||||||
|
console.warn('[dev-api] renderer error', report)
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
pauseAll: async () => {
|
||||||
|
await api.updateSettings({ globalEnabled: false })
|
||||||
|
},
|
||||||
|
resumeAll: async () => {
|
||||||
|
await api.updateSettings({ globalEnabled: true })
|
||||||
|
},
|
||||||
|
quit: async () => undefined,
|
||||||
|
reminderClose: async () => undefined,
|
||||||
|
minimizeMain: () => undefined,
|
||||||
|
toggleMaximizeMain: () => undefined,
|
||||||
|
isMaximizedMain: async () => false,
|
||||||
|
closeMain: () => undefined,
|
||||||
|
hideMain: () => undefined,
|
||||||
|
listGames: async () => structuredClone(games),
|
||||||
|
installGame: async (id: GameId) => {
|
||||||
|
games = games.map((game) =>
|
||||||
|
game.id === id
|
||||||
|
? {
|
||||||
|
...game,
|
||||||
|
enabled: true,
|
||||||
|
integrationActive: true,
|
||||||
|
launchOptionStatus: 'applied'
|
||||||
|
}
|
||||||
|
: game
|
||||||
|
)
|
||||||
|
emitGames()
|
||||||
|
return structuredClone(games.find((game) => game.id === id)!)
|
||||||
|
},
|
||||||
|
uninstallGame: async (id: GameId) => {
|
||||||
|
games = games.map((game) =>
|
||||||
|
game.id === id
|
||||||
|
? { ...game, enabled: false, integrationActive: false }
|
||||||
|
: game
|
||||||
|
)
|
||||||
|
emitGames()
|
||||||
|
return structuredClone(games.find((game) => game.id === id)!)
|
||||||
|
},
|
||||||
|
toggleGame: async (id, enabled) => {
|
||||||
|
games = games.map((game) =>
|
||||||
|
game.id === id ? { ...game, enabled } : game
|
||||||
|
)
|
||||||
|
state = {
|
||||||
|
...state,
|
||||||
|
gamesEnabled: { ...state.gamesEnabled, [id]: enabled }
|
||||||
|
}
|
||||||
|
emitGames()
|
||||||
|
emitState()
|
||||||
|
},
|
||||||
|
openGameLaunchOptions: async () => undefined,
|
||||||
|
addChallenge: async (input) => {
|
||||||
|
const challenge: Challenge = { ...input, id: nextId('dev-ch') }
|
||||||
|
state = { ...state, challenges: [...state.challenges, challenge] }
|
||||||
|
emitState()
|
||||||
|
return structuredClone(challenge)
|
||||||
|
},
|
||||||
|
updateChallenge: async (id, patch) => {
|
||||||
|
let updated = state.challenges.find((challenge) => challenge.id === id)
|
||||||
|
if (!updated) throw new Error(`Unknown challenge ${id}`)
|
||||||
|
state = {
|
||||||
|
...state,
|
||||||
|
challenges: state.challenges.map((challenge) => {
|
||||||
|
if (challenge.id !== id) return challenge
|
||||||
|
updated = { ...challenge, ...patch, id }
|
||||||
|
return updated
|
||||||
|
})
|
||||||
|
}
|
||||||
|
emitState()
|
||||||
|
return structuredClone(updated)
|
||||||
|
},
|
||||||
|
deleteChallenge: async (id) => {
|
||||||
|
const before = state.challenges.length
|
||||||
|
state = {
|
||||||
|
...state,
|
||||||
|
challenges: state.challenges.filter((challenge) => challenge.id !== id)
|
||||||
|
}
|
||||||
|
emitState()
|
||||||
|
return state.challenges.length !== before
|
||||||
|
},
|
||||||
|
toggleChallenge: async (id, enabled) => {
|
||||||
|
return api.updateChallenge(id, { enabled })
|
||||||
|
},
|
||||||
|
markChallengeDone: async (id, reps) => {
|
||||||
|
const challenge = state.challenges.find((item) => item.id === id)
|
||||||
|
pushHistory({
|
||||||
|
ts: Date.now(),
|
||||||
|
exerciseId: `challenge:${id}`,
|
||||||
|
action: 'done',
|
||||||
|
actualReps: reps,
|
||||||
|
reps,
|
||||||
|
name: challenge?.exerciseName ?? challenge?.name,
|
||||||
|
source: 'match'
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
closeMatchSummary: async () => undefined,
|
||||||
|
simulateMatchEnd: async () => undefined,
|
||||||
|
updaterStatus: async () => updaterStatus,
|
||||||
|
updaterCheck: async () => {
|
||||||
|
updaterStatus = {
|
||||||
|
kind: 'not-available',
|
||||||
|
currentVersion: '0.6.5',
|
||||||
|
lastCheckedAt: Date.now()
|
||||||
|
}
|
||||||
|
emitUpdater()
|
||||||
|
return updaterStatus
|
||||||
|
},
|
||||||
|
updaterDownload: () => undefined,
|
||||||
|
updaterInstall: () => undefined,
|
||||||
|
getHistory: async (sinceMs) =>
|
||||||
|
structuredClone(
|
||||||
|
sinceMs === undefined
|
||||||
|
? history
|
||||||
|
: history.filter((entry) => entry.ts >= sinceMs)
|
||||||
|
),
|
||||||
|
clearHistory: async (beforeTs) => {
|
||||||
|
const before = history.length
|
||||||
|
history =
|
||||||
|
beforeTs === undefined
|
||||||
|
? history
|
||||||
|
: history.filter((entry) => entry.ts >= beforeTs)
|
||||||
|
emitHistory()
|
||||||
|
return before - history.length
|
||||||
|
},
|
||||||
|
exportState: async () => ({
|
||||||
|
ok: true,
|
||||||
|
canceled: false,
|
||||||
|
path: 'C:\\Users\\Demo\\Desktop\\razomnis-backup.json'
|
||||||
|
}),
|
||||||
|
importState: async () => ({ ok: true, canceled: false }),
|
||||||
|
onTick: (handler) => subscribe(tickHandlers, handler),
|
||||||
|
onFire: () => emptyUnsub,
|
||||||
|
onFireMeal: () => emptyUnsub,
|
||||||
|
onMatchEnd: () => emptyUnsub,
|
||||||
|
onStateChanged: (handler) => subscribe(stateHandlers, handler),
|
||||||
|
onThemeChanged: (handler) => subscribe(themeHandlers, handler),
|
||||||
|
onAccentChanged: () => emptyUnsub,
|
||||||
|
onGamesChanged: (handler) => subscribe(gamesHandlers, handler),
|
||||||
|
onUpdaterStatus: (handler) => subscribe(updaterHandlers, handler),
|
||||||
|
onMaximizeChanged: () => emptyUnsub,
|
||||||
|
onMeetingChanged: () => emptyUnsub,
|
||||||
|
onHistoryChanged: (handler) => subscribe(historyHandlers, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
window.api = api
|
||||||
|
tickTimer = window.setInterval(() => {
|
||||||
|
const ticks = buildTicks()
|
||||||
|
tickHandlers.forEach((handler) => handler(ticks))
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
function diagnostics(): DiagnosticsInfo {
|
||||||
|
return {
|
||||||
|
generatedAt: Date.now(),
|
||||||
|
app: {
|
||||||
|
version: '0.6.5',
|
||||||
|
isPackaged: false,
|
||||||
|
platform: 'win32',
|
||||||
|
arch: 'x64'
|
||||||
|
},
|
||||||
|
runtime: {
|
||||||
|
electron: 'dev',
|
||||||
|
chrome: 'dev',
|
||||||
|
node: 'dev'
|
||||||
|
},
|
||||||
|
paths: {
|
||||||
|
userData: 'dev-renderer',
|
||||||
|
store: 'dev-renderer',
|
||||||
|
logs: 'dev-renderer'
|
||||||
|
},
|
||||||
|
store: {
|
||||||
|
bytes: null,
|
||||||
|
exercises: state.exercises.length,
|
||||||
|
meals: state.meals.length,
|
||||||
|
challenges: state.challenges.length,
|
||||||
|
history: history.length
|
||||||
|
},
|
||||||
|
updater: updaterStatus,
|
||||||
|
games,
|
||||||
|
gsi: {
|
||||||
|
running: games.some((game) => game.integrationActive),
|
||||||
|
port: 38087,
|
||||||
|
baseUrl: 'http://127.0.0.1:38087'
|
||||||
|
},
|
||||||
|
meetingActive: false
|
||||||
|
}
|
||||||
|
}
|
||||||
111
src/renderer/src/lib/wellness.test.ts
Normal file
111
src/renderer/src/lib/wellness.test.ts
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import type { Exercise, HistoryEntry, Meal } from '@shared/types'
|
||||||
|
import {
|
||||||
|
buildSessionPlan,
|
||||||
|
computeWeeklyAnalytics,
|
||||||
|
computeWellnessInsights,
|
||||||
|
planGameDebt
|
||||||
|
} from './wellness'
|
||||||
|
|
||||||
|
const mondayNoon = new Date(2026, 5, 8, 12, 0, 0, 0).getTime()
|
||||||
|
|
||||||
|
const exercise: Exercise = {
|
||||||
|
id: 'ex-1',
|
||||||
|
name: 'Приседания',
|
||||||
|
reps: 10,
|
||||||
|
icon: 'Activity',
|
||||||
|
intervalMinutes: 60,
|
||||||
|
enabled: true,
|
||||||
|
nextFireAt: mondayNoon + 60_000,
|
||||||
|
category: 'exercise'
|
||||||
|
}
|
||||||
|
|
||||||
|
const meal: Meal = {
|
||||||
|
id: 'meal-1',
|
||||||
|
name: 'Обед',
|
||||||
|
time: '13:00',
|
||||||
|
icon: 'UtensilsCrossed',
|
||||||
|
enabled: false,
|
||||||
|
days: [],
|
||||||
|
nextFireAt: mondayNoon + 60_000
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('wellness analytics', () => {
|
||||||
|
it('computes weekly completion and late skips', () => {
|
||||||
|
const history: HistoryEntry[] = [
|
||||||
|
{
|
||||||
|
ts: mondayNoon,
|
||||||
|
exerciseId: exercise.id,
|
||||||
|
action: 'done',
|
||||||
|
reps: 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ts: mondayNoon + 7 * 60 * 60 * 1000,
|
||||||
|
exerciseId: exercise.id,
|
||||||
|
action: 'skip'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const analytics = computeWeeklyAnalytics({
|
||||||
|
history,
|
||||||
|
exercises: [exercise],
|
||||||
|
now: mondayNoon + 8 * 60 * 60 * 1000
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(analytics.activeDays).toBe(1)
|
||||||
|
expect(analytics.doneReps).toBe(10)
|
||||||
|
expect(analytics.skippedActions).toBe(1)
|
||||||
|
expect(analytics.lateSkips).toBe(1)
|
||||||
|
expect(analytics.completionPct).toBe(50)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('surfaces useful insights from state', () => {
|
||||||
|
const analytics = {
|
||||||
|
activeDays: 1,
|
||||||
|
doneReps: 10,
|
||||||
|
doneActions: 1,
|
||||||
|
skippedActions: 4,
|
||||||
|
snoozedActions: 0,
|
||||||
|
bestDayReps: 10,
|
||||||
|
lateSkips: 2,
|
||||||
|
completionPct: 20
|
||||||
|
}
|
||||||
|
|
||||||
|
const insights = computeWellnessInsights({
|
||||||
|
exercises: [exercise],
|
||||||
|
meals: [meal],
|
||||||
|
analytics
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(insights.map((i) => i.id)).toContain('too_many_skips')
|
||||||
|
expect(insights.map((i) => i.id)).toContain('late_slump')
|
||||||
|
expect(insights.map((i) => i.id)).toContain('empty_meals')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('wellness sessions', () => {
|
||||||
|
it('builds a compact session from enabled exercises', () => {
|
||||||
|
const session = buildSessionPlan({ exercises: [exercise], minutes: 5 })
|
||||||
|
|
||||||
|
expect(session.steps).toHaveLength(3)
|
||||||
|
expect(session.steps[0]).toMatchObject({
|
||||||
|
exerciseId: exercise.id,
|
||||||
|
reps: 10
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('splits game debt into realistic sets', () => {
|
||||||
|
expect(planGameDebt(12)).toEqual({
|
||||||
|
total: 12,
|
||||||
|
now: 12,
|
||||||
|
later: 0,
|
||||||
|
sets: [12]
|
||||||
|
})
|
||||||
|
expect(planGameDebt(55)).toEqual({
|
||||||
|
total: 55,
|
||||||
|
now: 20,
|
||||||
|
later: 35,
|
||||||
|
sets: [20, 20, 15]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
399
src/renderer/src/lib/wellness.ts
Normal file
399
src/renderer/src/lib/wellness.ts
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
import type { Exercise, HistoryEntry, Meal } from '@shared/types'
|
||||||
|
import { dayKey } from './history'
|
||||||
|
|
||||||
|
export type ExercisePreset = {
|
||||||
|
id: string
|
||||||
|
titleKey: string
|
||||||
|
descKey: string
|
||||||
|
exercises: Omit<Exercise, 'id' | 'nextFireAt' | 'lastDoneAt'>[]
|
||||||
|
meals?: Omit<Meal, 'id' | 'nextFireAt' | 'lastDoneAt'>[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type WellnessInsight = {
|
||||||
|
id:
|
||||||
|
| 'first_run'
|
||||||
|
| 'too_many_skips'
|
||||||
|
| 'good_rhythm'
|
||||||
|
| 'late_slump'
|
||||||
|
| 'empty_meals'
|
||||||
|
titleKey: string
|
||||||
|
descKey: string
|
||||||
|
tone: 'accent' | 'success' | 'warning' | 'info'
|
||||||
|
vars?: Record<string, string | number>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type WeeklyAnalytics = {
|
||||||
|
activeDays: number
|
||||||
|
doneReps: number
|
||||||
|
doneActions: number
|
||||||
|
skippedActions: number
|
||||||
|
snoozedActions: number
|
||||||
|
bestDayKey?: string
|
||||||
|
bestDayReps: number
|
||||||
|
lateSkips: number
|
||||||
|
completionPct: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SessionStep = {
|
||||||
|
exerciseId?: string
|
||||||
|
name: string
|
||||||
|
icon: string
|
||||||
|
reps: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SessionPlan = {
|
||||||
|
minutes: 3 | 5 | 10
|
||||||
|
titleKey: string
|
||||||
|
steps: SessionStep[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GameDebtPlan = {
|
||||||
|
total: number
|
||||||
|
now: number
|
||||||
|
later: number
|
||||||
|
sets: number[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const DAY_MS = 24 * 60 * 60 * 1000
|
||||||
|
|
||||||
|
export const EXERCISE_PRESETS: ExercisePreset[] = [
|
||||||
|
{
|
||||||
|
id: 'office',
|
||||||
|
titleKey: 'preset.office.title',
|
||||||
|
descKey: 'preset.office.desc',
|
||||||
|
exercises: [
|
||||||
|
{
|
||||||
|
name: 'Плечи и шея',
|
||||||
|
reps: 8,
|
||||||
|
icon: 'StretchHorizontal',
|
||||||
|
intervalMinutes: 45,
|
||||||
|
enabled: true,
|
||||||
|
category: 'posture',
|
||||||
|
dailyGoal: 32,
|
||||||
|
adaptive: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Приседания',
|
||||||
|
reps: 10,
|
||||||
|
icon: 'Activity',
|
||||||
|
intervalMinutes: 60,
|
||||||
|
enabled: true,
|
||||||
|
category: 'exercise',
|
||||||
|
dailyGoal: 40,
|
||||||
|
adaptive: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Отдых глазам',
|
||||||
|
reps: 1,
|
||||||
|
icon: 'Eye',
|
||||||
|
intervalMinutes: 30,
|
||||||
|
enabled: true,
|
||||||
|
category: 'eyes',
|
||||||
|
dailyGoal: 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'back',
|
||||||
|
titleKey: 'preset.back.title',
|
||||||
|
descKey: 'preset.back.desc',
|
||||||
|
exercises: [
|
||||||
|
{
|
||||||
|
name: 'Проверь осанку',
|
||||||
|
reps: 1,
|
||||||
|
icon: 'PersonStanding',
|
||||||
|
intervalMinutes: 25,
|
||||||
|
enabled: true,
|
||||||
|
category: 'posture',
|
||||||
|
dailyGoal: 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Лопатки назад',
|
||||||
|
reps: 12,
|
||||||
|
icon: 'StretchHorizontal',
|
||||||
|
intervalMinutes: 50,
|
||||||
|
enabled: true,
|
||||||
|
category: 'posture',
|
||||||
|
dailyGoal: 48,
|
||||||
|
adaptive: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Наклоны',
|
||||||
|
reps: 8,
|
||||||
|
icon: 'Activity',
|
||||||
|
intervalMinutes: 70,
|
||||||
|
enabled: true,
|
||||||
|
category: 'exercise',
|
||||||
|
dailyGoal: 32
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'minimum',
|
||||||
|
titleKey: 'preset.minimum.title',
|
||||||
|
descKey: 'preset.minimum.desc',
|
||||||
|
exercises: [
|
||||||
|
{
|
||||||
|
name: 'Мини-разминка',
|
||||||
|
reps: 5,
|
||||||
|
icon: 'Dumbbell',
|
||||||
|
intervalMinutes: 90,
|
||||||
|
enabled: true,
|
||||||
|
category: 'exercise',
|
||||||
|
dailyGoal: 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Стакан воды',
|
||||||
|
reps: 1,
|
||||||
|
icon: 'GlassWater',
|
||||||
|
intervalMinutes: 120,
|
||||||
|
enabled: true,
|
||||||
|
category: 'hydration',
|
||||||
|
dailyGoal: 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'after_match',
|
||||||
|
titleKey: 'preset.after_match.title',
|
||||||
|
descKey: 'preset.after_match.desc',
|
||||||
|
exercises: [
|
||||||
|
{
|
||||||
|
name: 'Приседания после катки',
|
||||||
|
reps: 12,
|
||||||
|
icon: 'Activity',
|
||||||
|
intervalMinutes: 75,
|
||||||
|
enabled: true,
|
||||||
|
category: 'exercise',
|
||||||
|
dailyGoal: 48
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Отжимания после катки',
|
||||||
|
reps: 8,
|
||||||
|
icon: 'Dumbbell',
|
||||||
|
intervalMinutes: 90,
|
||||||
|
enabled: true,
|
||||||
|
category: 'exercise',
|
||||||
|
dailyGoal: 32
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
function startOfWeek(ts: number): number {
|
||||||
|
const d = new Date(ts)
|
||||||
|
d.setHours(0, 0, 0, 0)
|
||||||
|
const day = d.getDay()
|
||||||
|
d.setDate(d.getDate() + (day === 0 ? -6 : 1 - day))
|
||||||
|
return d.getTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
function entryReps(
|
||||||
|
entry: HistoryEntry,
|
||||||
|
exercisesById: Map<string, Exercise>
|
||||||
|
): number {
|
||||||
|
return (
|
||||||
|
entry.actualReps ??
|
||||||
|
entry.reps ??
|
||||||
|
exercisesById.get(entry.exerciseId)?.reps ??
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function computeWeeklyAnalytics({
|
||||||
|
history,
|
||||||
|
exercises,
|
||||||
|
now = Date.now()
|
||||||
|
}: {
|
||||||
|
history: HistoryEntry[]
|
||||||
|
exercises: Exercise[]
|
||||||
|
now?: number
|
||||||
|
}): WeeklyAnalytics {
|
||||||
|
const weekStart = startOfWeek(now)
|
||||||
|
const exercisesById = new Map(exercises.map((e) => [e.id, e]))
|
||||||
|
const days = new Map<string, number>()
|
||||||
|
let doneReps = 0
|
||||||
|
let doneActions = 0
|
||||||
|
let skippedActions = 0
|
||||||
|
let snoozedActions = 0
|
||||||
|
let lateSkips = 0
|
||||||
|
|
||||||
|
for (const entry of history) {
|
||||||
|
if (entry.ts < weekStart || entry.ts > now) continue
|
||||||
|
const key = dayKey(entry.ts)
|
||||||
|
if (entry.action === 'done') {
|
||||||
|
const reps = entryReps(entry, exercisesById)
|
||||||
|
doneReps += reps
|
||||||
|
doneActions++
|
||||||
|
days.set(key, (days.get(key) ?? 0) + reps)
|
||||||
|
} else if (entry.action === 'skip') {
|
||||||
|
skippedActions++
|
||||||
|
if (new Date(entry.ts).getHours() >= 18) lateSkips++
|
||||||
|
} else if (entry.action === 'snooze') {
|
||||||
|
snoozedActions++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let bestDayKey: string | undefined
|
||||||
|
let bestDayReps = 0
|
||||||
|
for (const [key, reps] of days) {
|
||||||
|
if (reps > bestDayReps) {
|
||||||
|
bestDayKey = key
|
||||||
|
bestDayReps = reps
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const attempts = doneActions + skippedActions
|
||||||
|
const completionPct =
|
||||||
|
attempts > 0 ? Math.round((doneActions / attempts) * 100) : 0
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeDays: days.size,
|
||||||
|
doneReps,
|
||||||
|
doneActions,
|
||||||
|
skippedActions,
|
||||||
|
snoozedActions,
|
||||||
|
bestDayKey,
|
||||||
|
bestDayReps,
|
||||||
|
lateSkips,
|
||||||
|
completionPct
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function computeWellnessInsights({
|
||||||
|
exercises,
|
||||||
|
meals,
|
||||||
|
analytics
|
||||||
|
}: {
|
||||||
|
exercises: Exercise[]
|
||||||
|
meals: Meal[]
|
||||||
|
analytics: WeeklyAnalytics
|
||||||
|
}): WellnessInsight[] {
|
||||||
|
const insights: WellnessInsight[] = []
|
||||||
|
const activeExercises = exercises.filter((e) => e.enabled).length
|
||||||
|
const activeMeals = meals.filter((m) => m.enabled).length
|
||||||
|
|
||||||
|
if (activeExercises === 0) {
|
||||||
|
insights.push({
|
||||||
|
id: 'first_run',
|
||||||
|
titleKey: 'insight.first_run.title',
|
||||||
|
descKey: 'insight.first_run.desc',
|
||||||
|
tone: 'accent'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (analytics.skippedActions >= 3 && analytics.completionPct < 60) {
|
||||||
|
insights.push({
|
||||||
|
id: 'too_many_skips',
|
||||||
|
titleKey: 'insight.too_many_skips.title',
|
||||||
|
descKey: 'insight.too_many_skips.desc',
|
||||||
|
tone: 'warning',
|
||||||
|
vars: { n: analytics.skippedActions }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (analytics.lateSkips >= 2) {
|
||||||
|
insights.push({
|
||||||
|
id: 'late_slump',
|
||||||
|
titleKey: 'insight.late_slump.title',
|
||||||
|
descKey: 'insight.late_slump.desc',
|
||||||
|
tone: 'info',
|
||||||
|
vars: { n: analytics.lateSkips }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeMeals === 0) {
|
||||||
|
insights.push({
|
||||||
|
id: 'empty_meals',
|
||||||
|
titleKey: 'insight.empty_meals.title',
|
||||||
|
descKey: 'insight.empty_meals.desc',
|
||||||
|
tone: 'info'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (analytics.activeDays >= 4 && analytics.completionPct >= 70) {
|
||||||
|
insights.push({
|
||||||
|
id: 'good_rhythm',
|
||||||
|
titleKey: 'insight.good_rhythm.title',
|
||||||
|
descKey: 'insight.good_rhythm.desc',
|
||||||
|
tone: 'success',
|
||||||
|
vars: { pct: analytics.completionPct }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return insights.slice(0, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildSessionPlan({
|
||||||
|
exercises,
|
||||||
|
minutes
|
||||||
|
}: {
|
||||||
|
exercises: Exercise[]
|
||||||
|
minutes: 3 | 5 | 10
|
||||||
|
}): SessionPlan {
|
||||||
|
const enabled = exercises.filter((e) => e.enabled)
|
||||||
|
const pool = enabled.length > 0 ? enabled : exercises
|
||||||
|
const count = minutes === 3 ? 2 : minutes === 5 ? 3 : 5
|
||||||
|
const steps = pool.slice(0, count).map<SessionStep>((e) => ({
|
||||||
|
exerciseId: e.enabled ? e.id : undefined,
|
||||||
|
name: e.name,
|
||||||
|
icon: e.icon,
|
||||||
|
reps:
|
||||||
|
e.category === 'hydration' ||
|
||||||
|
e.category === 'eyes' ||
|
||||||
|
e.category === 'posture'
|
||||||
|
? 1
|
||||||
|
: Math.max(
|
||||||
|
3,
|
||||||
|
Math.min(e.reps, minutes === 3 ? 8 : minutes === 5 ? 12 : 16)
|
||||||
|
)
|
||||||
|
}))
|
||||||
|
|
||||||
|
while (steps.length < count) {
|
||||||
|
const fallback =
|
||||||
|
fallbackSessionSteps[steps.length % fallbackSessionSteps.length]
|
||||||
|
steps.push(fallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
minutes,
|
||||||
|
titleKey: `session.${minutes}.title`,
|
||||||
|
steps
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const fallbackSessionSteps: SessionStep[] = [
|
||||||
|
{ name: 'Плечи назад', icon: 'StretchHorizontal', reps: 8 },
|
||||||
|
{ name: 'Приседания', icon: 'Activity', reps: 8 },
|
||||||
|
{ name: 'Отдых глазам', icon: 'Eye', reps: 1 },
|
||||||
|
{ name: 'Проверь осанку', icon: 'PersonStanding', reps: 1 },
|
||||||
|
{ name: 'Стакан воды', icon: 'GlassWater', reps: 1 }
|
||||||
|
]
|
||||||
|
|
||||||
|
export function planGameDebt(total: number): GameDebtPlan {
|
||||||
|
const safeTotal = Math.max(0, Math.trunc(total))
|
||||||
|
if (safeTotal === 0) return { total: 0, now: 0, later: 0, sets: [] }
|
||||||
|
|
||||||
|
const now = Math.min(safeTotal, safeTotal <= 20 ? safeTotal : 20)
|
||||||
|
const later = safeTotal - now
|
||||||
|
const sets: number[] = []
|
||||||
|
let left = safeTotal
|
||||||
|
while (left > 0) {
|
||||||
|
const next = Math.min(left, 20)
|
||||||
|
sets.push(next)
|
||||||
|
left -= next
|
||||||
|
}
|
||||||
|
return { total: safeTotal, now, later, sets }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function weekWindowLabel(now = Date.now()): {
|
||||||
|
from: string
|
||||||
|
to: string
|
||||||
|
} {
|
||||||
|
const from = new Date(startOfWeek(now))
|
||||||
|
const to = new Date(from.getTime() + 6 * DAY_MS)
|
||||||
|
return {
|
||||||
|
from: from.toLocaleDateString('ru-RU', { day: 'numeric', month: 'short' }),
|
||||||
|
to: to.toLocaleDateString('ru-RU', { day: 'numeric', month: 'short' })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,15 +7,19 @@ import ReminderApp from './ReminderApp'
|
|||||||
import { ThemeProvider } from './providers/ThemeProvider'
|
import { ThemeProvider } from './providers/ThemeProvider'
|
||||||
import { installRendererErrorReporting } from './lib/reporting'
|
import { installRendererErrorReporting } from './lib/reporting'
|
||||||
|
|
||||||
installRendererErrorReporting()
|
|
||||||
|
|
||||||
const params = new URLSearchParams(window.location.search)
|
const params = new URLSearchParams(window.location.search)
|
||||||
const which = params.get('window') ?? 'main'
|
const which = params.get('window') ?? 'main'
|
||||||
|
|
||||||
// reducedMotion="user" — framer-motion сам читает системную настройку
|
// reducedMotion="user" — framer-motion сам читает системную настройку
|
||||||
// «уменьшить движение» и глушит transform/layout-анимации (оставляя opacity).
|
// «уменьшить движение» и глушит transform/layout-анимации (оставляя opacity).
|
||||||
// Один источник истины для обоих окон и всех motion-компонентов.
|
// Один источник истины для обоих окон и всех motion-компонентов.
|
||||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
async function bootstrap(): Promise<void> {
|
||||||
|
if (import.meta.env.DEV && !window.api) {
|
||||||
|
const { installDevApi } = await import('./lib/dev-api')
|
||||||
|
installDevApi()
|
||||||
|
}
|
||||||
|
installRendererErrorReporting()
|
||||||
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<MotionConfig reducedMotion="user">
|
<MotionConfig reducedMotion="user">
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
@@ -23,4 +27,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</MotionConfig>
|
</MotionConfig>
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootstrap()
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ import {
|
|||||||
Check,
|
Check,
|
||||||
Trophy,
|
Trophy,
|
||||||
Swords,
|
Swords,
|
||||||
BadgeCheck
|
BadgeCheck,
|
||||||
|
Lightbulb,
|
||||||
|
BarChart3,
|
||||||
|
Timer
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useAppStore } from '../store/appStore'
|
import { useAppStore } from '../store/appStore'
|
||||||
import { ExerciseCard } from '../components/ExerciseCard'
|
import { ExerciseCard } from '../components/ExerciseCard'
|
||||||
@@ -48,6 +51,15 @@ import {
|
|||||||
type MomentumSummary,
|
type MomentumSummary,
|
||||||
type WeeklyQuest
|
type WeeklyQuest
|
||||||
} from '../lib/momentum'
|
} from '../lib/momentum'
|
||||||
|
import {
|
||||||
|
buildSessionPlan,
|
||||||
|
computeWeeklyAnalytics,
|
||||||
|
computeWellnessInsights,
|
||||||
|
weekWindowLabel,
|
||||||
|
type SessionPlan,
|
||||||
|
type WellnessInsight,
|
||||||
|
type WeeklyAnalytics
|
||||||
|
} from '../lib/wellness'
|
||||||
|
|
||||||
export default function Dashboard(): JSX.Element {
|
export default function Dashboard(): JSX.Element {
|
||||||
const state = useAppStore((s) => s.state)
|
const state = useAppStore((s) => s.state)
|
||||||
@@ -142,6 +154,26 @@ export default function Dashboard(): JSX.Element {
|
|||||||
() => computeMomentumSummary({ history, exercises, challenges }),
|
() => computeMomentumSummary({ history, exercises, challenges }),
|
||||||
[history, exercises, challenges]
|
[history, exercises, challenges]
|
||||||
)
|
)
|
||||||
|
const weeklyAnalytics = useMemo(
|
||||||
|
() => computeWeeklyAnalytics({ history, exercises }),
|
||||||
|
[history, exercises]
|
||||||
|
)
|
||||||
|
const wellnessInsights = useMemo(
|
||||||
|
() =>
|
||||||
|
computeWellnessInsights({
|
||||||
|
exercises,
|
||||||
|
meals,
|
||||||
|
analytics: weeklyAnalytics
|
||||||
|
}),
|
||||||
|
[exercises, meals, weeklyAnalytics]
|
||||||
|
)
|
||||||
|
const sessions = useMemo(
|
||||||
|
() =>
|
||||||
|
([3, 5, 10] as const).map((minutes) =>
|
||||||
|
buildSessionPlan({ exercises, minutes })
|
||||||
|
),
|
||||||
|
[exercises]
|
||||||
|
)
|
||||||
|
|
||||||
const paused = !settings?.globalEnabled
|
const paused = !settings?.globalEnabled
|
||||||
|
|
||||||
@@ -201,7 +233,7 @@ export default function Dashboard(): JSX.Element {
|
|||||||
<div className="max-w-5xl mx-auto px-4 sm:px-6 lg:px-10 pt-8 pb-12">
|
<div className="max-w-5xl mx-auto px-4 sm:px-6 lg:px-10 pt-8 pb-12">
|
||||||
<div className="flex flex-col sm:flex-row sm:items-end sm:justify-between gap-4 mb-6">
|
<div className="flex flex-col sm:flex-row sm:items-end sm:justify-between gap-4 mb-6">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className="text-[14px] text-text/65 font-semibold capitalize">
|
<div className="text-[14px] text-text/65 font-semibold">
|
||||||
{t('dashboard.header.date', { date: today })}
|
{t('dashboard.header.date', { date: today })}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-2 flex flex-wrap items-center gap-3">
|
<div className="mt-2 flex flex-wrap items-center gap-3">
|
||||||
@@ -361,6 +393,24 @@ export default function Dashboard(): JSX.Element {
|
|||||||
onItemDone={(item) => void handlePlanItemDone(item)}
|
onItemDone={(item) => void handlePlanItemDone(item)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<SmartWorkPanel
|
||||||
|
insights={wellnessInsights}
|
||||||
|
analytics={weeklyAnalytics}
|
||||||
|
sessions={sessions}
|
||||||
|
exercises={exercises}
|
||||||
|
t={t}
|
||||||
|
onRunSession={async (session) => {
|
||||||
|
for (const step of session.steps) {
|
||||||
|
if (!step.exerciseId) continue
|
||||||
|
const ex = exercises.find((item) => item.id === step.exerciseId)
|
||||||
|
await window.api.markDone(
|
||||||
|
step.exerciseId,
|
||||||
|
ex && step.reps !== ex.reps ? step.reps : undefined
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<MomentumPanel
|
<MomentumPanel
|
||||||
momentum={momentum}
|
momentum={momentum}
|
||||||
gamesLive={gamesLive}
|
gamesLive={gamesLive}
|
||||||
@@ -524,6 +574,228 @@ function dashboardStatusClass(tone: DashboardHeaderTone): string {
|
|||||||
return 'bg-text/10 text-text/55'
|
return 'bg-text/10 text-text/55'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SmartWorkPanel({
|
||||||
|
insights,
|
||||||
|
analytics,
|
||||||
|
sessions,
|
||||||
|
exercises,
|
||||||
|
t,
|
||||||
|
onRunSession
|
||||||
|
}: {
|
||||||
|
insights: WellnessInsight[]
|
||||||
|
analytics: WeeklyAnalytics
|
||||||
|
sessions: SessionPlan[]
|
||||||
|
exercises: Exercise[]
|
||||||
|
t: TFn
|
||||||
|
onRunSession: (session: SessionPlan) => Promise<void>
|
||||||
|
}): JSX.Element {
|
||||||
|
const [busySession, setBusySession] = useState<number | null>(null)
|
||||||
|
const week = weekWindowLabel()
|
||||||
|
const shownInsights =
|
||||||
|
insights.length > 0
|
||||||
|
? insights
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
id: 'good_rhythm' as const,
|
||||||
|
titleKey: 'insight.default.title',
|
||||||
|
descKey: 'insight.default.desc',
|
||||||
|
tone: 'success' as const
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
async function run(session: SessionPlan): Promise<void> {
|
||||||
|
if (busySession !== null) return
|
||||||
|
setBusySession(session.minutes)
|
||||||
|
try {
|
||||||
|
await onRunSession(session)
|
||||||
|
} finally {
|
||||||
|
setBusySession(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="mb-8 grid grid-cols-1 lg:grid-cols-[1fr_1fr] gap-4">
|
||||||
|
<div className="bg-surface rounded-3xl p-5 shadow-card dark:ring-0.5 dark:ring-hairline/30 min-w-0">
|
||||||
|
<div className="flex items-center gap-3 mb-4">
|
||||||
|
<div className="w-10 h-10 rounded-2xl bg-info/12 text-info grid place-items-center shrink-0">
|
||||||
|
<Lightbulb size={19} strokeWidth={2.5} />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="text-[13px] text-text/55 font-semibold">
|
||||||
|
{t('smart.kicker')}
|
||||||
|
</div>
|
||||||
|
<h2 className="font-display text-[22px] font-bold leading-tight">
|
||||||
|
{t('smart.title')}
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-2">
|
||||||
|
{shownInsights.map((insight) => (
|
||||||
|
<InsightLine key={insight.id} insight={insight} t={t} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="bg-surface rounded-3xl p-5 shadow-card dark:ring-0.5 dark:ring-hairline/30 min-w-0">
|
||||||
|
<div className="flex items-center gap-3 mb-4">
|
||||||
|
<div className="w-10 h-10 rounded-2xl bg-accent/12 text-accent grid place-items-center shrink-0">
|
||||||
|
<Timer size={19} strokeWidth={2.5} />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="text-[13px] text-text/55 font-semibold">
|
||||||
|
{t('session.kicker')}
|
||||||
|
</div>
|
||||||
|
<h2 className="font-display text-[22px] font-bold leading-tight">
|
||||||
|
{t('session.title')}
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-3 gap-2">
|
||||||
|
{sessions.map((session) => (
|
||||||
|
<button
|
||||||
|
key={session.minutes}
|
||||||
|
type="button"
|
||||||
|
onClick={() => void run(session)}
|
||||||
|
disabled={busySession !== null || exercises.length === 0}
|
||||||
|
className="rounded-2xl bg-surface-2 hover:bg-hairline/25 disabled:opacity-55 text-left p-3 transition-colors active:scale-[0.99]"
|
||||||
|
>
|
||||||
|
<div className="font-mono-num text-[22px] font-bold leading-none">
|
||||||
|
{session.minutes}
|
||||||
|
<span className="ml-1 text-[12px] text-text/55 font-sans">
|
||||||
|
{t('fmt.m')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="text-[13px] font-semibold mt-2 leading-tight">
|
||||||
|
{t(session.titleKey)}
|
||||||
|
</div>
|
||||||
|
<div className="text-[12px] text-text/55 mt-1 truncate">
|
||||||
|
{session.steps.map((s) => s.name).join(' · ')}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{exercises.length === 0 && (
|
||||||
|
<div className="text-[13px] text-text/55 mt-3">
|
||||||
|
{t('session.empty')}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="lg:col-span-2 bg-surface rounded-3xl p-5 shadow-card dark:ring-0.5 dark:ring-hairline/30 min-w-0">
|
||||||
|
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4">
|
||||||
|
<div className="flex items-center gap-3 min-w-0">
|
||||||
|
<div className="w-10 h-10 rounded-2xl bg-success/12 text-success grid place-items-center shrink-0">
|
||||||
|
<BarChart3 size={19} strokeWidth={2.5} />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="text-[13px] text-text/55 font-semibold">
|
||||||
|
{t('analytics.kicker')}
|
||||||
|
</div>
|
||||||
|
<h2 className="font-display text-[22px] font-bold leading-tight">
|
||||||
|
{t('analytics.title')}
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="text-[12px] text-text/50 font-semibold">
|
||||||
|
{week.from} — {week.to}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 lg:grid-cols-5 gap-2">
|
||||||
|
<AnalyticsTile
|
||||||
|
label={t('analytics.active_days')}
|
||||||
|
value={`${analytics.activeDays}`}
|
||||||
|
hint={t('analytics.active_days.hint')}
|
||||||
|
/>
|
||||||
|
<AnalyticsTile
|
||||||
|
label={t('analytics.done_reps')}
|
||||||
|
value={`${analytics.doneReps}`}
|
||||||
|
hint={t('analytics.done_reps.hint')}
|
||||||
|
/>
|
||||||
|
<AnalyticsTile
|
||||||
|
label={t('analytics.completion')}
|
||||||
|
value={`${analytics.completionPct}%`}
|
||||||
|
hint={t('analytics.completion.hint')}
|
||||||
|
/>
|
||||||
|
<AnalyticsTile
|
||||||
|
label={t('analytics.skips')}
|
||||||
|
value={`${analytics.skippedActions}`}
|
||||||
|
hint={t('analytics.skips.hint')}
|
||||||
|
/>
|
||||||
|
<AnalyticsTile
|
||||||
|
label={t('analytics.best_day')}
|
||||||
|
value={analytics.bestDayReps > 0 ? `${analytics.bestDayReps}` : '—'}
|
||||||
|
hint={
|
||||||
|
analytics.bestDayKey
|
||||||
|
? t('analytics.best_day.hint', { day: analytics.bestDayKey })
|
||||||
|
: t('analytics.best_day.empty')
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function InsightLine({
|
||||||
|
insight,
|
||||||
|
t
|
||||||
|
}: {
|
||||||
|
insight: WellnessInsight
|
||||||
|
t: TFn
|
||||||
|
}): JSX.Element {
|
||||||
|
const toneClass =
|
||||||
|
insight.tone === 'success'
|
||||||
|
? 'bg-success/12 text-success'
|
||||||
|
: insight.tone === 'warning'
|
||||||
|
? 'bg-warning/12 text-warning'
|
||||||
|
: insight.tone === 'info'
|
||||||
|
? 'bg-info/12 text-info'
|
||||||
|
: 'bg-accent/12 text-accent'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="rounded-2xl bg-surface-2 p-3 flex items-start gap-3 min-w-0">
|
||||||
|
<div
|
||||||
|
className={[
|
||||||
|
'w-8 h-8 rounded-xl grid place-items-center shrink-0',
|
||||||
|
toneClass
|
||||||
|
].join(' ')}
|
||||||
|
>
|
||||||
|
<Lightbulb size={15} strokeWidth={2.5} />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="text-[14px] font-bold leading-tight">
|
||||||
|
{t(insight.titleKey, insight.vars)}
|
||||||
|
</div>
|
||||||
|
<div className="text-[13px] text-text/62 mt-1 leading-snug">
|
||||||
|
{t(insight.descKey, insight.vars)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AnalyticsTile({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
hint
|
||||||
|
}: {
|
||||||
|
label: string
|
||||||
|
value: string
|
||||||
|
hint: string
|
||||||
|
}): JSX.Element {
|
||||||
|
return (
|
||||||
|
<div className="rounded-2xl bg-surface-2 p-3 min-w-0">
|
||||||
|
<div className="text-[12px] text-text/50 font-semibold leading-tight">
|
||||||
|
{label}
|
||||||
|
</div>
|
||||||
|
<div className="font-mono-num text-[22px] font-bold leading-tight mt-1 truncate">
|
||||||
|
{value}
|
||||||
|
</div>
|
||||||
|
<div className="text-[12px] text-text/52 mt-1 truncate">{hint}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function MomentumPanel({
|
function MomentumPanel({
|
||||||
momentum,
|
momentum,
|
||||||
gamesLive,
|
gamesLive,
|
||||||
@@ -1054,7 +1326,7 @@ function planItemMeta(item: PlanItem, t: TFn): string {
|
|||||||
: t('dashboard.plan.kind.meal')
|
: t('dashboard.plan.kind.meal')
|
||||||
}
|
}
|
||||||
if (item.goal !== undefined) {
|
if (item.goal !== undefined) {
|
||||||
return t('dashboard.plan.item.remaining', {
|
return t('dashboard.plan.item.remaining_reps', {
|
||||||
n: item.remainingReps ?? 0
|
n: item.remainingReps ?? 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Activity, ChevronRight, Dumbbell, Plus, Target } from 'lucide-react'
|
import {
|
||||||
|
Activity,
|
||||||
|
ChevronRight,
|
||||||
|
Dumbbell,
|
||||||
|
Plus,
|
||||||
|
Sparkles,
|
||||||
|
Target
|
||||||
|
} from 'lucide-react'
|
||||||
import { useAppStore } from '../store/appStore'
|
import { useAppStore } from '../store/appStore'
|
||||||
import { ExerciseEditor } from '../components/ExerciseEditor'
|
import { ExerciseEditor } from '../components/ExerciseEditor'
|
||||||
import {
|
import {
|
||||||
@@ -14,6 +21,7 @@ import { Icon } from '../lib/icon'
|
|||||||
import { formatInterval } from '../lib/format'
|
import { formatInterval } from '../lib/format'
|
||||||
import { useT } from '../i18n'
|
import { useT } from '../i18n'
|
||||||
import type { Exercise } from '@shared/types'
|
import type { Exercise } from '@shared/types'
|
||||||
|
import { EXERCISE_PRESETS, type ExercisePreset } from '../lib/wellness'
|
||||||
|
|
||||||
export default function Exercises(): JSX.Element {
|
export default function Exercises(): JSX.Element {
|
||||||
const exercises = useAppStore((s) => s.state?.exercises ?? [])
|
const exercises = useAppStore((s) => s.state?.exercises ?? [])
|
||||||
@@ -69,6 +77,17 @@ export default function Exercises(): JSX.Element {
|
|||||||
/>
|
/>
|
||||||
</InsightGrid>
|
</InsightGrid>
|
||||||
|
|
||||||
|
<SectionHeader title={t('exercises.presets.title')} />
|
||||||
|
<Card className="mb-6">
|
||||||
|
{EXERCISE_PRESETS.map((preset, index) => (
|
||||||
|
<PresetRow
|
||||||
|
key={preset.id}
|
||||||
|
preset={preset}
|
||||||
|
last={index === EXERCISE_PRESETS.length - 1}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Card>
|
||||||
|
|
||||||
{enabled.length > 0 && (
|
{enabled.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
@@ -147,6 +166,58 @@ export default function Exercises(): JSX.Element {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PresetRow({
|
||||||
|
preset,
|
||||||
|
last
|
||||||
|
}: {
|
||||||
|
preset: ExercisePreset
|
||||||
|
last: boolean
|
||||||
|
}): JSX.Element {
|
||||||
|
const { t } = useT()
|
||||||
|
const [busy, setBusy] = useState(false)
|
||||||
|
|
||||||
|
async function addPreset(): Promise<void> {
|
||||||
|
if (busy) return
|
||||||
|
setBusy(true)
|
||||||
|
try {
|
||||||
|
for (const exercise of preset.exercises) {
|
||||||
|
await window.api.addExercise(exercise)
|
||||||
|
}
|
||||||
|
for (const meal of preset.meals ?? []) {
|
||||||
|
await window.api.addMeal(meal)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setBusy(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Row last={last}>
|
||||||
|
<div className="w-9 h-9 rounded-lg bg-accent/12 text-accent grid place-items-center shrink-0">
|
||||||
|
<Sparkles size={18} strokeWidth={2.3} />
|
||||||
|
</div>
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<div className="text-[16px] font-semibold truncate leading-tight">
|
||||||
|
{t(preset.titleKey)}
|
||||||
|
</div>
|
||||||
|
<div className="text-[14px] text-text/65 mt-1 font-medium leading-snug">
|
||||||
|
{t(preset.descKey)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="sm"
|
||||||
|
variant="tinted"
|
||||||
|
onClick={addPreset}
|
||||||
|
disabled={busy}
|
||||||
|
>
|
||||||
|
<Plus size={14} strokeWidth={2.5} />
|
||||||
|
{t('exercises.presets.add')}
|
||||||
|
</Button>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function ExerciseRow({
|
function ExerciseRow({
|
||||||
exercise,
|
exercise,
|
||||||
last,
|
last,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
FolderOpen,
|
FolderOpen,
|
||||||
Languages,
|
Languages,
|
||||||
Palette,
|
Palette,
|
||||||
|
Power,
|
||||||
RefreshCw
|
RefreshCw
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useAppStore } from '../store/appStore'
|
import { useAppStore } from '../store/appStore'
|
||||||
@@ -18,11 +19,12 @@ import { ConfirmModal } from '../components/ui/ConfirmModal'
|
|||||||
import { Skeleton } from '../components/ui/Skeleton'
|
import { Skeleton } from '../components/ui/Skeleton'
|
||||||
import { Spinner } from '../components/ui/Spinner'
|
import { Spinner } from '../components/ui/Spinner'
|
||||||
import { RELEASE_NOTES } from '@shared/release-notes'
|
import { RELEASE_NOTES } from '@shared/release-notes'
|
||||||
import { translate, useT } from '../i18n'
|
import { translate, useT, type TFn } from '../i18n'
|
||||||
import type {
|
import type {
|
||||||
DiagnosticsInfo,
|
DiagnosticsInfo,
|
||||||
Language,
|
Language,
|
||||||
NotificationMode,
|
NotificationMode,
|
||||||
|
NotificationTone,
|
||||||
QuietHours,
|
QuietHours,
|
||||||
Settings as SettingsType,
|
Settings as SettingsType,
|
||||||
Theme
|
Theme
|
||||||
@@ -35,7 +37,7 @@ export default function SettingsPage(): JSX.Element {
|
|||||||
if (!settings)
|
if (!settings)
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="max-w-2xl mx-auto px-4 sm:px-6 lg:px-10 pt-8 pb-12 space-y-5"
|
className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-10 pt-8 pb-12 space-y-5"
|
||||||
role="status"
|
role="status"
|
||||||
aria-label={t('settings.loading')}
|
aria-label={t('settings.loading')}
|
||||||
>
|
>
|
||||||
@@ -52,8 +54,8 @@ export default function SettingsPage(): JSX.Element {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full overflow-y-auto">
|
<div className="h-full overflow-y-auto">
|
||||||
<div className="max-w-2xl mx-auto px-4 sm:px-6 lg:px-10 pt-8 pb-12">
|
<div className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-10 pt-8 pb-12">
|
||||||
<div className="mb-8">
|
<div className="mb-6">
|
||||||
<div className="text-[14px] text-text/65 font-semibold">
|
<div className="text-[14px] text-text/65 font-semibold">
|
||||||
{t('settings.kicker')}
|
{t('settings.kicker')}
|
||||||
</div>
|
</div>
|
||||||
@@ -62,6 +64,13 @@ export default function SettingsPage(): JSX.Element {
|
|||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SettingsStatusPanel
|
||||||
|
settings={settings}
|
||||||
|
onToggleGlobal={() =>
|
||||||
|
patch({ globalEnabled: !settings.globalEnabled })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<InsightGrid>
|
<InsightGrid>
|
||||||
<InsightCard
|
<InsightCard
|
||||||
icon={<Bell size={17} strokeWidth={2.5} />}
|
icon={<Bell size={17} strokeWidth={2.5} />}
|
||||||
@@ -86,7 +95,7 @@ export default function SettingsPage(): JSX.Element {
|
|||||||
/>
|
/>
|
||||||
</InsightGrid>
|
</InsightGrid>
|
||||||
|
|
||||||
<SectionHeader title={t('settings.section.language')} />
|
<SectionHeader title={t('settings.section.interface')} />
|
||||||
<Card className="mb-6">
|
<Card className="mb-6">
|
||||||
<SelectRow
|
<SelectRow
|
||||||
label={t('settings.language.label')}
|
label={t('settings.language.label')}
|
||||||
@@ -97,12 +106,29 @@ export default function SettingsPage(): JSX.Element {
|
|||||||
{ value: 'ru', label: t('settings.language.ru') },
|
{ value: 'ru', label: t('settings.language.ru') },
|
||||||
{ value: 'en', label: t('settings.language.en') }
|
{ value: 'en', label: t('settings.language.en') }
|
||||||
]}
|
]}
|
||||||
|
/>
|
||||||
|
<SelectRow
|
||||||
|
label={t('settings.theme.label')}
|
||||||
|
hint={t('settings.theme.hint')}
|
||||||
|
value={settings.theme}
|
||||||
|
onChange={(v) => patch({ theme: v as Theme })}
|
||||||
|
options={[
|
||||||
|
{ value: 'system', label: t('settings.theme.system') },
|
||||||
|
{ value: 'light', label: t('settings.theme.light') },
|
||||||
|
{ value: 'dark', label: t('settings.theme.dark') }
|
||||||
|
]}
|
||||||
last
|
last
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<SectionHeader title={t('settings.section.reminders')} />
|
<SectionHeader title={t('settings.section.reminders')} />
|
||||||
<Card className="mb-6">
|
<Card className="mb-6">
|
||||||
|
<ToggleRow
|
||||||
|
label={t('settings.global.label')}
|
||||||
|
hint={t('settings.global.hint')}
|
||||||
|
checked={settings.globalEnabled}
|
||||||
|
onChange={(v) => patch({ globalEnabled: v })}
|
||||||
|
/>
|
||||||
<SelectRow
|
<SelectRow
|
||||||
label={t('settings.notification_mode.label')}
|
label={t('settings.notification_mode.label')}
|
||||||
hint={t('settings.notification_mode.hint')}
|
hint={t('settings.notification_mode.hint')}
|
||||||
@@ -123,6 +149,30 @@ export default function SettingsPage(): JSX.Element {
|
|||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
<SelectRow
|
||||||
|
label={t('settings.notification_tone.label')}
|
||||||
|
hint={t('settings.notification_tone.hint')}
|
||||||
|
value={settings.notificationTone}
|
||||||
|
onChange={(v) => patch({ notificationTone: v as NotificationTone })}
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
value: 'calm',
|
||||||
|
label: t('settings.notification_tone.calm')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'brief',
|
||||||
|
label: t('settings.notification_tone.brief')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'firm',
|
||||||
|
label: t('settings.notification_tone.firm')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'playful',
|
||||||
|
label: t('settings.notification_tone.playful')
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
/>
|
||||||
<ToggleRow
|
<ToggleRow
|
||||||
label={t('settings.sound.label')}
|
label={t('settings.sound.label')}
|
||||||
hint={t('settings.sound.hint')}
|
hint={t('settings.sound.hint')}
|
||||||
@@ -204,22 +254,6 @@ export default function SettingsPage(): JSX.Element {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<SectionHeader title={t('settings.section.appearance')} />
|
|
||||||
<Card className="mb-6">
|
|
||||||
<SelectRow
|
|
||||||
label={t('settings.theme.label')}
|
|
||||||
hint={t('settings.theme.hint')}
|
|
||||||
value={settings.theme}
|
|
||||||
onChange={(v) => patch({ theme: v as Theme })}
|
|
||||||
options={[
|
|
||||||
{ value: 'system', label: t('settings.theme.system') },
|
|
||||||
{ value: 'light', label: t('settings.theme.light') },
|
|
||||||
{ value: 'dark', label: t('settings.theme.dark') }
|
|
||||||
]}
|
|
||||||
last
|
|
||||||
/>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<SectionHeader title={t('settings.section.updates')} />
|
<SectionHeader title={t('settings.section.updates')} />
|
||||||
<UpdaterCard />
|
<UpdaterCard />
|
||||||
|
|
||||||
@@ -242,6 +276,135 @@ export default function SettingsPage(): JSX.Element {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SettingsStatusPanel({
|
||||||
|
settings,
|
||||||
|
onToggleGlobal
|
||||||
|
}: {
|
||||||
|
settings: SettingsType
|
||||||
|
onToggleGlobal: () => void
|
||||||
|
}): JSX.Element {
|
||||||
|
const { t } = useT()
|
||||||
|
return (
|
||||||
|
<section className="mb-6 rounded-3xl bg-surface p-5 shadow-card dark:ring-0.5 dark:ring-hairline/30">
|
||||||
|
<div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4">
|
||||||
|
<div className="flex items-start gap-3 min-w-0">
|
||||||
|
<div
|
||||||
|
className={[
|
||||||
|
'w-11 h-11 rounded-2xl grid place-items-center text-white shrink-0',
|
||||||
|
settings.globalEnabled ? 'bg-success' : 'bg-warning'
|
||||||
|
].join(' ')}
|
||||||
|
>
|
||||||
|
<Power size={20} strokeWidth={2.5} />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0 flex-1">
|
||||||
|
<div className="text-[13px] uppercase tracking-[0.06em] text-text/50 font-bold">
|
||||||
|
{t('settings.status.kicker')}
|
||||||
|
</div>
|
||||||
|
<h2 className="font-display text-[22px] font-bold leading-tight mt-1">
|
||||||
|
{settings.globalEnabled
|
||||||
|
? t('settings.status.title.on')
|
||||||
|
: t('settings.status.title.off')}
|
||||||
|
</h2>
|
||||||
|
<p className="text-[14px] text-text/62 mt-1 leading-relaxed max-w-xl break-words">
|
||||||
|
{settingsStatusHint(settings, t)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant={settings.globalEnabled ? 'tinted' : 'filled'}
|
||||||
|
onClick={onToggleGlobal}
|
||||||
|
className="self-start sm:self-auto"
|
||||||
|
>
|
||||||
|
{settings.globalEnabled ? t('btn.pause') : t('btn.start')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-5 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-2">
|
||||||
|
<StatusPill
|
||||||
|
label={t('settings.status.reminders')}
|
||||||
|
value={
|
||||||
|
settings.globalEnabled
|
||||||
|
? t('settings.status.on')
|
||||||
|
: t('settings.status.off')
|
||||||
|
}
|
||||||
|
active={settings.globalEnabled}
|
||||||
|
/>
|
||||||
|
<StatusPill
|
||||||
|
label={t('settings.status.quiet')}
|
||||||
|
value={
|
||||||
|
settings.quietHours.enabled
|
||||||
|
? `${settings.quietHours.from}-${settings.quietHours.to}`
|
||||||
|
: t('settings.status.off')
|
||||||
|
}
|
||||||
|
active={settings.quietHours.enabled}
|
||||||
|
tone="info"
|
||||||
|
/>
|
||||||
|
<StatusPill
|
||||||
|
label={t('settings.status.meetings')}
|
||||||
|
value={
|
||||||
|
settings.meetingAutoPause
|
||||||
|
? t('settings.status.on')
|
||||||
|
: t('settings.status.off')
|
||||||
|
}
|
||||||
|
active={settings.meetingAutoPause}
|
||||||
|
tone="info"
|
||||||
|
/>
|
||||||
|
<StatusPill
|
||||||
|
label={t('settings.status.autostart')}
|
||||||
|
value={
|
||||||
|
settings.startWithWindows
|
||||||
|
? t('settings.status.on')
|
||||||
|
: t('settings.status.off')
|
||||||
|
}
|
||||||
|
active={settings.startWithWindows}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function StatusPill({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
active,
|
||||||
|
tone = 'success'
|
||||||
|
}: {
|
||||||
|
label: string
|
||||||
|
value: string
|
||||||
|
active: boolean
|
||||||
|
tone?: 'success' | 'info'
|
||||||
|
}): JSX.Element {
|
||||||
|
const activeClass = tone === 'info' ? 'text-info' : 'text-success'
|
||||||
|
return (
|
||||||
|
<div className="rounded-2xl bg-surface-2 px-3.5 py-3 min-w-0">
|
||||||
|
<div className="text-[12px] text-text/50 font-semibold leading-tight">
|
||||||
|
{label}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={[
|
||||||
|
'mt-1 text-[14px] font-bold leading-tight break-words',
|
||||||
|
active ? activeClass : 'text-text/55'
|
||||||
|
].join(' ')}
|
||||||
|
>
|
||||||
|
{value}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function settingsStatusHint(settings: SettingsType, t: TFn): string {
|
||||||
|
if (!settings.globalEnabled) return t('settings.status.hint.paused')
|
||||||
|
if (settings.quietHours.enabled) {
|
||||||
|
return t('settings.status.hint.quiet', {
|
||||||
|
from: settings.quietHours.from,
|
||||||
|
to: settings.quietHours.to
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!settings.startWithWindows) return t('settings.status.hint.autostart')
|
||||||
|
return t('settings.status.hint.ready')
|
||||||
|
}
|
||||||
|
|
||||||
function DiagnosticsCard(): JSX.Element {
|
function DiagnosticsCard(): JSX.Element {
|
||||||
const { t, lang } = useT()
|
const { t, lang } = useT()
|
||||||
const [info, setInfo] = useState<DiagnosticsInfo | null>(null)
|
const [info, setInfo] = useState<DiagnosticsInfo | null>(null)
|
||||||
|
|||||||
@@ -21,6 +21,168 @@ export type ReleaseNoteItem = {
|
|||||||
export type ReleaseNotes = Record<Language, ReleaseNoteItem[]>
|
export type ReleaseNotes = Record<Language, ReleaseNoteItem[]>
|
||||||
|
|
||||||
export const RELEASE_NOTES: Record<string, ReleaseNotes> = {
|
export const RELEASE_NOTES: Record<string, ReleaseNotes> = {
|
||||||
|
'0.8.0': {
|
||||||
|
ru: [
|
||||||
|
{
|
||||||
|
title: 'Добавлен помощник дня',
|
||||||
|
detail:
|
||||||
|
'Обзор теперь показывает советы по пропускам, питанию, вечерним провалам и текущему ритму.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Появились быстрые пресеты',
|
||||||
|
detail:
|
||||||
|
'Офисная разминка, спина и шея, минимум на день и набор после катки добавляются одним кликом.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Короткие разминка-сессии',
|
||||||
|
detail:
|
||||||
|
'На главном экране можно запустить 3, 5 или 10 минут и записать подходы в историю.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Неделя в цифрах',
|
||||||
|
detail:
|
||||||
|
'Добавлена компактная аналитика: дни активности, повторы, закрываемость, пропуски и лучший день.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Dota-долг стал мягче',
|
||||||
|
detail:
|
||||||
|
'Большой долг после матча теперь предлагается разбивать на подходы: сколько сейчас и сколько позже.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Тон напоминаний',
|
||||||
|
detail:
|
||||||
|
'В настройках можно выбрать спокойные, краткие, настойчивые или более игровые формулировки.',
|
||||||
|
tag: 'new'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
en: [
|
||||||
|
{
|
||||||
|
title: 'Added a day assistant',
|
||||||
|
detail:
|
||||||
|
'Overview now shows suggestions for skips, meals, evening slumps and current rhythm.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Fast presets are here',
|
||||||
|
detail:
|
||||||
|
'Office warm-up, back and neck, daily minimum and after-match sets can be added in one click.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Short warm-up sessions',
|
||||||
|
detail:
|
||||||
|
'Run 3, 5 or 10 minutes from Overview and log the selected actions into history.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Week in numbers',
|
||||||
|
detail:
|
||||||
|
'Compact analytics now show active days, reps, completion, skips and best day.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Game debt is easier to close',
|
||||||
|
detail:
|
||||||
|
'Large Dota match debt now suggests sets: how much to do now and how much can wait.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Reminder tone',
|
||||||
|
detail:
|
||||||
|
'Settings can switch reminder wording between calm, brief, firm and playful.',
|
||||||
|
tag: 'new'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'0.7.1': {
|
||||||
|
ru: [
|
||||||
|
{
|
||||||
|
title: 'Вернули последний удачный дизайн',
|
||||||
|
detail:
|
||||||
|
'Редизайн 0.7.0 откатан: интерфейс снова выглядит как сохраненная версия “последнее-удачное”.',
|
||||||
|
tag: 'fix'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Откат придет через автообновление',
|
||||||
|
detail:
|
||||||
|
'Версия 0.7.1 опубликована как обычный релиз, чтобы установленная 0.7.0 сама вернулась к старому виду.',
|
||||||
|
tag: 'fix'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
en: [
|
||||||
|
{
|
||||||
|
title: 'Restored the last good design',
|
||||||
|
detail:
|
||||||
|
'The 0.7.0 redesign was rolled back: the UI is back to the saved last-good version.',
|
||||||
|
tag: 'fix'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Rollback ships through auto-update',
|
||||||
|
detail:
|
||||||
|
'Version 0.7.1 is a normal release so installed 0.7.0 copies can return to the old look automatically.',
|
||||||
|
tag: 'fix'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'0.6.6': {
|
||||||
|
ru: [
|
||||||
|
{
|
||||||
|
title: 'Настройки стали панелью состояния',
|
||||||
|
detail:
|
||||||
|
'Сверху видно, работают ли напоминания, включены ли тихие часы, встречи и запуск вместе с Windows.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Главный экран стал точнее по текстам',
|
||||||
|
detail:
|
||||||
|
'Дата больше не кричит заглавными буквами, а цели показывают понятные единицы: “осталось 30 раз”.',
|
||||||
|
tag: 'fix'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Сводные карточки читаются лучше',
|
||||||
|
detail:
|
||||||
|
'Длинные значения в карточках больше не обрезаются, а сетка спокойнее держит десктопные ширины.',
|
||||||
|
tag: 'fix'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Безопасный стенд для проверки интерфейса',
|
||||||
|
detail:
|
||||||
|
'Добавлен dev:renderer: можно открыть UI в браузере с демо-данными и не трогать реальные настройки.',
|
||||||
|
tag: 'new'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
en: [
|
||||||
|
{
|
||||||
|
title: 'Settings now show app status first',
|
||||||
|
detail:
|
||||||
|
'The top panel shows whether reminders, quiet hours, meeting pause and Windows autostart are active.',
|
||||||
|
tag: 'new'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Overview copy is clearer',
|
||||||
|
detail:
|
||||||
|
'The date no longer gets artificial capitalization, and goals show units like “30 reps left”.',
|
||||||
|
tag: 'fix'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Summary cards are easier to read',
|
||||||
|
detail:
|
||||||
|
'Long values no longer get clipped, and the card grid behaves better on desktop widths.',
|
||||||
|
tag: 'fix'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Safe renderer preview for UI checks',
|
||||||
|
detail:
|
||||||
|
'Added dev:renderer so the UI can be opened with demo data without touching real settings.',
|
||||||
|
tag: 'new'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
'0.6.5': {
|
'0.6.5': {
|
||||||
ru: [
|
ru: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export const MEAL_PRESETS: MealPreset[] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export type NotificationMode = 'toast' | 'modal' | 'both'
|
export type NotificationMode = 'toast' | 'modal' | 'both'
|
||||||
|
export type NotificationTone = 'calm' | 'brief' | 'firm' | 'playful'
|
||||||
export type Theme = 'light' | 'dark' | 'system'
|
export type Theme = 'light' | 'dark' | 'system'
|
||||||
export type Language = 'ru' | 'en'
|
export type Language = 'ru' | 'en'
|
||||||
|
|
||||||
@@ -96,6 +97,7 @@ export type QuietHours = {
|
|||||||
export type Settings = {
|
export type Settings = {
|
||||||
globalEnabled: boolean
|
globalEnabled: boolean
|
||||||
notificationMode: NotificationMode
|
notificationMode: NotificationMode
|
||||||
|
notificationTone: NotificationTone
|
||||||
soundEnabled: boolean
|
soundEnabled: boolean
|
||||||
/**
|
/**
|
||||||
* TTS голос диктора в окне напоминания: «Время приседать. Десять раз».
|
* TTS голос диктора в окне напоминания: «Время приседать. Десять раз».
|
||||||
@@ -280,6 +282,7 @@ export type MatchSummary = {
|
|||||||
export const DEFAULT_SETTINGS: Settings = {
|
export const DEFAULT_SETTINGS: Settings = {
|
||||||
globalEnabled: true,
|
globalEnabled: true,
|
||||||
notificationMode: 'modal',
|
notificationMode: 'modal',
|
||||||
|
notificationTone: 'calm',
|
||||||
soundEnabled: true,
|
soundEnabled: true,
|
||||||
voicePromptsEnabled: false, // opt-in — на работе с коллегами может смущать
|
voicePromptsEnabled: false, // opt-in — на работе с коллегами может смущать
|
||||||
meetingAutoPause: true,
|
meetingAutoPause: true,
|
||||||
|
|||||||
19
vite.renderer.config.mjs
Normal file
19
vite.renderer.config.mjs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { resolve } from 'node:path'
|
||||||
|
import react from '@vitejs/plugin-react'
|
||||||
|
import { defineConfig } from 'vite'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
root: resolve('src/renderer'),
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@renderer': resolve('src/renderer/src'),
|
||||||
|
'@shared': resolve('src/shared')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
host: '127.0.0.1',
|
||||||
|
port: 5173,
|
||||||
|
strictPort: true
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user