From 2f50f6e9205c78b8637afac8befd1357f829dd58 Mon Sep 17 00:00:00 2001 From: wasrusgen Date: Sun, 17 May 2026 00:39:12 +0300 Subject: [PATCH] fix(miniapp): remove location.reload() on back-to-home navigation (splash bug) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every "Назад" / "На главную" button was calling location.reload() which triggered a full page reload → splash screen appeared again. Fix: replace reload() with routeByHash() call (global router function from app.js) which re-renders the role-appropriate home screen from cached window.__zovMe without any network round-trips. Affected files: app.js, clients.js, measurements.js, request.js, assembly.js, podbor.js. Bump asset versions to 20260517b to bust cache. Co-Authored-By: Claude Sonnet 4.6 --- miniapp/assets/app.js | 3 ++- miniapp/assets/assembly.js | 2 +- miniapp/assets/clients.js | 3 ++- miniapp/assets/measurements.js | 4 ++-- miniapp/assets/podbor.js | 4 ++-- miniapp/assets/request.js | 8 +++++--- miniapp/index.html | 12 ++++++------ 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/miniapp/assets/app.js b/miniapp/assets/app.js index 7db679d..9d33fd3 100644 --- a/miniapp/assets/app.js +++ b/miniapp/assets/app.js @@ -1199,8 +1199,9 @@ async function renderInboxDetail(measurementId) { `); header.querySelector(".podbor-back").addEventListener("click", () => { + // Возврат в главное меню без перезагрузки (иначе сплэш мигает) location.hash = ""; - if (!location.hash) location.reload(); + routeByHash(); }); app.appendChild(header); diff --git a/miniapp/assets/assembly.js b/miniapp/assets/assembly.js index 743c281..90ad221 100644 --- a/miniapp/assets/assembly.js +++ b/miniapp/assets/assembly.js @@ -226,7 +226,7 @@ const Assembly = (function () { btn.style.display = "none"; result.querySelector("#toHome")?.addEventListener("click", () => { location.hash = ""; - location.reload(); + if (typeof routeByHash === "function") routeByHash(); }); result.querySelector("#toDetail")?.addEventListener("click", () => { location.hash = `#/assembly/${data.id}`; diff --git a/miniapp/assets/clients.js b/miniapp/assets/clients.js index a745b11..44a3ed6 100644 --- a/miniapp/assets/clients.js +++ b/miniapp/assets/clients.js @@ -1804,8 +1804,9 @@ const Clients = (function () { } else if (backHref) { location.hash = backHref; } else { + // Возврат в главное меню — без перезагрузки страницы (иначе сплэш мигает) location.hash = ""; - location.reload(); + if (typeof routeByHash === "function") routeByHash(); } }); return h; diff --git a/miniapp/assets/measurements.js b/miniapp/assets/measurements.js index af7ea17..7b05563 100644 --- a/miniapp/assets/measurements.js +++ b/miniapp/assets/measurements.js @@ -146,7 +146,7 @@ const Measurements = (function () { `); h.querySelector(".podbor-back").addEventListener("click", () => { location.hash = ""; - location.reload(); + if (typeof routeByHash === "function") routeByHash(); }); h.querySelector("#openChecklist").addEventListener("click", () => { location.hash = "#/measure/checklist"; @@ -969,7 +969,7 @@ const Measurements = (function () { node.querySelector("#newOne")?.addEventListener("click", () => mount(root)); node.querySelector("#toHome")?.addEventListener("click", () => { location.hash = ""; - location.reload(); + if (typeof routeByHash === "function") routeByHash(); }); } catch (e) { result.innerHTML = `
Сеть: ${e.message}
`; diff --git a/miniapp/assets/podbor.js b/miniapp/assets/podbor.js index a645ea3..a2335a4 100644 --- a/miniapp/assets/podbor.js +++ b/miniapp/assets/podbor.js @@ -108,9 +108,9 @@ const Podbor = (function () { h.querySelector(".podbor-back").addEventListener("click", () => { const idx = STEPS.indexOf(currentStep); if (idx <= 0) { - // Выход из подбора в главный экран кабинета + // Выход из подбора в главный экран кабинета — без перезагрузки (иначе сплэш мигает) location.hash = ""; - location.reload(); + if (typeof routeByHash === "function") routeByHash(); } else { go(STEPS[idx - 1]); } diff --git a/miniapp/assets/request.js b/miniapp/assets/request.js index 335c808..a24882e 100644 --- a/miniapp/assets/request.js +++ b/miniapp/assets/request.js @@ -208,7 +208,7 @@ const MeasurementRequest = (function () { form.querySelector("#newOne")?.addEventListener("click", () => mount(root)); form.querySelector("#toHome")?.addEventListener("click", () => { location.hash = ""; - location.reload(); + if (typeof routeByHash === "function") routeByHash(); }); } catch (e) { result.innerHTML = `
Сеть: ${e.message}
`; @@ -227,8 +227,10 @@ const MeasurementRequest = (function () { `); h.querySelector(".podbor-back").addEventListener("click", () => { if (backHref) location.hash = backHref; - else location.hash = ""; - if (!location.hash) location.reload(); + else { + location.hash = ""; + if (typeof routeByHash === "function") routeByHash(); + } }); return h; } diff --git a/miniapp/index.html b/miniapp/index.html index 15690d2..7ec980f 100644 --- a/miniapp/index.html +++ b/miniapp/index.html @@ -38,13 +38,13 @@ - - + + - - - + + + - +