From 3b0dd2e8008c36c3fe96b508ddbb6c4d012012a0 Mon Sep 17 00:00:00 2001 From: 170-carry Date: Tue, 28 Apr 2026 20:49:56 +0800 Subject: [PATCH] fix: close host center on back --- h5/hyapp/host-center/index.html | 2 +- h5/hyapp/host-center/script.js | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/h5/hyapp/host-center/index.html b/h5/hyapp/host-center/index.html index cbd485d..2436b25 100644 --- a/h5/hyapp/host-center/index.html +++ b/h5/hyapp/host-center/index.html @@ -146,6 +146,6 @@
loading....
- + diff --git a/h5/hyapp/host-center/script.js b/h5/hyapp/host-center/script.js index 2dac1d1..69b117f 100644 --- a/h5/hyapp/host-center/script.js +++ b/h5/hyapp/host-center/script.js @@ -214,7 +214,7 @@ if (window.location.protocol === "file:") return fallbackMessages[normalizedLang]; try { - const response = await fetch(`./locales/${normalizedLang}.json?v=20260428-2060`, { cache: "no-store" }); + const response = await fetch(`./locales/${normalizedLang}.json?v=20260428-2070`, { cache: "no-store" }); if (response.ok) return await response.json(); } catch (error) { return fallbackMessages[normalizedLang]; @@ -461,6 +461,25 @@ window.location.replace(buildPageURL("../join-agency/index.html")); } + function closeHostCenterPage() { + try { + if (window.app && typeof window.app.closePage === "function") { + window.app.closePage(); + return; + } + + if (window.FlutterPageControl && typeof window.FlutterPageControl.postMessage === "function") { + window.FlutterPageControl.postMessage("close_page"); + return; + } + + if (window.history.length > 1) window.history.back(); + } catch (error) { + console.error("close host center page failed:", error); + if (window.history.length > 1) window.history.back(); + } + } + function formatCurrentSalary(value) { const numericValue = Number(value); if (Number.isFinite(numericValue)) return numericValue.toFixed(2); @@ -878,7 +897,7 @@ }); document.querySelector(".back-button")?.addEventListener("click", () => { - if (window.history.length > 1) window.history.back(); + closeHostCenterPage(); }); document.querySelector(".agency")?.addEventListener("click", () => {