In the electron project that has already been done, download a word document. How can electron have a prompt after the download is successful?

in the electron project that has already been done, download a word document. How can electron have a prompt after the download is successful?

Mar.25,2021

there are two understandings of your question: (1) you don't know if you can't prompt when you've finished downloading. (2) you don't know how to prompt after downloading.
Let's talk about the first understanding first. If you use the Electron system browser's own download method, it will automatically trigger the 'will-download' message
mainWindow.webContents.session.on (' will-download', (event,item,webContents) = > {
item.once ('done', (event, state) = > {

).
if (state === 'completed') 
{
  console.log('Download successfully');
} 
else 
{
  console.log(`Download failed: ${state}`);
}

})
});
so that you know whether the download is finished or not. If the download function is written by you, the download is complete. If you don't know it yourself, you won't talk about it here.
the second understanding is that in the Electron main thread, you can use the console.log (); console to output prompts, or you can use the dialog pop-up window prompt
const {dialog} = require ('electron');
dialog.showMessageBox (
null,
{

)
  type: 'info',
  message: message.updateNotAva

});
can also communicate with the rendering thread
in the main thread
mainWindow.webContents.send ('alertMessage',message);
prompt
const {ipcRenderer} = require (' electron') with alert or other pop-up window in the rendering thread;

ipcRenderer.on ('alertMessage', (event, text) = > {

)
    alert(text);

});


I have never used electron, but there must be successful or failed callback functions in the downloaded methods. Call the relevant Toast or Alert in the successful or failed functions to give a hint.

Menu