mirror of
https://github.com/electron/electron.git
synced 2026-01-25 23:38:18 -05:00
docs: Make the example cover all cases
This commit is contained in:
@@ -13,13 +13,17 @@ win.webContents.session.on('will-download', (event, item, webContents) => {
|
||||
item.setSavePath('/tmp/save.pdf')
|
||||
|
||||
item.on('updated', (event, state) => {
|
||||
if (state === 'progressing') {
|
||||
console.log(`Received bytes: ${item.getReceivedBytes()}`)
|
||||
} else {
|
||||
console.log('Download stopped')
|
||||
if (state === 'interrupted') {
|
||||
console.log('Download is interrupted but can be resumed')
|
||||
} else if (state === 'progressing') {
|
||||
if (item.isPaused()) {
|
||||
console.log('Download is paused')
|
||||
} else {
|
||||
console.log(`Received bytes: ${item.getReceivedBytes()}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
item.on('done', (event, state) => {
|
||||
item.once('done', (event, state) => {
|
||||
if (state === 'completed') {
|
||||
console.log('Download successfully')
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user