From 4e89898cc0b9202ab64ed41a48fa662c07b62daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Thu, 7 May 2026 06:17:48 +0900 Subject: [PATCH] =?UTF-8?q?AJAX=20=D0=B1=D1=8B=D0=BB=20=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D1=91=D0=BD=20=D0=B4=D0=BB=D1=8F=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=20=D1=81=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=D0=BC=D0=B8=20=D0=B8=20?= =?UTF-8?q?=D0=BC=D0=B0=D1=81=D1=82=D0=B5=D1=80=D0=BE=D0=BC=20VM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/static/panel.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/web/static/panel.js b/web/static/panel.js index f4b8e5a..b84fc06 100644 --- a/web/static/panel.js +++ b/web/static/panel.js @@ -4,6 +4,8 @@ refreshTimers: [], }; + const fullLoadPages = ['/iso', '/disk-images', '/vm/create']; + function qs(selector, root = document) { return root.querySelector(selector); } @@ -18,9 +20,14 @@ return url.origin === window.location.origin; } + function requiresFullLoad(pathname) { + return fullLoadPages.some((path) => pathname === path || pathname.startsWith(path + '/')); + } + function isAjaxSafeLink(link) { if (!sameOriginLink(link)) return false; const url = new URL(link.href, window.location.href); + if (requiresFullLoad(url.pathname)) return false; if (url.pathname.startsWith('/vm/') && url.pathname.endsWith('/console')) return false; if (url.pathname.startsWith('/static/')) return false; if (url.pathname.startsWith('/api/')) return false; @@ -59,6 +66,11 @@ function swapPage(html, url, push = true) { const parser = new DOMParser(); const doc = parser.parseFromString(html, 'text/html'); + const targetPath = new URL(url, window.location.href).pathname; + if (requiresFullLoad(targetPath)) { + window.location.href = url; + return; + } const newMain = qs('.v-main', doc) || qs('.shell', doc); const currentMain = qs('.v-main') || qs('.shell'); @@ -74,7 +86,7 @@ currentMain.replaceWith(newMain); newMain.classList.add('page-enter'); setTimeout(() => newMain.classList.remove('page-enter'), 220); - activeSidebar(new URL(url, window.location.href).pathname); + activeSidebar(targetPath); if (push) history.pushState({ ajax: true }, '', url); initDynamicPage(); window.scrollTo({ top: 0, behavior: 'smooth' }); @@ -82,6 +94,11 @@ } async function ajaxNavigate(url, push = true) { + const targetPath = new URL(url, window.location.href).pathname; + if (requiresFullLoad(targetPath)) { + window.location.href = url; + return; + } if (app.loading) return; setLoading(true); try {