feat:app嵌套h5返回键
This commit is contained in:
@@ -11,7 +11,7 @@ onMounted(async() => {
|
||||
// 设置系统状态栏明暗主题
|
||||
appBridge.setStatusBarStyle('light');
|
||||
// 设置禁止原生返回
|
||||
appBridge.takeOverAndroidBack();
|
||||
// appBridge.takeOverAndroidBack();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.van-nav-bar {
|
||||
padding-top: var(--status-bar-height) !important;
|
||||
height: calc(60px + var(--status-bar-height)) !important;
|
||||
padding-top: calc(var(--status-bar-height) + 10px) !important;
|
||||
// height: calc(46px + var(--status-bar-height)) !important;
|
||||
}
|
||||
.van-cell {
|
||||
padding: 8px !important;
|
||||
|
||||
@@ -140,22 +140,9 @@ export default {
|
||||
* @returns {Boolean} 操作是否成功
|
||||
*/
|
||||
takeOverAndroidBack() {
|
||||
if (!this.isInReactNative()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
window.ReactNativeWebView.postMessage(
|
||||
JSON.stringify({
|
||||
type: 'takeOverAndroidBack',
|
||||
data: {
|
||||
enabled: true
|
||||
}
|
||||
})
|
||||
);
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return this.postMessage({
|
||||
type: 'takeOverAndroidBack'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -328,6 +315,7 @@ export default {
|
||||
if (canGoBack) {
|
||||
router.go(-1);
|
||||
} else {
|
||||
this.takeOverAndroidBack();
|
||||
this.navigateBack();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ router.beforeEach((to, from, next) => {
|
||||
if (to.query.digitalYiliToken) {
|
||||
utils.setSessionStorage('xToken', to.query.digitalYiliToken);
|
||||
}
|
||||
appBridge.setTitle(to.meta.title as string);
|
||||
// appBridge.setTitle(to.meta.title as string);
|
||||
// 添加 Android 返回按钮监听方法
|
||||
window.onAndroidBack = () => {
|
||||
if (routerCanGoBack()) {
|
||||
|
||||
Reference in New Issue
Block a user