fix(админка): свежие файлы без ручной чистки кеша, скелетон вместо «Загрузки»

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
anor
2026-11-10 01:26:08 +10:00
co-authored by Claude Code
parent 40dcb44a7c
commit 55aca56b3f
12 changed files with 92 additions and 10 deletions
+9
View File
@@ -18,6 +18,7 @@ const TITLES = {
};
const App = () => {
const [section, setSection] = useState(sectionFromPath(location.pathname));
const [version, setVersion] = useState('');
const firstRender = useRef(true);
const [title, subtitle] = TITLES[section]
|| [SECTIONS.find(([key]) => key === section)?.[1] || 'Раздел', ''];
@@ -29,6 +30,13 @@ const App = () => {
return () => window.removeEventListener('popstate', onPop);
}, []);
// Версия видна в меню: по ней человек понимает, что браузер взял свежий файл,
// а не старую копию из кеша.
useEffect(() => {
fetch('/api/version').then((r) => r.json())
.then((d) => setVersion(d.version || '')).catch(() => {});
}, []);
// Заголовок вкладки и фокус на заголовок раздела — только при переходе, не при
// первой загрузке: иначе фокус отбирается у адресной строки на пустом месте.
useEffect(() => {
@@ -60,6 +68,7 @@ const App = () => {
<a key=${key} href=${href} onClick=${(e) => go(e, href)}
class=${'nav-link' + (key === section ? ' active' : '')}
aria-current=${key === section ? 'page' : null}>${label}</a>`)}
<div class="side-foot">v.${version || '—'}</div>
</nav>
<main class="main">
<header class="top"><div><h1 tabIndex="-1">${title}</h1><p>${subtitle}</p></div></header>