diff --git a/app/src/main/assets/h5/js/pages/webapplist.js b/app/src/main/assets/h5/js/pages/webapplist.js index 4011434..1eab162 100644 --- a/app/src/main/assets/h5/js/pages/webapplist.js +++ b/app/src/main/assets/h5/js/pages/webapplist.js @@ -174,3 +174,11 @@ window.HearthEvents.webappUpdated = function () { if (page.classList.contains('active')) window.loadWebAppList(); } }; + +// 点击菜单外部关闭长按菜单(touchstart 更及时,移动端可靠) +// Close the long-press menu when tapping outside (touchstart fires promptly on mobile) +document.addEventListener('touchstart', (e) => { + document.querySelectorAll('.wapp-menu').forEach((m) => { + if (!m.contains(e.target)) m.remove(); + }); +}, { passive: true }); diff --git a/app/src/main/assets/h5/js/router.js b/app/src/main/assets/h5/js/router.js index e8e3e34..ca6fe5a 100644 --- a/app/src/main/assets/h5/js/router.js +++ b/app/src/main/assets/h5/js/router.js @@ -36,6 +36,9 @@ const router = { // 移除 webapp-active:webapp 已丢后台,恢复 webapp 列表显示 // Remove webapp-active: the webapp is backgrounded, restore the list display document.body.classList.remove('webapp-active'); + // 关闭长按菜单(切页时) + // Close the long-press menu on page switch + document.querySelectorAll('.wapp-menu').forEach((m) => m.remove()); // 非首页时侧边栏顶部显示小时间(容器始终占位,仅切换可见性避免撑动图标) // Show the small clock at the sidebar top when not on home (the container // always occupies space; only toggle visibility to avoid shifting icons) diff --git a/app/src/main/java/top/yeij/hearth/webview/WebViewManager.kt b/app/src/main/java/top/yeij/hearth/webview/WebViewManager.kt index 3827f18..4ef24e1 100644 --- a/app/src/main/java/top/yeij/hearth/webview/WebViewManager.kt +++ b/app/src/main/java/top/yeij/hearth/webview/WebViewManager.kt @@ -43,13 +43,17 @@ class WebViewManager(private val activity: Activity) { ua == "desktop" || ua == "pc" -> UA_DESKTOP else -> ua } - // 初始缩放(1-100):用于 PC 版页面缩放适配横屏。 - // 需关闭 overview 模式,否则 useWideViewPort+overview 会自动重新缩放并覆盖 setInitialScale - // Initial zoom (1-100): scale desktop pages to fit landscape. Must disable - // overview mode, otherwise useWideViewPort+overview re-zooms and overrides setInitialScale + // 缩放(1-100):View 级别 scaleX/scaleY,不依赖页面渲染或 viewport,对任何页面可靠生效。 + // 缩放后内容相对左上角缩小;触摸坐标由 View 自动映射 + // Zoom (1-100): view-level scaleX/scaleY, independent of page rendering or + // viewport, so it reliably works for any page. Content shrinks toward the + // top-left; touch coordinates are auto-mapped by the View if (scale != null && scale in 1..100) { - webView.settings.loadWithOverviewMode = false - webView.setInitialScale(scale) + val s = scale / 100f + webView.scaleX = s + webView.scaleY = s + webView.pivotX = 0f + webView.pivotY = 0f } return webView }