mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
* 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
30 lines
931 B
JavaScript
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;
|