feat:app嵌套h5返回键

This commit is contained in:
LHY\18810
2025-03-15 00:04:00 +08:00
parent 853aa676e3
commit 4270f925f2
4 changed files with 30 additions and 76 deletions

View File

@@ -23,19 +23,26 @@ declare global {
appBridge?: any;
}
}
// 隐藏/显示 header
appBridge.setHeaderShown(true);
// 设置系统状态栏明暗主题
appBridge.setStatusBarStyle('light');
// 定义路由是否可以返回的判断
const routerCanGoBack = () => {
const position = router.options.history.state?.position;
return typeof position === 'number' && position > 0;
};
router.beforeEach((to, from, next) => {
if (to.query.digitalYiliToken) {
utils.setSessionStorage('xToken', to.query.digitalYiliToken);
}
// 设置 header 标题
appBridge.setTitle(to.meta.title as string);
// 添加 Android 返回按钮监听方法
window.onAndroidBack = () => {
if (routerCanGoBack()) {
router.go(-1);
} else {
appBridge.navigateBack();
}
};
next();
});
app.use(createPinia());
app.use(router);
app.mount('#app');
app.mount('#app');