mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-15 07:31:33 +00:00
2.3 released
This commit is contained in:
23
main.js
23
main.js
@@ -116,7 +116,19 @@ function removeEvents (win) {
|
|||||||
win.removeAllListeners('close');
|
win.removeAllListeners('close');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function close (e, force) {
|
||||||
|
console.log('close:', force);
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.hide();
|
||||||
|
e && e.preventDefault();
|
||||||
|
mainWindow.webContents.send('closeWindow');
|
||||||
|
} else {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function bindEvents (win) {
|
function bindEvents (win) {
|
||||||
|
mainWindow = win;
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
win.on('closed', function() {
|
win.on('closed', function() {
|
||||||
@@ -138,17 +150,6 @@ function bindEvents (win) {
|
|||||||
if(win && win.webContents)
|
if(win && win.webContents)
|
||||||
win.webContents.send('blurWindow');
|
win.webContents.send('blurWindow');
|
||||||
});
|
});
|
||||||
|
|
||||||
function close (e, force) {
|
|
||||||
console.log('close:', force);
|
|
||||||
if (win) {
|
|
||||||
win.hide();
|
|
||||||
e && e.preventDefault();
|
|
||||||
win.webContents.send('closeWindow');
|
|
||||||
} else {
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 以前的关闭是真关闭, 现是是假关闭了
|
// 以前的关闭是真关闭, 现是是假关闭了
|
||||||
// 关闭,先保存数据
|
// 关闭,先保存数据
|
||||||
|
9
node_modules/api.js
generated
vendored
9
node_modules/api.js
generated
vendored
@@ -28,7 +28,7 @@ var Api = {
|
|||||||
// 检查错误
|
// 检查错误
|
||||||
checkError: function(error, resp) {
|
checkError: function(error, resp) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.unConnected(error);
|
var unConnected = me.unConnected(error);
|
||||||
// console.error(error);
|
// console.error(error);
|
||||||
// 是否需要重新登录
|
// 是否需要重新登录
|
||||||
/*{
|
/*{
|
||||||
@@ -44,18 +44,25 @@ var Api = {
|
|||||||
if(typeof ret == 'object') {
|
if(typeof ret == 'object') {
|
||||||
if(!ret['Ok'] && ret['Msg'] == 'NOTLOGIN') {
|
if(!ret['Ok'] && ret['Msg'] == 'NOTLOGIN') {
|
||||||
Web.notLogin();
|
Web.notLogin();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(!ret['Ok'] && ret['Msg'] == 'NEED-UPGRADE-ACCOUNT') {
|
if(!ret['Ok'] && ret['Msg'] == 'NEED-UPGRADE-ACCOUNT') {
|
||||||
Web.needUpgradeAccount();
|
Web.needUpgradeAccount();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 出现问题
|
// 出现问题
|
||||||
Web.unConnected();
|
Web.unConnected();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// 出错问题
|
// 出错问题
|
||||||
Web.unConnected();
|
Web.unConnected();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 没有断网
|
||||||
|
!unConnected && Web.connected();
|
||||||
},
|
},
|
||||||
// 是否断网
|
// 是否断网
|
||||||
unConnected: function(error) {
|
unConnected: function(error) {
|
||||||
|
85
node_modules/sync.js
generated
vendored
85
node_modules/sync.js
generated
vendored
@@ -581,6 +581,7 @@ var Sync = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 全量同步
|
// 全量同步
|
||||||
|
// callback(error, info)
|
||||||
fullSync: function(callback) {
|
fullSync: function(callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me._stop = false;
|
me._stop = false;
|
||||||
@@ -607,44 +608,53 @@ var Sync = {
|
|||||||
|
|
||||||
console.log('fullSync ' + notebookUsn + ' ' + noteUsn + ' ' + tagUsn);
|
console.log('fullSync ' + notebookUsn + ' ' + noteUsn + ' ' + tagUsn);
|
||||||
|
|
||||||
// Web.syncNotebookFinish();
|
Api.getLastSyncState(function(serverState) {
|
||||||
// 同步笔记本
|
if(!Common.isOk(serverState)) {
|
||||||
me.syncNotebook(notebookUsn, function(ok) {
|
console.error(' get Server LastSyncState error!!');
|
||||||
if(ok) {
|
callback && callback(serverState, null);
|
||||||
// Web.syncNoteFinish();
|
return;
|
||||||
// console.log('------------------')
|
|
||||||
// 同步笔记
|
|
||||||
me.syncNote(noteUsn, function(ok) {
|
|
||||||
if(ok) {
|
|
||||||
// Web.syncTagFinish();
|
|
||||||
// 同步标签
|
|
||||||
me.syncTag(tagUsn, function(ok) {
|
|
||||||
if (ok) {
|
|
||||||
me.fullSyncStart = false;
|
|
||||||
// 更新上次同步时间
|
|
||||||
me.updateLastSyncState(function() {
|
|
||||||
// send changes
|
|
||||||
// me.sendChanges();
|
|
||||||
callback && callback(me._syncInfo, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
me.fullSyncStart = false;
|
|
||||||
console.error('syncTag error....');
|
|
||||||
callback && callback(me._syncInfo, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
me.fullSyncStart = false;
|
|
||||||
console.error('syncNote error.... 跳过tag');
|
|
||||||
callback && callback(me._syncInfo, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
me.fullSyncStart = false;
|
|
||||||
console.error('syncNotebook error.... 跳过note,tag');
|
|
||||||
callback && callback(me._syncInfo, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Web.syncNotebookFinish();
|
||||||
|
// 同步笔记本
|
||||||
|
me.syncNotebook(notebookUsn, function(ok) {
|
||||||
|
if(ok) {
|
||||||
|
// Web.syncNoteFinish();
|
||||||
|
// console.log('------------------')
|
||||||
|
// 同步笔记
|
||||||
|
me.syncNote(noteUsn, function(ok) {
|
||||||
|
if(ok) {
|
||||||
|
// Web.syncTagFinish();
|
||||||
|
// 同步标签
|
||||||
|
me.syncTag(tagUsn, function(ok) {
|
||||||
|
if (ok) {
|
||||||
|
me.fullSyncStart = false;
|
||||||
|
// 更新上次同步时间
|
||||||
|
me.updateLastSyncState(function() {
|
||||||
|
// send changes
|
||||||
|
// me.sendChanges();
|
||||||
|
callback && callback(false, me._syncInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
me.fullSyncStart = false;
|
||||||
|
console.error('syncTag error....');
|
||||||
|
callback && callback({}, me._syncInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
me.fullSyncStart = false;
|
||||||
|
console.error('syncNote error.... 跳过tag');
|
||||||
|
callback && callback({}, me._syncInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
me.fullSyncStart = false;
|
||||||
|
console.error('syncNotebook error.... 跳过note,tag');
|
||||||
|
callback && callback({}, me._syncInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -782,6 +792,7 @@ var Sync = {
|
|||||||
me.setSyncFinished();
|
me.setSyncFinished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 先从服务器上得到usn, 与本地的判断, 是否需要pull
|
// 先从服务器上得到usn, 与本地的判断, 是否需要pull
|
||||||
Api.getLastSyncState(function(serverState) {
|
Api.getLastSyncState(function(serverState) {
|
||||||
if(!Common.isOk(serverState)) {
|
if(!Common.isOk(serverState)) {
|
||||||
|
4
node_modules/web.js
generated
vendored
4
node_modules/web.js
generated
vendored
@@ -15,6 +15,10 @@ var Web = {
|
|||||||
var me = this;
|
var me = this;
|
||||||
me.Note && me.Note.unConnected();
|
me.Note && me.Note.unConnected();
|
||||||
},
|
},
|
||||||
|
connected: function() {
|
||||||
|
var me = this;
|
||||||
|
me.Note && me.Note.connected();
|
||||||
|
},
|
||||||
notLogin: function() {
|
notLogin: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.Note && me.Note.notLogin();
|
me.Note && me.Note.notLogin();
|
||||||
|
@@ -847,21 +847,22 @@ Note.renderChangedNote = function(changedNote) {
|
|||||||
// 清空右侧note信息, 可能是共享的,
|
// 清空右侧note信息, 可能是共享的,
|
||||||
// 此时需要清空只读的, 且切换到note edit模式下
|
// 此时需要清空只读的, 且切换到note edit模式下
|
||||||
Note.clearNoteInfo = function() {
|
Note.clearNoteInfo = function() {
|
||||||
Note.clearCurNoteId();
|
Note.clearCurNoteId();
|
||||||
Tag.input.clearTags();
|
Tag.input.clearTags();
|
||||||
$("#noteTitle").val("");
|
$("#noteTitle").val("");
|
||||||
setEditorContent("");
|
setEditorContent("");
|
||||||
|
|
||||||
// markdown editor
|
// markdown editor
|
||||||
/*
|
/*
|
||||||
$("#wmd-input").val("");
|
$("#wmd-input").val("");
|
||||||
$("#wmd-preview").html("");
|
$("#wmd-preview").html("");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 只隐藏即可
|
// 只隐藏即可
|
||||||
$("#noteRead").hide();
|
$("#noteRead").hide();
|
||||||
}
|
};
|
||||||
// 清除noteList导航
|
|
||||||
|
// 清除noteList导航
|
||||||
Note.clearNoteList = function() {
|
Note.clearNoteList = function() {
|
||||||
Note.noteItemListO.html(""); // 清空
|
Note.noteItemListO.html(""); // 清空
|
||||||
}
|
}
|
||||||
@@ -1252,23 +1253,31 @@ Note.hideSyncProgress = function() {
|
|||||||
Note.unConnected = function() {
|
Note.unConnected = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me._syncWarningE.show();
|
me._syncWarningE.show();
|
||||||
SyncService.setSyncFinished();
|
SyncService.setSyncFinished(true);
|
||||||
me.hideSpin();
|
me.hideSpin();
|
||||||
me._syncWarningE.data('reason', 'unConnected');
|
me._syncWarningE.data('reason', 'unConnected');
|
||||||
me._syncWarningE.attr('title', 'Network error');
|
me._syncWarningE.attr('title', 'Network error');
|
||||||
};
|
};
|
||||||
|
// 网络已经连接好了
|
||||||
|
Note.connected = function() {
|
||||||
|
var me = this;
|
||||||
|
if (me._syncWarningE.data('reason') == 'unConnected') {
|
||||||
|
me._syncWarningE.data('reason', '-');
|
||||||
|
me._syncWarningE.hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
Note.notLogin = function() {
|
Note.notLogin = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me._syncWarningE.show();
|
me._syncWarningE.show();
|
||||||
me.hideSpin();
|
me.hideSpin();
|
||||||
SyncService.setSyncFinished();
|
SyncService.setSyncFinished(true);
|
||||||
me._syncWarningE.data('reason', 'notLogin');
|
me._syncWarningE.data('reason', 'notLogin');
|
||||||
me._syncWarningE.attr('title', getMsg('You need to sign in Leanote'));
|
me._syncWarningE.attr('title', getMsg('You need to sign in Leanote'));
|
||||||
};
|
};
|
||||||
Note.needUpgradeAccount = function() {
|
Note.needUpgradeAccount = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.hideSpin();
|
me.hideSpin();
|
||||||
SyncService.setSyncFinished();
|
SyncService.setSyncFinished(true);
|
||||||
me._syncWarningE.show();
|
me._syncWarningE.show();
|
||||||
me._syncWarningE.data('reason', 'NEED-UPGRADE-ACCOUNT');
|
me._syncWarningE.data('reason', 'NEED-UPGRADE-ACCOUNT');
|
||||||
me._syncWarningE.attr('title', getMsg('You need to upgrade Leanote account'));
|
me._syncWarningE.attr('title', getMsg('You need to upgrade Leanote account'));
|
||||||
@@ -1284,7 +1293,7 @@ Note.fixNetOrAuthError = function() {
|
|||||||
} else if (reason == 'notLogin') {
|
} else if (reason == 'notLogin') {
|
||||||
alert(getMsg('You need to sign in Leanote'));
|
alert(getMsg('You need to sign in Leanote'));
|
||||||
// 弹出登录框登录之, 重新弹出
|
// 弹出登录框登录之, 重新弹出
|
||||||
window.open('login.html?ref=needLogin');
|
toLogin();
|
||||||
|
|
||||||
// 需要升级Leanote
|
// 需要升级Leanote
|
||||||
} else if (reason == 'NEED-UPGRADE-ACCOUNT') {
|
} else if (reason == 'NEED-UPGRADE-ACCOUNT') {
|
||||||
|
@@ -1216,8 +1216,8 @@ LeaAce = {
|
|||||||
function fullSync(callback) {
|
function fullSync(callback) {
|
||||||
log('full sync');
|
log('full sync');
|
||||||
$('.loading-footer').show();
|
$('.loading-footer').show();
|
||||||
SyncService.fullSync(function(ret, ok) {
|
SyncService.fullSync(function(err, ret) {
|
||||||
callback && callback(ok);
|
callback && callback(err, ret);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1525,9 +1525,29 @@ function initPage(initedCallback) {
|
|||||||
else if ('LastSyncUsn' in UserInfo && UserInfo['LastSyncUsn'] > 0) {
|
else if ('LastSyncUsn' in UserInfo && UserInfo['LastSyncUsn'] > 0) {
|
||||||
_init();
|
_init();
|
||||||
} else {
|
} else {
|
||||||
fullSync(function(ok) {
|
fullSync(function(err, info) {
|
||||||
if (!ok) {
|
if (err) {
|
||||||
Notify.show({ title: 'Info', body: getMsg('Sync error, retry to sync after 3 seconds') });
|
if (typeof err == 'object') {
|
||||||
|
if(err['Msg'] == 'NOTLOGIN') {
|
||||||
|
alert(getMsg('You need to sign in Leanote'));
|
||||||
|
toLogin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(err['Msg'] == 'NEED-UPGRADE-ACCOUNT') {
|
||||||
|
alert(getMsg('You need to upgrade Leanote account'));
|
||||||
|
openExternal('https://leanote.com/pricing#buy');
|
||||||
|
setTimeout(function () {
|
||||||
|
toLogin();
|
||||||
|
}, 1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMac()) {
|
||||||
|
Notify.show({ title: 'Info', body: getMsg('Sync error, retry to sync after 3 seconds') });
|
||||||
|
} else {
|
||||||
|
alert(getMsg('Sync error, retry to sync after 3 seconds'));
|
||||||
|
}
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
reloadApp();
|
reloadApp();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
@@ -220,9 +220,9 @@ TagInput.prototype = {
|
|||||||
// called by Note
|
// called by Note
|
||||||
setTags: function(tags) {
|
setTags: function(tags) {
|
||||||
if(!Array.isArray(tags)) {
|
if(!Array.isArray(tags)) {
|
||||||
return;
|
tags = [];
|
||||||
}
|
}
|
||||||
this.$tags.html('');
|
this.clearTags();
|
||||||
for(var i = 0; i < tags.length; ++i) {
|
for(var i = 0; i < tags.length; ++i) {
|
||||||
this._addTag(tags[i]);
|
this._addTag(tags[i]);
|
||||||
}
|
}
|
||||||
|
@@ -1524,7 +1524,7 @@ function toLogin() {
|
|||||||
if(isMac()) {
|
if(isMac()) {
|
||||||
ipc.send('openUrl', {html: 'login.html', width: 278, height: 370, show: true, frame: false, resizable: false })
|
ipc.send('openUrl', {html: 'login.html', width: 278, height: 370, show: true, frame: false, resizable: false })
|
||||||
} else {
|
} else {
|
||||||
ipc.send('openUrl', { width: 278, height: 400, show: true, frame: true, resizable: false })
|
ipc.send('openUrl', {html: 'login.html', width: 278, height: 400, show: true, frame: true, resizable: false })
|
||||||
}
|
}
|
||||||
// gui.getCurrentWindow().close();
|
// gui.getCurrentWindow().close();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user