|
发表于 2016-4-18 11:27:41
|
显示全部楼层
修改$UI/system/lib/portal/shell.js,加个判断2次closepage的时间,若小于500ms,则不退出页面,就可以解决多次点击返回键报错了
define(function(require) {
var $ = require("jquery");
var lastClickTime = 0;
function checkImpl() {
if (api.impl) {
return true;
}
return false;
}
function isFastDoubleClick() {
var timeA = new Date().getTime();
var timeB = timeA - lastClickTime;
if (timeB >= 0 && timeB <= 600) {
return false;
}
lastClickTime = timeA;
return true;
}
function DefaultImpl() {
}
DefaultImpl.prototype.noopImpl = function() {
var dtd = $.Deferred();
return dtd.promise();
};
DefaultImpl.prototype.closePage = function() {
return window.close();
};
var defaultImpl = new DefaultImpl();
function addShowPage() {
var dtd = $.Deferred();
// require('$UI/system/components/justep/windowOpener/windowOpener')
require([ '$UI/system/components/justep/windowOpener/windowOpener' ], function(WindowOpener) {
DefaultImpl.prototype.showPage = function(url, data, options) {
if (typeof url === "object") {
var urlParams = [];
var params = url;
url = url.url;
delete params.url;
$.each(params, function(key, value) {
if (key !== "xid" && key !== "extra") {
if (value !== "undefined" && value !== "" && value !== undefined) {
urlParams.push(key + "=" + encodeURIComponent(value));
}
}
});
var urlParamStr = urlParams.join("&");
if (urlParams.length > 0) {
if (url.indexOf("?") != -1) {
url = url + "&" + urlParamStr;
} else {
url = url + "?" + urlParamStr;
}
}
}
var option = {
url : url,
modal : "true",
resizable : "true",
status : "fullscreen"
};
var opener = new WindowOpener(option);
opener.open({
params : data
});
};
dtd.resolve();
});
return dtd.promise();
}
;
var api = {
loadPage : function() {
if (checkImpl()) {
return api.impl.loadPage.apply(api.impl, arguments);
} else {
return defaultImpl.noopImpl();
}
},
showPage : function() {
var args = arguments;
if (checkImpl()) {
return api.impl.showPage.apply(api.impl, arguments);
} else {
if (defaultImpl.showPage) {
return defaultImpl.showPage.apply(defaultImpl, arguments);
} else {
addShowPage().done(function() {
return defaultImpl.showPage.apply(defaultImpl, args);
})
}
}
},
showLeft : function() {
if (checkImpl()) {
return api.impl.showLeft.apply(api.impl, arguments);
} else {
return defaultImpl.noopImpl();
}
},
showRight : function() {
if (checkImpl()) {
return api.impl.showRight.apply(api.impl, arguments);
} else {
return defaultImpl.noopImpl();
}
},
closePage : function() {
if (isFastDoubleClick()) {
if (checkImpl()) {
return api.impl.closePage.apply(api.impl, arguments);
} else {
defaultImpl.closePage();
}
}
},
setIsSinglePage : function(isSinglePage) {
if (checkImpl()) {
api.impl.isSinglePage = isSinglePage;
}
},
getActivePageXid : function() {
if (checkImpl()) {
return api.impl.getActivePageXid.apply(api.impl, arguments);
} else {
return "";
}
},
on : function() {
if (checkImpl()) {
return api.impl.on.apply(api.impl, arguments);
}
},
off : function() {
if (checkImpl()) {
return api.impl.off.apply(api.impl, arguments);
}
},
fireEvent : function() {
if (checkImpl()) {
return api.impl.fireEvent.apply(api.impl, arguments);
}
},
addPageMappings : function() {
if (checkImpl()) {
return api.impl.addPageMappings.apply(api.impl, arguments);
}
},
showMainPage : function() {
if (checkImpl()) {
return api.impl.showMainPage.apply(api.impl, arguments);
}
},
removeMainPage : function() {
if (checkImpl()) {
return api.impl.removeMainPage.apply(api.impl, arguments);
}
}
};
return api;
}); |
|