From 2fc8955e855470bccf2c46e275015625d8dd0037 Mon Sep 17 00:00:00 2001 From: anor Date: Thu, 23 Jul 2026 20:05:15 +1000 Subject: [PATCH] =?UTF-8?q?fix(register):=20=D0=BA=D0=B0=D0=BF=D1=87=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D1=81=D1=82=D1=80=D0=B0=D0=B8=D0=B2=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=8F=20=D0=BF=D0=BE=D0=B4=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BC=D1=83=20(dark/light)=20+=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Yandex SmartCaptcha рендерилась без theme → белый виджет на тёмной теме (скрин Юрия). Теперь theme = data-theme страницы; при toggleTheme капча destroy+render заново с новой темой. bump 2026-07-23j. Co-Authored-By: Claude Opus 4.8 --- main.py | 2 +- static/changelog.json | 15 +++++++-------- static/register.html | 20 ++++++++++++++++---- 3 files changed, 24 insertions(+), 13 deletions(-) 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(() => {});