提交 b27848ca 编写于 作者: Q qiang

fix(harmony): 监听返回按键

上级 2e88c38a
......@@ -1999,6 +1999,13 @@ function reLaunchEntryPage() {
});
}
const EVENT_BACKBUTTON = 'backbutton';
function backbuttonListener() {
uni.navigateBack({
from: 'backbutton',
success() { }, // 传入空方法,避免返回Promise,因为onBackPress可能导致fail
});
}
const enterOptions = /*#__PURE__*/ createLaunchOptions();
const launchOptions = /*#__PURE__*/ createLaunchOptions();
function initLaunchOptions({ path, query, referrerInfo, }) {
......@@ -2956,6 +2963,7 @@ function initSubscribeHandlers() {
function initGlobalEvent() {
const plusGlobalEvent = plus.globalEvent;
plus.key.addEventListener(EVENT_BACKBUTTON, backbuttonListener);
// TODO KeyboardHeightChange
plusGlobalEvent.addEventListener('plusMessage', subscribePlusMessage);
}
......
import { subscribePlusMessage } from '@dcloudio/uni-app-plus/service/framework/app/initGlobalEvent'
import {
EVENT_BACKBUTTON,
backbuttonListener,
} from '@dcloudio/uni-app-plus/service/framework/app/utils'
export function initGlobalEvent() {
const plusGlobalEvent = (plus as any).globalEvent
plus.key.addEventListener(EVENT_BACKBUTTON, backbuttonListener)
// TODO KeyboardHeightChange
plusGlobalEvent.addEventListener('plusMessage', subscribePlusMessage)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册