bugfix: #338 error message on export cancel (#364)

* bugfix: #338 error message on export cancel

* fixed the solution

* put package-lock.json back
This commit is contained in:
mklpiening 2018-06-19 04:26:27 +02:00 committed by 冉四夕
parent 1073e650cc
commit 1f0b65d95c

View File

@ -20,24 +20,26 @@ const handleResponseForExport = (e, { type, content, pathname }) => {
defaultPath
})
// If export PDF, the content will be undefined.
if (!content && type === 'pdf') {
win.webContents.printToPDF({ printBackground: true }, (err, data) => {
if (err) log(err)
else {
writeFile(filePath, data, extension)
.then(() => {
win.webContents.send('AGANI::export-success', { type, filePath })
})
.catch(log)
}
})
} else {
writeFile(filePath, content, extension)
.then(() => {
win.webContents.send('AGANI::export-success', { type, filePath })
if (filePath) {
// If export PDF, the content will be undefined.
if (!content && type === 'pdf') {
win.webContents.printToPDF({ printBackground: true }, (err, data) => {
if (err) log(err)
else {
writeFile(filePath, data, extension)
.then(() => {
win.webContents.send('AGANI::export-success', { type, filePath })
})
.catch(log)
}
})
.catch(log)
} else {
writeFile(filePath, content, extension)
.then(() => {
win.webContents.send('AGANI::export-success', { type, filePath })
})
.catch(log)
}
}
}