mac下关闭窗口是隐藏, 不必stop server

This commit is contained in:
life
2015-12-06 14:31:38 +08:00
parent 796bd14d15
commit f1be042b5e
2 changed files with 28 additions and 1 deletions

View File

@@ -23,7 +23,7 @@ $(function() {
$('.tool-close, .tool-close-blur').click(function() {
// mac下关闭才是隐藏
onClose(function() {
onCloseNotStopServerForMac(function() {
gui.win.hide();
});
// gui.win.showInactive();

View File

@@ -1779,6 +1779,33 @@ var onClose = function(afterFunc) {
}
}
// 如果是mac, 当关闭窗口时不要stop server
var onCloseNotStopServerForMac = function(afterFunc) {
function o () {
SyncService.stop();
// 先保存之前改变的
Note.curChangedSaveIt();
// 保存状态
State.saveCurState(function() {
afterFunc && afterFunc();
});
}
try {
if (isMac()) {
o();
}
else {
// 先把服务/协议关掉
Server.close(function () {
o();
});
}
} catch(e) {
console.error(e);
afterFunc && afterFunc();
}
}
function isURL(str_url) {
var re = new RegExp("^((https|http|ftp|rtsp|mms|emailto)://).+");
return re.test(str_url);