mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-14 15:11:24 +00:00
Fix white screen on Windows when start
This commit is contained in:
@@ -1 +1 @@
|
|||||||
{"version":"2.2","updatedTime":"2016-12-29T07:21:51.505Z"}
|
{"version":"2.3","updatedTime":"2017-01-20T07:21:51.505Z"}
|
@@ -190,7 +190,7 @@ $(function() {
|
|||||||
// setTimeout(function() {
|
// setTimeout(function() {
|
||||||
$body.removeClass('loading');
|
$body.removeClass('loading');
|
||||||
goToMainPage();
|
goToMainPage();
|
||||||
gui.getCurrentWindow().close();
|
// gui.getCurrenstWindow().close();
|
||||||
// }, 2000);
|
// }, 2000);
|
||||||
}
|
}
|
||||||
// 不成功, 则用api登录
|
// 不成功, 则用api登录
|
||||||
@@ -228,7 +228,7 @@ $(function() {
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$body.removeClass('loading');
|
$body.removeClass('loading');
|
||||||
goToMainPage();
|
goToMainPage();
|
||||||
gui.getCurrentWindow().close();
|
// gui.getCurrentWindow().close();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
} else {
|
} else {
|
||||||
$body.removeClass('loading');
|
$body.removeClass('loading');
|
||||||
|
124
main.js
124
main.js
@@ -109,6 +109,64 @@ var DB = {
|
|||||||
// initialization and ready for creating browser windows.
|
// initialization and ready for creating browser windows.
|
||||||
app.on('ready', openIt);
|
app.on('ready', openIt);
|
||||||
|
|
||||||
|
function removeEvents (win) {
|
||||||
|
win.removeAllListeners('closed');
|
||||||
|
win.removeAllListeners('focus');
|
||||||
|
win.removeAllListeners('blur');
|
||||||
|
win.removeAllListeners('close');
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindEvents (win) {
|
||||||
|
|
||||||
|
// Emitted when the window is closed.
|
||||||
|
win.on('closed', function() {
|
||||||
|
console.log('closed');
|
||||||
|
// Dereference the window object, usually you would store windows
|
||||||
|
// in an array if your app supports multi windows, this is the time
|
||||||
|
// when you should delete the corresponding element.
|
||||||
|
win = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
win.on('focus', function() {
|
||||||
|
console.log('focus');
|
||||||
|
// ipc.send('focusWindow'); mainProcess没有该方法
|
||||||
|
if(win && win.webContents)
|
||||||
|
win.webContents.send('focusWindow');
|
||||||
|
});
|
||||||
|
win.on('blur', function() {
|
||||||
|
console.log('blur');
|
||||||
|
if(win && win.webContents)
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 以前的关闭是真关闭, 现是是假关闭了
|
||||||
|
// 关闭,先保存数据
|
||||||
|
win.on('close', function(e) {
|
||||||
|
// windows支持tray, 点close就是隐藏
|
||||||
|
if (process.platform.toLowerCase().indexOf('win') === 0) { // win32
|
||||||
|
win.hide();
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mac 在docker下quit;
|
||||||
|
// linux直接点x linux不支持Tray
|
||||||
|
close(e, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function openIt() {
|
function openIt() {
|
||||||
// 数据库
|
// 数据库
|
||||||
DB.init();
|
DB.init();
|
||||||
@@ -131,52 +189,7 @@ function openIt() {
|
|||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadURL('file://' + __dirname + '/note.html');
|
mainWindow.loadURL('file://' + __dirname + '/note.html');
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
bindEvents(mainWindow);
|
||||||
mainWindow.on('closed', function() {
|
|
||||||
console.log('closed');
|
|
||||||
// Dereference the window object, usually you would store windows
|
|
||||||
// in an array if your app supports multi windows, this is the time
|
|
||||||
// when you should delete the corresponding element.
|
|
||||||
mainWindow = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.on('focus', function() {
|
|
||||||
console.log('focus');
|
|
||||||
// ipc.send('focusWindow'); mainProcess没有该方法
|
|
||||||
if(mainWindow && mainWindow.webContents)
|
|
||||||
mainWindow.webContents.send('focusWindow');
|
|
||||||
});
|
|
||||||
mainWindow.on('blur', function() {
|
|
||||||
console.log('blur');
|
|
||||||
if(mainWindow && mainWindow.webContents)
|
|
||||||
mainWindow.webContents.send('blurWindow');
|
|
||||||
});
|
|
||||||
|
|
||||||
function close (e, force) {
|
|
||||||
console.log('close:', force);
|
|
||||||
if (mainWindow) {
|
|
||||||
mainWindow.hide();
|
|
||||||
e && e.preventDefault();
|
|
||||||
mainWindow.webContents.send('closeWindow');
|
|
||||||
} else {
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 以前的关闭是真关闭, 现是是假关闭了
|
|
||||||
// 关闭,先保存数据
|
|
||||||
mainWindow.on('close', function(e) {
|
|
||||||
// windows支持tray, 点close就是隐藏
|
|
||||||
if (process.platform.toLowerCase().indexOf('win') === 0) { // win32
|
|
||||||
mainWindow.hide();
|
|
||||||
e.preventDefault();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// mac 在docker下quit;
|
|
||||||
// linux直接点x linux不支持Tray
|
|
||||||
close(e, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 前端发来可以关闭了
|
// 前端发来可以关闭了
|
||||||
ipc.on('quit-app', function(event, arg) {
|
ipc.on('quit-app', function(event, arg) {
|
||||||
@@ -189,6 +202,25 @@ function openIt() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// open login.html and note.html
|
||||||
|
ipc.on('openUrl', function(event, arg) {
|
||||||
|
console.log('openUrl', arg);
|
||||||
|
|
||||||
|
var html = arg.html;
|
||||||
|
var everWindow = mainWindow;
|
||||||
|
var win2 = new BrowserWindow(arg);
|
||||||
|
win2.loadURL('file://' + __dirname + '/' + html);
|
||||||
|
mainWindow = win2;
|
||||||
|
|
||||||
|
// remove all events then close it
|
||||||
|
removeEvents(everWindow);
|
||||||
|
everWindow.close();
|
||||||
|
|
||||||
|
if (html.indexOf('note.html') >= 0) {
|
||||||
|
bindEvents(mainWindow)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
pdfMain.init();
|
pdfMain.init();
|
||||||
|
|
||||||
function show () {
|
function show () {
|
||||||
|
7
node_modules/api.js
generated
vendored
7
node_modules/api.js
generated
vendored
@@ -39,7 +39,7 @@ var Api = {
|
|||||||
"List": null,
|
"List": null,
|
||||||
"Item": null
|
"Item": null
|
||||||
}*/
|
}*/
|
||||||
var ret = resp;
|
var ret = resp.body;
|
||||||
try {
|
try {
|
||||||
if(typeof ret == 'object') {
|
if(typeof ret == 'object') {
|
||||||
if(!ret['Ok'] && ret['Msg'] == 'NOTLOGIN') {
|
if(!ret['Ok'] && ret['Msg'] == 'NOTLOGIN') {
|
||||||
@@ -195,12 +195,7 @@ var Api = {
|
|||||||
return callback && callback(false);
|
return callback && callback(false);
|
||||||
}
|
}
|
||||||
var ret = response.body;
|
var ret = response.body;
|
||||||
// console.log('1. getSyncStateRet:')
|
|
||||||
if(Common.isOk(ret)) {
|
|
||||||
callback && callback(ret);
|
callback && callback(ret);
|
||||||
} else {
|
|
||||||
callback && callback(false);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获取笔记内容, 获取之后保存到笔记中
|
// 获取笔记内容, 获取之后保存到笔记中
|
||||||
|
12
node_modules/sync.js
generated
vendored
12
node_modules/sync.js
generated
vendored
@@ -718,8 +718,7 @@ var Sync = {
|
|||||||
me.fixConflicts(function() {
|
me.fixConflicts(function() {
|
||||||
callback();
|
callback();
|
||||||
// 已结束
|
// 已结束
|
||||||
Web.syncFinished();
|
me.setSyncFinished();
|
||||||
me.incrSyncStart = false;
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 同步状态
|
// 同步状态
|
||||||
@@ -736,10 +735,11 @@ var Sync = {
|
|||||||
// 增量同步
|
// 增量同步
|
||||||
incrSyncStart: false,
|
incrSyncStart: false,
|
||||||
// 如果第一次insync, 网络错误导致incrSyncStart不结束, 第二次就会永远转动
|
// 如果第一次insync, 网络错误导致incrSyncStart不结束, 第二次就会永远转动
|
||||||
setSyncFinished: function() {
|
setSyncFinished: function(hasError) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.incrSyncStart = false;
|
me.incrSyncStart = false;
|
||||||
Web.syncProgress(0);
|
// Web.syncProgress(0);
|
||||||
|
Web.syncFinished(hasError);
|
||||||
},
|
},
|
||||||
incrSync: function(again) {
|
incrSync: function(again) {
|
||||||
if (User.isLocal()) {
|
if (User.isLocal()) {
|
||||||
@@ -776,9 +776,9 @@ var Sync = {
|
|||||||
}
|
}
|
||||||
// 先从服务器上得到usn, 与本地的判断, 是否需要pull
|
// 先从服务器上得到usn, 与本地的判断, 是否需要pull
|
||||||
Api.getLastSyncState(function(serverState) {
|
Api.getLastSyncState(function(serverState) {
|
||||||
if(!serverState) {
|
if(!Common.isOk(serverState)) {
|
||||||
console.error(' get Server LastSyncState error!!');
|
console.error(' get Server LastSyncState error!!');
|
||||||
me.setSyncFinished();
|
me.setSyncFinished(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(' get Server LastSyncState ret', serverState.LastSyncUsn + ' ' + lastSyncUsn);
|
console.log(' get Server LastSyncState ret', serverState.LastSyncUsn + ' ' + lastSyncUsn);
|
||||||
|
4
node_modules/web.js
generated
vendored
4
node_modules/web.js
generated
vendored
@@ -104,9 +104,9 @@ var Web = {
|
|||||||
},
|
},
|
||||||
//--------------
|
//--------------
|
||||||
|
|
||||||
syncFinished: function() {
|
syncFinished: function(hasError) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.Note.syncFinished();
|
me.Note.syncFinished(hasError);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 删除笔记时, 更新左侧导航标签的count
|
// 删除笔记时, 更新左侧导航标签的count
|
||||||
|
@@ -1225,11 +1225,12 @@ Note.hideSpin = function() {
|
|||||||
me.startInterval();
|
me.startInterval();
|
||||||
};
|
};
|
||||||
// nodejs调用
|
// nodejs调用
|
||||||
Note.syncFinished = function() {
|
Note.syncFinished = function(hasError) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.hideSpin();
|
me.hideSpin();
|
||||||
|
if (!hasError) {
|
||||||
me._syncWarningE.hide();
|
me._syncWarningE.hide();
|
||||||
|
}
|
||||||
Note.hideSyncProgress();
|
Note.hideSyncProgress();
|
||||||
};
|
};
|
||||||
// 过时
|
// 过时
|
||||||
@@ -1278,9 +1279,9 @@ Note.notLogin = function() {
|
|||||||
};
|
};
|
||||||
Note.needUpgradeAccount = function () {
|
Note.needUpgradeAccount = function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
me._syncWarningE.show();
|
|
||||||
me.hideSpin();
|
me.hideSpin();
|
||||||
SyncService.setSyncFinished();
|
SyncService.setSyncFinished();
|
||||||
|
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'));
|
||||||
};
|
};
|
||||||
|
@@ -1507,25 +1507,26 @@ var ContextTips = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function goToMainPage() {
|
function goToMainPage() {
|
||||||
var BrowserWindow = gui.remote.BrowserWindow;
|
// var BrowserWindow = gui.remote.BrowserWindow;
|
||||||
var win = new BrowserWindow(getMainWinParams());
|
// var win = new BrowserWindow(getMainWinParams());
|
||||||
win.loadURL('file://' + __dirname + '/note.html?from=login');
|
// win.loasdURL('file://' + __dirname + '/note.html?from=login');
|
||||||
|
const {ipcRenderer} = require('electron');
|
||||||
|
var ipc = ipcRenderer;
|
||||||
|
var params = getMainWinParams();
|
||||||
|
params.html = 'note.html?from=login';
|
||||||
|
ipc.send('openUrl', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toLogin() {
|
function toLogin() {
|
||||||
var BrowserWindow = gui.remote.BrowserWindow;
|
const {ipcRenderer} = require('electron');
|
||||||
|
var ipc = ipcRenderer;
|
||||||
|
// var BrowserWindow = gui.remote.BrowserWindow;
|
||||||
if(isMac()) {
|
if(isMac()) {
|
||||||
var win = new BrowserWindow(
|
ipc.send('openUrl', {html: 'login.html', width: 278, height: 370, show: true, frame: false, resizable: false })
|
||||||
{ width: 278, height: 370, show: true, frame: false, resizable: false }
|
|
||||||
);
|
|
||||||
win.loadURL('file://' + __dirname + '/login.html');
|
|
||||||
} else {
|
} else {
|
||||||
var win = new BrowserWindow(
|
ipc.send('openUrl', { width: 278, height: 400, show: true, frame: true, resizable: false })
|
||||||
{ width: 278, height: 400, show: true, frame: true, resizable: false }
|
|
||||||
);
|
|
||||||
win.loadURL('file://' + __dirname + '/login.html');
|
|
||||||
}
|
}
|
||||||
gui.getCurrentWindow().close();
|
// gui.getCurrentWindow().close();
|
||||||
}
|
}
|
||||||
// 添加用户
|
// 添加用户
|
||||||
function switchAccount() {
|
function switchAccount() {
|
||||||
|
Reference in New Issue
Block a user