feat(ui): show current commit version and date in admin sidebar
This commit is contained in:
@@ -27,5 +27,8 @@ Thumbs.db
|
||||
# --- Playwright test artifacts ---
|
||||
.playwright-mcp/
|
||||
|
||||
# --- Generated version data ---
|
||||
public/version.json
|
||||
|
||||
# --- Internal audit (not for commit) ---
|
||||
SECURITY_AUDIT.md
|
||||
|
||||
@@ -29,6 +29,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b
|
||||
.sidebar nav a.active svg{color:var(--accent)}
|
||||
.sidebar .bottom a[data-nav=home] svg{color:#2563eb}
|
||||
.sidebar .bottom{padding:12px 20px;border-top:1px solid var(--border)}
|
||||
.sidebar .version{color:var(--muted);font-size:.72rem;padding:0 20px 8px}
|
||||
.sidebar .bottom a{display:flex;align-items:center;gap:10px;color:var(--muted);text-decoration:none;font-size:.8rem;padding:6px 0}
|
||||
.sidebar .bottom a:hover{color:var(--text)}
|
||||
.sidebar .bottom .logout{color:#ef4444;cursor:pointer;margin-top:4px}
|
||||
|
||||
@@ -77,10 +77,26 @@ function buildSidebar(active) {
|
||||
${nav.map(n => `<a href="${n.page}.html" data-nav="${n.page}" class="${n.page === active ? 'active' : ''}"><i data-lucide="${n.icon}"></i>${n.label}</a>`).join('')}
|
||||
</nav>
|
||||
<div class="bottom">
|
||||
<div class="version" id="sidebarVersion"></div>
|
||||
<a href="/" data-nav="home"><i data-lucide="home"></i>На главную</a>
|
||||
<a class="logout" href="#" data-action="logout"><i data-lucide="log-out"></i>Выйти</a>
|
||||
</div>`;
|
||||
renderIcons();
|
||||
loadVersion();
|
||||
}
|
||||
|
||||
async function loadVersion() {
|
||||
const el = document.getElementById('sidebarVersion');
|
||||
if (!el) return;
|
||||
try {
|
||||
const res = await fetch(`${API}/version.json?t=${Date.now()}`);
|
||||
if (!res.ok) { el.textContent = ''; return; }
|
||||
const v = await res.json();
|
||||
if (!v.short) { el.textContent = ''; return; }
|
||||
const d = (v.date || '').slice(0, 10);
|
||||
el.textContent = `v${v.short}${d ? ' · ' + d : ''}`;
|
||||
el.title = `${v.short} · ${v.date || ''}`;
|
||||
} catch { el.textContent = ''; }
|
||||
}
|
||||
|
||||
// --- Common UI ---
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function sh(cmd) {
|
||||
try { return execSync(cmd, { encoding: 'utf8' }).trim(); } catch { return ''; }
|
||||
}
|
||||
|
||||
const out = {
|
||||
full: sh('git rev-parse HEAD'),
|
||||
short: sh('git rev-parse --short HEAD'),
|
||||
date: sh('git log -1 --format=%cI')
|
||||
};
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, '..', 'public', 'version.json'),
|
||||
JSON.stringify(out, null, 2)
|
||||
);
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
node "$ROOT/scripts/gen-version.js"
|
||||
Reference in New Issue
Block a user