导入导出优化

This commit is contained in:
life
2015-11-01 15:41:35 +08:00
parent 8198d4495d
commit 07ef7c0136
12 changed files with 46 additions and 17 deletions

13
node_modules/sync.js generated vendored
View File

@@ -523,7 +523,7 @@ var Sync = {
me.syncNotebook(-1, function(ok) { me.syncNotebook(-1, function(ok) {
if(ok) { if(ok) {
// Web.syncNoteFinish(); // Web.syncNoteFinish();
console.log('------------------') // console.log('------------------')
// 同步笔记 // 同步笔记
me.syncNote(-1, function(ok) { me.syncNote(-1, function(ok) {
if(ok) { if(ok) {
@@ -533,17 +533,18 @@ var Sync = {
// 更新上次同步时间 // 更新上次同步时间
me.updateLastSyncState(function() { me.updateLastSyncState(function() {
// send changes // send changes
me.sendChanges(); // me.sendChanges();
callback && callback(me._syncInfo); callback && callback(me._syncInfo, true);
}); });
}); });
} else { } else {
callback && callback(me._syncInfo); console.error('syncNote error.... 跳过tag');
callback && callback(me._syncInfo, false);
} }
}); });
} else { } else {
console.log('no-------') console.error('syncNotebook error.... 跳过note,tag');
callback && callback(me._syncInfo); callback && callback(me._syncInfo, false);
} }
}); });
}, },

View File

@@ -550,7 +550,7 @@ function log(o) {
<h4 class="modal-title modalTitle lang">Check for updates</h4> <h4 class="modal-title modalTitle lang">Check for updates</h4>
</div> </div>
<div class="modal-body" id="upgradeDialogBody"> <div class="modal-body" id="upgradeDialogBody">
<div class="cur-version-info">Current version: <span class="cur-version"></span></div> <div class="cur-version-info"><span class="lang">Current version</span>: <span class="cur-version"></span></div>
<div class="get-next-version-info-loading lang"> <div class="get-next-version-info-loading lang">
Checking for udpates... Checking for udpates...

View File

@@ -1154,8 +1154,9 @@ LeaAce = {
// 全量同步 // 全量同步
function fullSync(callback) { function fullSync(callback) {
log('full sync'); log('full sync');
SyncService.fullSync(function(ret) { $('.loading-footer').show();
callback && callback(); SyncService.fullSync(function(ret, ok) {
callback && callback(ok);
}); });
} }
@@ -1432,8 +1433,16 @@ 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() { fullSync(function(ok) {
_init(); if (!ok) {
Notify.show({title: 'Info', body: getMsg('Sync error, retry to sync after 3 seconds')});
setTimeout(function () {
reloadApp();
}, 3000);
}
else {
_init();
}
}); });
} }
$('#username').text(UserInfo.Username); $('#username').text(UserInfo.Username);

View File

@@ -20,7 +20,11 @@ var Notebook = {};
var Share = {}; var Share = {};
var Mobile = {}; // 手机端处理 var Mobile = {}; // 手机端处理
var LeaAce = {}; var LeaAce = {};
var Upgrade = {}; var Upgrade = {
checkForUpdates: function () {
Notify.show({title: 'Info', body: getMsg('Network error!')});
}
};
// markdown // markdown
var Converter; var Converter;

View File

@@ -194,6 +194,7 @@
"Choose Files": "选择文件", "Choose Files": "选择文件",
"Check for updates": "检查更新", "Check for updates": "检查更新",
"Checking for udpates...": "正在检查是否有可用更新...", "Checking for udpates...": "正在检查是否有可用更新...",
"Current version": "当前版本",
"Upgrade": "升级", "Upgrade": "升级",
"This note is conflicted with:": "该笔记与以下笔记冲突:", "This note is conflicted with:": "该笔记与以下笔记冲突:",
"Maker as resolved": "标记已解决冲突", "Maker as resolved": "标记已解决冲突",
@@ -286,5 +287,8 @@
"Hyperlink":"超链接","Please provide the link URL and an optional title":"请填写链接和一个可选的标题","optional title":"可选标题","Cancel":"取消","Strong":"粗体","strong text":"粗体","Emphasis":"斜体","emphasized text":"斜体","Blockquote":"引用","Code Sample":"代码","enter code here":"代码","Image":"图片","Heading":"标题","Numbered List":"有序列表","Bulleted List":"无序列表","List item":"项目","Horizontal Rule":"水平线","Undo":"撤销","Redo":"重做","enter image description here":"图片标题","enter link description here":"链接标题", "Hyperlink":"超链接","Please provide the link URL and an optional title":"请填写链接和一个可选的标题","optional title":"可选标题","Cancel":"取消","Strong":"粗体","strong text":"粗体","Emphasis":"斜体","emphasized text":"斜体","Blockquote":"引用","Code Sample":"代码","enter code here":"代码","Image":"图片","Heading":"标题","Numbered List":"有序列表","Bulleted List":"无序列表","List item":"项目","Horizontal Rule":"水平线","Undo":"撤销","Redo":"重做","enter image description here":"图片标题","enter link description here":"链接标题",
"Please select a note firstly.": "请先选择一个笔记", "Please select a note firstly.": "请先选择一个笔记",
"<span></span> notes selected": "当前选中了 <span></span> 篇笔记" "<span></span> notes selected": "当前选中了 <span></span> 篇笔记",
"Sync error, retry to sync after 3 seconds": "同步失败, 3 秒后自动重新尝试同步",
"Network error!": "网络异常"
} }

View File

@@ -194,6 +194,7 @@
"Choose Files": "選擇文件", "Choose Files": "選擇文件",
"Check for updates": "檢查更新", "Check for updates": "檢查更新",
"Checking for udpates...": "正在檢查是否有可用更新...", "Checking for udpates...": "正在檢查是否有可用更新...",
"Current version": "當前版本",
"Upgrade": "升級", "Upgrade": "升級",
"This note is conflicted with:": "該筆記與以下筆記沖突:", "This note is conflicted with:": "該筆記與以下筆記沖突:",
"Maker as resolved": "標記已解決沖突", "Maker as resolved": "標記已解決沖突",
@@ -286,5 +287,8 @@
"Hyperlink":"超鏈接","Please provide the link URL and an optional title":"請填寫鏈接和壹個可選的標題","optional title":"可選標題","Cancel":"取消","Strong":"粗體","strong text":"粗體","Emphasis":"斜體","emphasized text":"斜體","Blockquote":"引用","Code Sample":"代碼","enter code here":"代碼","Image":"圖片","Heading":"標題","Numbered List":"有序列表","Bulleted List":"無序列表","List item":"項目","Horizontal Rule":"水平線","Undo":"撤銷","Redo":"重做","enter image description here":"圖片標題","enter link description here":"鏈接標題", "Hyperlink":"超鏈接","Please provide the link URL and an optional title":"請填寫鏈接和壹個可選的標題","optional title":"可選標題","Cancel":"取消","Strong":"粗體","strong text":"粗體","Emphasis":"斜體","emphasized text":"斜體","Blockquote":"引用","Code Sample":"代碼","enter code here":"代碼","Image":"圖片","Heading":"標題","Numbered List":"有序列表","Bulleted List":"無序列表","List item":"項目","Horizontal Rule":"水平線","Undo":"撤銷","Redo":"重做","enter image description here":"圖片標題","enter link description here":"鏈接標題",
"Please select a note firstly.": "請先選擇壹個筆記", "Please select a note firstly.": "請先選擇壹個筆記",
"<span></span> notes selected": "當前選中了 <span></span> 篇筆記" "<span></span> notes selected": "當前選中了 <span></span> 篇筆記",
"Sync error, retry to sync after 3 seconds": "同步失敗, 3 秒後自動重新嘗試同步",
"Network error!": "網絡異常"
} }

View File

@@ -1407,7 +1407,7 @@ a.input-group-addon {
.preview-container { .preview-container {
position: absolute; position: absolute;
overflow: auto; overflow: auto;
right: 0; right: 10px;
left: 30px; left: 30px;
} }
.wmd-prompt-background { .wmd-prompt-background {

View File

@@ -525,7 +525,7 @@ define(function() {
var name = note.Title ? note.Title + '.enex' : getMsg('Untitled') + '.enex'; var name = note.Title ? note.Title + '.enex' : getMsg('Untitled') + '.enex';
name = me.fixFilename(name); name = me.fixFilename(name);
var targetPath = path + '/' + name; var targetPath = path + Api.commonService.getPathSep() + name;
// 将路径和名字区分开 // 将路径和名字区分开
var pathInfo = Api.commonService.splitFile(targetPath); var pathInfo = Api.commonService.splitFile(targetPath);

View File

@@ -534,7 +534,7 @@ define(function() {
var name = note.Title ? note.Title + '.leanote' : getMsg('Untitled') + '.leanote'; var name = note.Title ? note.Title + '.leanote' : getMsg('Untitled') + '.leanote';
name = me.fixFilename(name); name = me.fixFilename(name);
var targetPath = path + '/' + name; var targetPath = path + Api.commonService.getPathSep() + name;
// 将路径和名字区分开 // 将路径和名字区分开
var pathInfo = Api.commonService.splitFile(targetPath); var pathInfo = Api.commonService.splitFile(targetPath);

View File

@@ -262,6 +262,8 @@ var Import = {
} }
} }
console.log('--- haha -- Note.updateNoteOrContent');
Note.updateNoteOrContent(jsonNote, function(insertedNote) { Note.updateNoteOrContent(jsonNote, function(insertedNote) {
eachCallback && eachCallback(insertedNote); eachCallback && eachCallback(insertedNote);
cb(); cb();

View File

@@ -153,6 +153,8 @@ define(function() {
n++; n++;
$('#importEvernoteMsg .curImportNote').html(me.getMsg("Import: %s Success!", note.Title)); $('#importEvernoteMsg .curImportNote').html(me.getMsg("Import: %s Success!", note.Title));
// 不要是新的, 不然切换笔记时又会保存一次
note.IsNew = false;
// 插入到当前笔记中 // 插入到当前笔记中
Note.addSync([note]); Note.addSync([note]);
} }

View File

@@ -154,6 +154,9 @@ define(function() {
n++; n++;
$('#importLeanoteMsg .curImportNote').html(me.getMsg("Import: %s Success!", note.Title)); $('#importLeanoteMsg .curImportNote').html(me.getMsg("Import: %s Success!", note.Title));
// 不要是新的, 不然切换笔记时又会保存一次
note.IsNew = false;
// 插入到当前笔记中 // 插入到当前笔记中
Note.addSync([note]); Note.addSync([note]);
} }