YesPlayMusic/src/utils/nativeAlert.js
pan93412 e9f45c5352
feat: Use actively maintained unblockNeteaseMusic (#1105)
* refactor: use @unblockneteasemusic/server

we also use ipcMain.handle for unblock-music.

* refactor(utils/nativeAlert): remove the deprecated "remote"

* refactor(ipcMain): use our default sources

* style(config/vue): prettier

* feat(README): update for new UNM
2021-12-30 18:16:47 +08:00

30 lines
931 B
JavaScript

/**
* Returns an alert-like function that fits current runtime environment
*
* This function is amid to solve a electron bug on Windows, that, when
* user dismissed a browser alert, <input> elements cannot be focused
* for further editing unless switching to another window and then back
*
* @returns { (message:string) => void }
* Built-in alert function for browser environment
* A function wrapping {@link dialog.showMessageBoxSync} for electron environment
*
* @see {@link https://github.com/electron/electron/issues/19977} for upstream electron issue
*/
const nativeAlert = (() => {
if (process.env.IS_ELECTRON === true) {
const { dialog } = require('electron');
if (dialog) {
return message => {
var options = {
type: 'warning',
message,
};
dialog.showMessageBoxSync(null, options);
};
}
}
return alert;
})();
export default nativeAlert;