feat: тёмная тема (переключатель + системное предпочтение) + версия UI из единого источника
Тёмная тема по Ководству: тёплый «не-чёрный» фон, «не-белый» текст, подсвеченный акцент; переключатель ☾/☀ в шапке, выбор сохраняется в localStorage, по умолчанию — системное предпочтение, без мигания (FOUC-скрипт в <head>). Светлые правила не тронуты — тёмная добавлена аддитивно через :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) <noreply@anthropic.com>
This commit is contained in:
@@ -171,6 +171,10 @@ app.mount("/static", StaticFiles(directory="static"), name="static")
|
|||||||
MAX_UPLOAD_SIZE = 100 * 1024 * 1024 # 100 MB
|
MAX_UPLOAD_SIZE = 100 * 1024 * 1024 # 100 MB
|
||||||
MAX_MESSAGE_LEN = 10_000
|
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: path → action name mapping
|
||||||
_AUDIT_MAP = [
|
_AUDIT_MAP = [
|
||||||
("POST", "/api/login", "login"),
|
("POST", "/api/login", "login"),
|
||||||
@@ -300,6 +304,12 @@ async def index():
|
|||||||
return Path("static/chat.html").read_text(encoding="utf-8")
|
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;
|
# 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.
|
# the finished file lands in the work dir exactly like legacy /api/upload.
|
||||||
TUS_MAX_SIZE = 3 * 1024 * 1024 * 1024 # 3 GB
|
TUS_MAX_SIZE = 3 * 1024 * 1024 * 1024 # 3 GB
|
||||||
|
|||||||
+6
-1
@@ -48,7 +48,7 @@ a { color: var(--accent); text-decoration: none; }
|
|||||||
<a href="#audit" onclick="return showPage('audit')">Журнал</a>
|
<a href="#audit" onclick="return showPage('audit')">Журнал</a>
|
||||||
<a href="#files" onclick="return showPage('files')">Файлы</a>
|
<a href="#files" onclick="return showPage('files')">Файлы</a>
|
||||||
<a href="/" class="back">← Вернуться в чат</a>
|
<a href="/" class="back">← Вернуться в чат</a>
|
||||||
<div style="position:absolute;bottom:.5rem;left:1rem;font-size:.65rem;color:#999">v.2026-05-06g</div>
|
<div class="app-version" style="position:absolute;bottom:.5rem;left:1rem;font-size:.65rem;color:#999"></div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="main">
|
<div class="main">
|
||||||
@@ -388,6 +388,11 @@ fetch('/api/admin/sessions', {headers: H}).then(r=>r.json()).then(sessions => {
|
|||||||
table.appendChild(tr);
|
table.appendChild(tr);
|
||||||
}
|
}
|
||||||
}).catch(()=>{});
|
}).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(()=>{});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+67
-1
@@ -151,7 +151,54 @@ button { font-family: inherit; }
|
|||||||
#sidebar-toggle { display: inline-block; }
|
#sidebar-toggle { display: inline-block; }
|
||||||
.sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 55; }
|
.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; }
|
||||||
</style>
|
</style>
|
||||||
|
<script>
|
||||||
|
/* Тема ДО первой отрисовки — без мигания (FOUC).
|
||||||
|
Приоритет: сохранённый выбор → системное предпочтение → светлая. */
|
||||||
|
(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) {}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -196,6 +243,7 @@ button { font-family: inherit; }
|
|||||||
<button onclick="window.open('/reference','_blank')">Справочники</button>
|
<button onclick="window.open('/reference','_blank')">Справочники</button>
|
||||||
<button onclick="window.open('/check','_blank')">Проверка</button>
|
<button onclick="window.open('/check','_blank')">Проверка</button>
|
||||||
-->
|
-->
|
||||||
|
<button id="theme-toggle" onclick="toggleTheme()" title="Светлая / тёмная тема" aria-label="Переключить тему">☾</button>
|
||||||
<button onclick="newChat()">Новый диалог</button>
|
<button onclick="newChat()">Новый диалог</button>
|
||||||
<button onclick="listFiles()">Файлы</button>
|
<button onclick="listFiles()">Файлы</button>
|
||||||
<button onclick="logout()">Выйти</button>
|
<button onclick="logout()">Выйти</button>
|
||||||
@@ -214,7 +262,7 @@ button { font-family: inherit; }
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="file" id="file-input" multiple hidden onchange="handleFiles(this.files)">
|
<input type="file" id="file-input" multiple hidden onchange="handleFiles(this.files)">
|
||||||
<div style="text-align:center;margin-top:4px"><a href="/static/security.html" target="_blank" style="font-size:.65rem;color:var(--text-muted);opacity:.4;text-decoration:none">О безопасности сервиса</a></div>
|
<div style="text-align:center;margin-top:4px"><a href="/static/security.html" target="_blank" style="font-size:.65rem;color:var(--text-muted);opacity:.4;text-decoration:none">О безопасности сервиса</a><span class="app-version" style="font-size:.65rem;color:var(--text-muted);opacity:.4;margin-left:.6rem"></span></div>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /.main-col -->
|
</div><!-- /.main-col -->
|
||||||
</div><!-- /.app-layout -->
|
</div><!-- /.app-layout -->
|
||||||
@@ -228,6 +276,24 @@ if (typeof marked !== 'undefined') {
|
|||||||
marked.setOptions({ breaks: true, gfm: true });
|
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) {
|
function renderMarkdown(text) {
|
||||||
if (typeof marked !== 'undefined') {
|
if (typeof marked !== 'undefined') {
|
||||||
try { return marked.parse(text); } catch(e) {}
|
try { return marked.parse(text); } catch(e) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user