diff --git a/main.py b/main.py index b310483..0ac0998 100644 --- a/main.py +++ b/main.py @@ -207,7 +207,7 @@ MAX_MESSAGE_LEN = 10_000 # ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква). # Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version). -APP_VERSION = "2026-07-23i" +APP_VERSION = "2026-07-23j" # Audit: path → action name mapping _AUDIT_MAP = [ diff --git a/static/changelog.json b/static/changelog.json index a2e82d1..1d81037 100644 --- a/static/changelog.json +++ b/static/changelog.json @@ -1,4 +1,11 @@ [ + { + "version": "2026-07-23j", + "date": "2026-07-23", + "changes": [ + "Капча на регистрации подстраивается под тёмную/светлую тему" + ] + }, { "version": "2026-07-23i", "date": "2026-07-23", @@ -27,13 +34,5 @@ "changes": [ "Открытая регистрация — ссылка-приглашение больше не требуется" ] - }, - { - "version": "2026-07-23e", - "date": "2026-07-23", - "changes": [ - "На вопрос про индекс пересчёта ассистент сразу отвечает числом со ссылкой на письмо Минстроя", - "При регистрации можно указать телефон/Telegram; добавлено согласие на обработку данных" - ] } ] diff --git a/static/register.html b/static/register.html index 4d3777f..6363ace 100644 --- a/static/register.html +++ b/static/register.html @@ -38,7 +38,7 @@ html { color-scheme: light; } @@ -100,14 +100,26 @@ let regTelegram = ''; // SmartCaptcha (Ф4): виджет рендерится ТОЛЬКО если сервер отдал sitekey // (иначе капча выключена и блок пуст — поведение как раньше). let captchaWidgetId = null; +let captchaSitekey = null; +// Тема капчи = тема страницы (data-theme). Перерисовываем при переключении темы, +// иначе Yandex-виджет остаётся светлым на тёмной теме (баг 2026-07-23). +function _captchaTheme() { + return document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'; +} +function renderCaptcha() { + if (!captchaSitekey || !window.smartCaptcha) return; + if (captchaWidgetId !== null) { try { window.smartCaptcha.destroy(captchaWidgetId); } catch (e) {} } + document.getElementById('captcha-container').innerHTML = ''; + captchaWidgetId = window.smartCaptcha.render('captcha-container', + {sitekey: captchaSitekey, theme: _captchaTheme()}); +} fetch('/api/captcha-config').then(r => r.json()).then(cfg => { if (!cfg.sitekey) return; + captchaSitekey = cfg.sitekey; const s = document.createElement('script'); s.src = 'https://smartcaptcha.yandexcloud.net/captcha.js?render=onload&onload=onCaptchaReady'; s.defer = true; - window.onCaptchaReady = () => { - captchaWidgetId = window.smartCaptcha.render('captcha-container', {sitekey: cfg.sitekey}); - }; + window.onCaptchaReady = renderCaptcha; document.head.appendChild(s); }).catch(() => {});