docs: Make the example cover all cases
This commit is contained in:
parent
dcad25c98c
commit
cbcbcaeb41
1 changed files with 9 additions and 5 deletions
|
@ -13,13 +13,17 @@ win.webContents.session.on('will-download', (event, item, webContents) => {
|
||||||
item.setSavePath('/tmp/save.pdf')
|
item.setSavePath('/tmp/save.pdf')
|
||||||
|
|
||||||
item.on('updated', (event, state) => {
|
item.on('updated', (event, state) => {
|
||||||
if (state === 'progressing') {
|
if (state === 'interrupted') {
|
||||||
console.log(`Received bytes: ${item.getReceivedBytes()}`)
|
console.log('Download is interrupted but can be resumed')
|
||||||
|
} else if (state === 'progressing') {
|
||||||
|
if (item.isPaused()) {
|
||||||
|
console.log('Download is paused')
|
||||||
} else {
|
} else {
|
||||||
console.log('Download stopped')
|
console.log(`Received bytes: ${item.getReceivedBytes()}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
item.on('done', (event, state) => {
|
item.once('done', (event, state) => {
|
||||||
if (state === 'completed') {
|
if (state === 'completed') {
|
||||||
console.log('Download successfully')
|
console.log('Download successfully')
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue