The 
 problem is solved. When the page performs the download operation, the webContents.downloadURL (url) of Electron will be called automatically, and the will-download event of session will be triggered. Just listen to the will-download event of session, then call event.preventDefault () to prevent the default download of the calling system, and then call your own download function. Thank you 
 mainWindow.webContents.session.on ('will-download', (event,item,webContents) = > {
).
    event.preventDefault();
    //console.log('will-download'+item.getURL());
    //
    MyDownLoad(item.getURL());
});
 I just wrote about electron download some time ago. What is a normal electron implementation download like? 
 first, let's talk about the ipc communication of electron.  ipcMain ,  ipcRenderer  
 the main process and the rendering process in electron are 
 main process (main.js) that communicates through ipc. Define the monitoring function 
.
ipcMain.on('download', (evt, args) => {
    let url = JSON.parse(args);
    downloadUrl = url.downloadUrl;
    saveUrl = url.saveUrl;
    mainWindow.webContents.downloadURL(downloadUrl);
});
 rendering process (page) calls ipcRenderer to trigger 
ipcRenderer.send('download', JSON.stringify({
    downloadUrl: `${ipURL()}${url}`,
    saveUrl: result[0]
}));
 in this way, you can trigger the download action of the main process. As for what the download action is, I won't write about it. Officially, there are 
 if you want to stop electron, just put the 
 in main.js.
ipcMain.on('download', (evt, args) => {
    let url = JSON.parse(args);
    downloadUrl = url.downloadUrl;
    saveUrl = url.saveUrl;
    //mainWindow.webContents.downloadURL(downloadUrl);
});
 just comment out 
 of course, everyone may write differently, but they are all sent from the rendering process to the main process through ipc. Find the actions that start downloading in the main process, and turn it off 
  File download is an action of the browser, and this part does not interact with js