mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-14 07:00:53 +00:00
Merge pull request #351 from chaosue/master
fix compatibilies with electron9 for plugins; auto hide default menubar
This commit is contained in:
1
main.js
1
main.js
@@ -204,6 +204,7 @@ function openIt() {
|
||||
height: 595,
|
||||
frame: process.platform != 'darwin',
|
||||
transparent: false,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
|
27
node_modules/pdf_main.js
generated
vendored
27
node_modules/pdf_main.js
generated
vendored
@@ -15,11 +15,7 @@ var exportPdf = {
|
||||
win.webContents.on('did-finish-load', function() {
|
||||
console.log('load ok');
|
||||
setTimeout(function() {
|
||||
win.webContents.printToPDF({
|
||||
printBackground: true,
|
||||
landscape: false,
|
||||
pageSize: 'A4'
|
||||
}, function(err, data) {
|
||||
var callback = function(err, data) {
|
||||
fs.writeFile(targetPdfPath, data, function(err) {
|
||||
if (err) {
|
||||
callbcak(false);
|
||||
@@ -29,7 +25,26 @@ var exportPdf = {
|
||||
}
|
||||
// win.close();
|
||||
});
|
||||
})
|
||||
};
|
||||
var po = win.webContents.printToPDF({
|
||||
printBackground: true,
|
||||
landscape: false,
|
||||
pageSize: 'A4'
|
||||
},
|
||||
callbcak
|
||||
);
|
||||
|
||||
if(typeof(po) != "object"){
|
||||
return;
|
||||
}
|
||||
|
||||
po.then(data => {
|
||||
callback(null, data);
|
||||
}
|
||||
).catch( err => {
|
||||
callback(err, null);
|
||||
}
|
||||
);
|
||||
}, isMarkdown ? 1000 : 100);
|
||||
});
|
||||
|
||||
|
@@ -405,7 +405,7 @@ define(function() {
|
||||
|
||||
getTargetPath: function(callback) {
|
||||
// showSaveDialog 不支持property选择文件夹
|
||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
||||
properties: ['openDirectory']
|
||||
@@ -414,6 +414,21 @@ define(function() {
|
||||
callback(targetPath);
|
||||
}
|
||||
);
|
||||
|
||||
if(typeof(po) != "object"){
|
||||
return;
|
||||
}
|
||||
|
||||
po.then(function(re){
|
||||
if(re.canceled !== false || re.filePaths.length < 1){
|
||||
return;
|
||||
}
|
||||
callback(re.filePaths[0]);
|
||||
},
|
||||
function(err){
|
||||
alert(err);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
loadingIsClosed: false,
|
||||
|
@@ -185,7 +185,7 @@ define(function() {
|
||||
|
||||
getTargetPath: function(callback) {
|
||||
// showSaveDialog 不支持property选择文件夹
|
||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
||||
properties: ['openDirectory']
|
||||
@@ -194,6 +194,20 @@ define(function() {
|
||||
callback(targetPath);
|
||||
}
|
||||
);
|
||||
if(typeof(po) != "object"){
|
||||
return;
|
||||
}
|
||||
|
||||
po.then(function(re){
|
||||
if(re.canceled !== false || re.filePaths.length < 1){
|
||||
return;
|
||||
}
|
||||
callback(re.filePaths[0]);
|
||||
},
|
||||
function(err){
|
||||
alert(err);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
loadingIsClosed: false,
|
||||
|
@@ -419,7 +419,7 @@ define(function() {
|
||||
|
||||
getTargetPath: function(callback) {
|
||||
// showSaveDialog 不支持property选择文件夹
|
||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
||||
properties: ['openDirectory']
|
||||
@@ -428,6 +428,21 @@ define(function() {
|
||||
callback(targetPath);
|
||||
}
|
||||
);
|
||||
|
||||
if(typeof(po) != "object"){
|
||||
return;
|
||||
}
|
||||
|
||||
po.then(function(re){
|
||||
if(re.canceled !== false || re.filePaths.length < 1){
|
||||
return;
|
||||
}
|
||||
callback(re.filePaths[0]);
|
||||
},
|
||||
function(err){
|
||||
alert(err);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
loadingIsClosed: false,
|
||||
|
@@ -152,7 +152,7 @@ define(function() {
|
||||
|
||||
getTargetPath: function (callback) {
|
||||
// showSaveDialog 不支持property选择文件夹
|
||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
||||
properties: ['openDirectory']
|
||||
@@ -161,6 +161,20 @@ define(function() {
|
||||
callback(targetPath);
|
||||
}
|
||||
);
|
||||
if(typeof(po) != "object"){
|
||||
return;
|
||||
}
|
||||
|
||||
po.then(function(re){
|
||||
if(re.canceled !== false || re.filePaths.length < 1){
|
||||
return;
|
||||
}
|
||||
callback(re.filePaths[0]);
|
||||
},
|
||||
function(err){
|
||||
alert(err);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
loadingIsClosed: false,
|
||||
@@ -185,7 +199,8 @@ define(function() {
|
||||
setTimeout(function () {
|
||||
me.hideLoading();
|
||||
});
|
||||
}});
|
||||
}
|
||||
});
|
||||
Api.loading.setProgress(1);
|
||||
|
||||
Api.noteService.getNotes(notebookId, function (notes) {
|
||||
@@ -241,7 +256,8 @@ define(function() {
|
||||
setTimeout(function () {
|
||||
me.hideLoading();
|
||||
});
|
||||
}});
|
||||
}
|
||||
});
|
||||
Api.loading.setProgress(1);
|
||||
|
||||
var i = 0;
|
||||
|
@@ -118,15 +118,7 @@ define(function() {
|
||||
|
||||
// 导入, 选择文件
|
||||
$('#chooseEvernoteFile').click(function() {
|
||||
|
||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
filters: [
|
||||
{ name: 'Evernote', extensions: ['enex'] }
|
||||
]
|
||||
},
|
||||
function(paths) {
|
||||
var callback = function(paths) {
|
||||
if(!paths) {
|
||||
return;
|
||||
}
|
||||
@@ -170,9 +162,33 @@ define(function() {
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
filters: [
|
||||
{ name: 'Evernote', extensions: ['enex'] }
|
||||
]
|
||||
},
|
||||
callback
|
||||
);
|
||||
|
||||
if(typeof(po) != "object"){
|
||||
return;
|
||||
}
|
||||
|
||||
po.then(
|
||||
function(re){
|
||||
if(re.canceled !== false || re.filePaths.length < 1){
|
||||
return;
|
||||
}
|
||||
callback(re.filePaths);
|
||||
},
|
||||
function(err){
|
||||
alert(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
|
@@ -118,15 +118,7 @@ define(function() {
|
||||
|
||||
// 导入, 选择文件
|
||||
$('#chooseHTMLFile').click(function() {
|
||||
|
||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
filters: [
|
||||
{ name: 'HTML', extensions: ['html'] }
|
||||
]
|
||||
},
|
||||
function(paths) {
|
||||
var callback = function(paths) {
|
||||
if(!paths) {
|
||||
return;
|
||||
}
|
||||
@@ -170,9 +162,32 @@ define(function() {
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
filters: [
|
||||
{ name: 'HTML', extensions: ['html'] }
|
||||
]
|
||||
}
|
||||
, callback
|
||||
);
|
||||
if(typeof(po) != "object"){
|
||||
return;
|
||||
}
|
||||
|
||||
po.then(
|
||||
function(re){
|
||||
if(re.canceled !== false || re.filePaths.length < 1){
|
||||
return;
|
||||
}
|
||||
callback(re.filePaths);
|
||||
},
|
||||
function(err){
|
||||
alert(err);
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
|
@@ -118,15 +118,8 @@ define(function() {
|
||||
|
||||
// 导入, 选择文件
|
||||
$('#chooseLeanoteFile').click(function() {
|
||||
var callback = function(paths) {
|
||||
|
||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
filters: [
|
||||
{ name: 'Leanote', extensions: ['leanote'] }
|
||||
]
|
||||
},
|
||||
function(paths) {
|
||||
if(!paths) {
|
||||
return;
|
||||
}
|
||||
@@ -173,8 +166,30 @@ define(function() {
|
||||
}
|
||||
);
|
||||
}
|
||||
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||
{
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
filters: [
|
||||
{ name: 'Leanote', extensions: ['leanote'] }
|
||||
]
|
||||
},
|
||||
callback
|
||||
);
|
||||
if(typeof(po) != "object"){
|
||||
return;
|
||||
}
|
||||
|
||||
po.then(
|
||||
function(re){
|
||||
if(re.canceled !== false || re.filePaths.length < 1){
|
||||
return;
|
||||
}
|
||||
callback(re.filePaths);
|
||||
},
|
||||
function(err){
|
||||
alert(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user