Commit 81a372e1 authored by hbcui1984's avatar hbcui1984

解决hello mui首页连按两次back键无法退出App的问题

parent 9ba90bbf
...@@ -47,24 +47,6 @@ ...@@ -47,24 +47,6 @@
var menu = null,showMenu = false; var menu = null,showMenu = false;
mui.plusReady(function() { mui.plusReady(function() {
//首页返回键处理
//处理逻辑:1秒内,连续两次按返回键,则退出应用;
var first = null;
plus.key.addEventListener('backbutton', function(){
//首次按键,提示‘再按一次退出应用’
if(!first){
first = new Date().getTime();
mui.toast('再按一次退出应用');
setTimeout(function(){
first = null;
},1000);
}else{
if(new Date().getTime()-first<1000){
plus.runtime.quit();
}
}
}, false);
//处理侧滑导航,为了避免和子页面初始化等竞争资源,延迟加载侧滑页面; //处理侧滑导航,为了避免和子页面初始化等竞争资源,延迟加载侧滑页面;
setTimeout(function () { setTimeout(function () {
menu= mui.preload({ menu= mui.preload({
......
...@@ -472,6 +472,23 @@ ...@@ -472,6 +472,23 @@
}); });
$.plusReady(function() { $.plusReady(function() {
plus.navigator.closeSplashscreen(); plus.navigator.closeSplashscreen();
//首页返回键处理
//处理逻辑:1秒内,连续两次按返回键,则退出应用;
var first = null;
plus.key.addEventListener('backbutton', function(){
//首次按键,提示‘再按一次退出应用’
if(!first){
first = new Date().getTime();
mui.toast('再按一次退出应用');
setTimeout(function(){
first = null;
},1000);
}else{
if(new Date().getTime()-first<1000){
plus.runtime.quit();
}
}
}, false);
//预加载下拉刷新 //预加载下拉刷新
$.preload({ $.preload({
id:"examples/pullrefresh-main.html", id:"examples/pullrefresh-main.html",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment