mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-14 07:00:53 +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() {
|
||||
$body.removeClass('loading');
|
||||
goToMainPage();
|
||||
gui.getCurrentWindow().close();
|
||||
// gui.getCurrenstWindow().close();
|
||||
// }, 2000);
|
||||
}
|
||||
// 不成功, 则用api登录
|
||||
@@ -228,7 +228,7 @@ $(function() {
|
||||
setTimeout(function(){
|
||||
$body.removeClass('loading');
|
||||
goToMainPage();
|
||||
gui.getCurrentWindow().close();
|
||||
// gui.getCurrentWindow().close();
|
||||
}, 2000);
|
||||
} else {
|
||||
$body.removeClass('loading');
|
||||
|
124
main.js
124
main.js
@@ -109,6 +109,64 @@ var DB = {
|
||||
// initialization and ready for creating browser windows.
|
||||
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() {
|
||||
// 数据库
|
||||
DB.init();
|
||||
@@ -131,52 +189,7 @@ function openIt() {
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL('file://' + __dirname + '/note.html');
|
||||
|
||||
// Emitted when the window is closed.
|
||||
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);
|
||||
});
|
||||
bindEvents(mainWindow);
|
||||
|
||||
// 前端发来可以关闭了
|
||||
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();
|
||||
|
||||
function show () {
|
||||
|
7
node_modules/api.js
generated
vendored
7
node_modules/api.js
generated
vendored
@@ -39,7 +39,7 @@ var Api = {
|
||||
"List": null,
|
||||
"Item": null
|
||||
}*/
|
||||
var ret = resp;
|
||||
var ret = resp.body;
|
||||
try {
|
||||
if(typeof ret == 'object') {
|
||||
if(!ret['Ok'] && ret['Msg'] == 'NOTLOGIN') {
|
||||
@@ -195,12 +195,7 @@ var Api = {
|
||||
return callback && callback(false);
|
||||
}
|
||||
var ret = response.body;
|
||||
// console.log('1. getSyncStateRet:')
|
||||
if(Common.isOk(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() {
|
||||
callback();
|
||||
// 已结束
|
||||
Web.syncFinished();
|
||||
me.incrSyncStart = false;
|
||||
me.setSyncFinished();
|
||||
})
|
||||
},
|
||||
// 同步状态
|
||||
@@ -736,10 +735,11 @@ var Sync = {
|
||||
// 增量同步
|
||||
incrSyncStart: false,
|
||||
// 如果第一次insync, 网络错误导致incrSyncStart不结束, 第二次就会永远转动
|
||||
setSyncFinished: function() {
|
||||
setSyncFinished: function(hasError) {
|
||||
var me = this;
|
||||
me.incrSyncStart = false;
|
||||
Web.syncProgress(0);
|
||||
// Web.syncProgress(0);
|
||||
Web.syncFinished(hasError);
|
||||
},
|
||||
incrSync: function(again) {
|
||||
if (User.isLocal()) {
|
||||
@@ -776,9 +776,9 @@ var Sync = {
|
||||
}
|
||||
// 先从服务器上得到usn, 与本地的判断, 是否需要pull
|
||||
Api.getLastSyncState(function(serverState) {
|
||||
if(!serverState) {
|
||||
if(!Common.isOk(serverState)) {
|
||||
console.error(' get Server LastSyncState error!!');
|
||||
me.setSyncFinished();
|
||||
me.setSyncFinished(true);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
me.Note.syncFinished();
|
||||
me.Note.syncFinished(hasError);
|
||||
},
|
||||
|
||||
// 删除笔记时, 更新左侧导航标签的count
|
||||
|
@@ -1225,11 +1225,12 @@ Note.hideSpin = function() {
|
||||
me.startInterval();
|
||||
};
|
||||
// nodejs调用
|
||||
Note.syncFinished = function() {
|
||||
Note.syncFinished = function(hasError) {
|
||||
var me = this;
|
||||
me.hideSpin();
|
||||
if (!hasError) {
|
||||
me._syncWarningE.hide();
|
||||
|
||||
}
|
||||
Note.hideSyncProgress();
|
||||
};
|
||||
// 过时
|
||||
@@ -1278,9 +1279,9 @@ Note.notLogin = function() {
|
||||
};
|
||||
Note.needUpgradeAccount = function () {
|
||||
var me = this;
|
||||
me._syncWarningE.show();
|
||||
me.hideSpin();
|
||||
SyncService.setSyncFinished();
|
||||
me._syncWarningE.show();
|
||||
me._syncWarningE.data('reason', 'NEED-UPGRADE-ACCOUNT');
|
||||
me._syncWarningE.attr('title', getMsg('You need to upgrade Leanote account'));
|
||||
};
|
||||
|
@@ -1507,25 +1507,26 @@ var ContextTips = {
|
||||
};
|
||||
|
||||
function goToMainPage() {
|
||||
var BrowserWindow = gui.remote.BrowserWindow;
|
||||
var win = new BrowserWindow(getMainWinParams());
|
||||
win.loadURL('file://' + __dirname + '/note.html?from=login');
|
||||
// var BrowserWindow = gui.remote.BrowserWindow;
|
||||
// var win = new BrowserWindow(getMainWinParams());
|
||||
// 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() {
|
||||
var BrowserWindow = gui.remote.BrowserWindow;
|
||||
const {ipcRenderer} = require('electron');
|
||||
var ipc = ipcRenderer;
|
||||
// var BrowserWindow = gui.remote.BrowserWindow;
|
||||
if(isMac()) {
|
||||
var win = new BrowserWindow(
|
||||
{ width: 278, height: 370, show: true, frame: false, resizable: false }
|
||||
);
|
||||
win.loadURL('file://' + __dirname + '/login.html');
|
||||
ipc.send('openUrl', {html: 'login.html', width: 278, height: 370, show: true, frame: false, resizable: false })
|
||||
} else {
|
||||
var win = new BrowserWindow(
|
||||
{ width: 278, height: 400, show: true, frame: true, resizable: false }
|
||||
);
|
||||
win.loadURL('file://' + __dirname + '/login.html');
|
||||
ipc.send('openUrl', { width: 278, height: 400, show: true, frame: true, resizable: false })
|
||||
}
|
||||
gui.getCurrentWindow().close();
|
||||
// gui.getCurrentWindow().close();
|
||||
}
|
||||
// 添加用户
|
||||
function switchAccount() {
|
||||
|
Reference in New Issue
Block a user