From ed913b291882e6463b1c6a4d8cd24f065ea4a7bc Mon Sep 17 00:00:00 2001 From: anor Date: Wed, 10 Jun 2026 01:40:58 +1000 Subject: [PATCH] =?UTF-8?q?feat:=20=D1=82=D1=91=D0=BC=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BC=D0=B0=20(=D0=BF=D0=B5=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=20+=20=D1=81?= =?UTF-8?q?=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=BD=D0=BE=D0=B5=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=BF=D0=BE=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D0=B5)?= =?UTF-8?q?=20+=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=20UI=20=D0=B8=D0=B7?= =?UTF-8?q?=20=D0=B5=D0=B4=D0=B8=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B8=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Тёмная тема по Ководству: тёплый «не-чёрный» фон, «не-белый» текст, подсвеченный акцент; переключатель ☾/☀ в шапке, выбор сохраняется в localStorage, по умолчанию — системное предпочтение, без мигания (FOUC-скрипт в ). Светлые правила не тронуты — тёмная добавлена аддитивно через :root[data-theme=dark]. Версия UI вынесена в единый источник main.py APP_VERSION (+ GET /api/version), фронт штампует .app-version на chat.html и admin.html — бамп = одна строка. Бамп до v.2026-06-10a. Co-Authored-By: Claude Opus 4.8 (1M context) --- main.py | 10 +++++++ static/admin.html | 7 ++++- static/chat.html | 68 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 67cae4a..1e1d949 100644 --- a/main.py +++ b/main.py @@ -171,6 +171,10 @@ app.mount("/static", StaticFiles(directory="static"), name="static") MAX_UPLOAD_SIZE = 100 * 1024 * 1024 # 100 MB MAX_MESSAGE_LEN = 10_000 +# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква). +# Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version). +APP_VERSION = "2026-06-10a" + # Audit: path → action name mapping _AUDIT_MAP = [ ("POST", "/api/login", "login"), @@ -300,6 +304,12 @@ async def index(): return Path("static/chat.html").read_text(encoding="utf-8") +@app.get("/api/version") +async def version(): + """Public — single source of UI version (stamped into .app-version on the front).""" + return {"version": APP_VERSION} + + # Resumable uploads (tus 1.0.0). Same-process, reuses auth + per-user work dir; # the finished file lands in the work dir exactly like legacy /api/upload. TUS_MAX_SIZE = 3 * 1024 * 1024 * 1024 # 3 GB diff --git a/static/admin.html b/static/admin.html index 84f2749..a7a38f2 100644 --- a/static/admin.html +++ b/static/admin.html @@ -48,7 +48,7 @@ a { color: var(--accent); text-decoration: none; } Журнал Файлы ← Вернуться в чат -
v.2026-05-06g
+
@@ -388,6 +388,11 @@ fetch('/api/admin/sessions', {headers: H}).then(r=>r.json()).then(sessions => { table.appendChild(tr); } }).catch(()=>{}); + +// Версия UI — единый источник (main.py APP_VERSION → /api/version) +fetch('/api/version').then(r=>r.json()).then(d=>{ + document.querySelectorAll('.app-version').forEach(e=>e.textContent='v.'+d.version); +}).catch(()=>{}); diff --git a/static/chat.html b/static/chat.html index 0c52dfc..a7623a9 100644 --- a/static/chat.html +++ b/static/chat.html @@ -151,7 +151,54 @@ button { font-family: inherit; } #sidebar-toggle { display: inline-block; } .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 55; } } + +/* ===== Тёмная тема (Ководство: тёплый «не-чёрный» фон, «не-белый» текст, */ +/* акцент чуть подсвечен для контраста; переключатель + системное предпочтение) ===== */ +html { color-scheme: light; } +:root[data-theme="dark"] { + color-scheme: dark; + --bg: #16140f; --bg-card: #211d17; --bg-input: #262019; --bg-sunken: #1b1813; + --text: #ece4d7; --text-muted: #a89c8a; --text-light: #7d7263; + --border: #3a332a; --border-light: #2a251e; + --accent: #d9695c; --accent-hover: #e58074; --accent-active: #c2564a; --accent-light: rgba(217,105,92,.16); + --user-bg: #39322a; --user-text: #f2ece2; + --ai-bg: #211d17; --ai-border: #2f2820; + --file-bg: #211d17; --file-border: #3a332a; + --error-bg: #3a1f1d; --error-border: #5e2b27; + --system-bg: #211d17; --system-text: #a89c8a; + --ok: #3fa066; --ok-hover: #4cb074; + --shadow-sm: 0 1px 2px rgba(0,0,0,.4); + --shadow-md: 0 10px 30px rgba(0,0,0,.55); + --focus-ring: 0 0 0 3px rgba(217,105,92,.42); +} +/* Места с захардкоженным цветом — переопределяем только в тёмной (light не трогаем) */ +:root[data-theme="dark"] #login-screen { background: linear-gradient(135deg, #1b1813 0%, #131009 100%); } +:root[data-theme="dark"] #login-error, +:root[data-theme="dark"] .msg-error { color: #ff8585; } +:root[data-theme="dark"] .msg-tool { background: #2a2410; border-color: #4a3f1a; color: #ecc879; } +:root[data-theme="dark"] .msg-file a { color: #5fc27e; } +:root[data-theme="dark"] .file-badge { background: #2a2620; color: #ece4d7; } +:root[data-theme="dark"] .file-badge .remove { color: #ff8585; } +:root[data-theme="dark"] .copy-btn.copied { background: #1e3a25; border-color: #2f6b40; color: #86dca0; } +:root[data-theme="dark"] .msg-ai code { background: #2a2620; color: #ece4d7; } +:root[data-theme="dark"] .msg-ai pre { background: #0e0c09; color: #ece4d7; } +:root[data-theme="dark"] .msg-ai tbody tr:nth-child(even) { background: rgba(255,255,255,.045); } +:root[data-theme="dark"] #input-area { box-shadow: 0 -2px 10px rgba(0,0,0,.35); } +#theme-toggle { font-size: .95rem; line-height: 1; padding: .38rem .62rem; } + @@ -196,6 +243,7 @@ button { font-family: inherit; } --> + @@ -214,7 +262,7 @@ button { font-family: inherit; }
-
О безопасности сервиса
+
О безопасности сервиса
@@ -228,6 +276,24 @@ if (typeof marked !== 'undefined') { marked.setOptions({ breaks: true, gfm: true }); } +// --- Тема (светлая/тёмная) --- +function applyThemeIcon() { + var b = document.getElementById('theme-toggle'); + if (b) b.textContent = document.documentElement.getAttribute('data-theme') === 'dark' ? '☀' : '☾'; +} +function toggleTheme() { + var next = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'; + document.documentElement.setAttribute('data-theme', next); + try { localStorage.setItem('theme', next); } catch (e) {} + applyThemeIcon(); +} +applyThemeIcon(); + +// --- Версия UI из единого источника (main.py APP_VERSION → /api/version) --- +fetch('/api/version').then(function (r) { return r.json(); }).then(function (d) { + document.querySelectorAll('.app-version').forEach(function (el) { el.textContent = 'v.' + d.version; }); +}).catch(function () {}); + function renderMarkdown(text) { if (typeof marked !== 'undefined') { try { return marked.parse(text); } catch(e) {}