From 1e65f9368508acbac9603be523d64938a909f8c4 Mon Sep 17 00:00:00 2001 From: "liu.huiying@ebiz-digits.com" Date: Fri, 14 Mar 2025 18:29:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:app=E5=B5=8C=E5=A5=97h5=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 -- src/main.ts | 4 +++- src/views/Survey/views/Publish/Index.vue | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index d9cd037..ed3e316 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,8 +10,6 @@ onMounted(async() => { appBridge.setHeaderShown(true); // 设置系统状态栏明暗主题 appBridge.setStatusBarStyle('light'); - // // 设置禁止原生返回 - // appBridge.takeOverAndroidBack(); } }); diff --git a/src/main.ts b/src/main.ts index 0b4f8c4..bd5ff58 100644 --- a/src/main.ts +++ b/src/main.ts @@ -43,8 +43,10 @@ router.beforeEach((to, from, next) => { // 添加 Android 返回按钮监听方法 window.onAndroidBack = () => { if (routerCanGoBack()) { - router.back(); // 使用 router.back() 而不是 router.goBack(),因为 Vue Router 使用 back() 方法 + console.log('h5返回') + router.back(); } else { + console.log('app返回') callAppGoBack(); // 调用 APP 的返回方法 } }; diff --git a/src/views/Survey/views/Publish/Index.vue b/src/views/Survey/views/Publish/Index.vue index bf00a84..47316c0 100644 --- a/src/views/Survey/views/Publish/Index.vue +++ b/src/views/Survey/views/Publish/Index.vue @@ -155,7 +155,10 @@ const handleBack = () => { return true; // 表示已处理返回事件 } else { console.log('app返回'); - // 没有更多历史记录,让APP自行处理返回 + // 没有更多历史记录,尝试使用appBridge处理返回 + if ((window as any).appBridge && (window as any).appBridge.closeWebView) { + (window as any).appBridge.closeWebView(); + } return false; // 表示未处理返回事件,应由APP处理 } };