Changeset 0.25.3 (#163)

This commit is contained in:
2026-03-09 01:54:06 +00:00
parent 6c484fa7f8
commit 2f7a0fb027
11 changed files with 235 additions and 74 deletions

View File

@@ -9,7 +9,7 @@
{{/* Top Bar */}}
<div class="admin-topbar">
<a href="{{.BasePath}}/" class="admin-topbar-back" onclick="if(history.length>1){history.back();return false;}">
<a href="{{.BasePath}}/" class="admin-topbar-back" id="adminBackBtn">>
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
Back
</a>
@@ -220,4 +220,52 @@
<script nonce="{{.CSPNonce}}" src="{{.BasePath}}/js/notifications.js?v={{.Version}}"></script>
<script nonce="{{.CSPNonce}}" src="{{.BasePath}}/js/admin-scaffold.js?v={{.Version}}"></script>
<script nonce="{{.CSPNonce}}" src="{{.BasePath}}/js/admin-surfaces.js?v={{.Version}}"></script>
<script nonce="{{.CSPNonce}}">
document.addEventListener('DOMContentLoaded', () => {
// ── Admin navigation: don't pollute browser history ──
// Same pattern as settings surface: stash return URL on entry,
// tab/nav switches use location.replace(), back goes directly out.
const RETURN_KEY = 'sb_admin_return';
if (!sessionStorage.getItem(RETURN_KEY)) {
const ref = document.referrer;
const base = (window.__BASE__ || '') + '/';
if (ref && ref.startsWith(location.origin) && !ref.includes('/admin')) {
sessionStorage.setItem(RETURN_KEY, ref);
} else {
sessionStorage.setItem(RETURN_KEY, location.origin + base);
}
}
const backBtn = document.getElementById('adminBackBtn');
if (backBtn) {
backBtn.addEventListener('click', (e) => {
e.preventDefault();
const returnURL = sessionStorage.getItem(RETURN_KEY);
sessionStorage.removeItem(RETURN_KEY);
location.href = returnURL || (window.__BASE__ || '') + '/';
});
}
// Category tabs: replace history instead of pushing
document.querySelectorAll('.admin-cat-btn').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
location.replace(link.href);
});
});
// Nav links are dynamically rebuilt by admin-scaffold.js —
// use event delegation on the nav container
const adminNav = document.getElementById('adminNav');
if (adminNav) {
adminNav.addEventListener('click', (e) => {
const link = e.target.closest('.admin-nav-link');
if (link && link.href) {
e.preventDefault();
location.replace(link.href);
}
});
}
});
</script>
{{end}}