fix(register): капча подстраивается под тему (dark/light) + перерисовка при переключении
Yandex SmartCaptcha рендерилась без theme → белый виджет на тёмной теме (скрин Юрия). Теперь theme = data-theme страницы; при toggleTheme капча destroy+render заново с новой темой. bump 2026-07-23j. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -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; добавлено согласие на обработку данных"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
+16
-4
@@ -38,7 +38,7 @@ html { color-scheme: light; }
|
||||
</style>
|
||||
<script>
|
||||
(function(){try{var t=localStorage.getItem('theme');if(t!=='dark'&&t!=='light'){t=(window.matchMedia&&matchMedia('(prefers-color-scheme: dark)').matches)?'dark':'light';}document.documentElement.setAttribute('data-theme',t);}catch(e){}})();
|
||||
function toggleTheme(){var n=document.documentElement.getAttribute('data-theme')==='dark'?'light':'dark';document.documentElement.setAttribute('data-theme',n);try{localStorage.setItem('theme',n);}catch(e){}applyThemeIcon();}
|
||||
function toggleTheme(){var n=document.documentElement.getAttribute('data-theme')==='dark'?'light':'dark';document.documentElement.setAttribute('data-theme',n);try{localStorage.setItem('theme',n);}catch(e){}applyThemeIcon();if(typeof renderCaptcha==='function')renderCaptcha();}
|
||||
function applyThemeIcon(){var b=document.getElementById('theme-fab');if(b)b.textContent=document.documentElement.getAttribute('data-theme')==='dark'?'☀':'☾';}
|
||||
document.addEventListener('DOMContentLoaded',applyThemeIcon);
|
||||
</script>
|
||||
@@ -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(() => {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user