bug_x

导航

 

1、code from github

url-link:

   https://github.com/electron/electron/issues/7712

// to store downloadItems
var downloadItems = [];

ipcMain.on('dowloadFiles', function(evt, options) {
    // ...
    if(options.command === 'stopDownload') {
           var item = getDownloadItem(options.url); // fetch item from downloadItems array
           item.pause();
           return;
      }
    // ...
});

mainWindow.webContents.session.on('will-download', function(event, item, webContents) {
    // ...

      // store the download item, so that we can call item.pause/resume in a 
      downloadItems.push(item);

    // ...
});

  

 

posted on 2018-12-10 13:56  bug_x  阅读(936)  评论(3编辑  收藏  举报