mirror of
https://github.com/responsively-org/responsively-app
synced 2024-11-10 06:44:13 +00:00
App custom protocol bug fix when all-windows are closed
This commit is contained in:
parent
442153b9a3
commit
56f7c05ce9
1 changed files with 14 additions and 5 deletions
|
@ -33,6 +33,10 @@ if (process.env.NODE_ENV !== 'development') {
|
|||
});
|
||||
}
|
||||
|
||||
const protocol = 'responsively';
|
||||
|
||||
let hasActiveWindow = false;
|
||||
|
||||
export default class AppUpdater {
|
||||
constructor() {
|
||||
log.transports.file.level = 'info';
|
||||
|
@ -72,7 +76,7 @@ const installExtensions = async () => {
|
|||
const openUrl = url => {
|
||||
mainWindow.webContents.send(
|
||||
'address-change',
|
||||
url.replace('responsively://', '')
|
||||
url.replace(`${protocol}://`, '')
|
||||
);
|
||||
mainWindow.show();
|
||||
};
|
||||
|
@ -84,11 +88,11 @@ const openUrl = url => {
|
|||
app.on('will-finish-launching', () => {
|
||||
if (['win32', 'darwin'].includes(process.platform)) {
|
||||
if (process.argv.length >= 2) {
|
||||
app.setAsDefaultProtocolClient('responsively', process.execPath, [
|
||||
app.setAsDefaultProtocolClient(protocol, process.execPath, [
|
||||
path.resolve(process.argv[1]),
|
||||
]);
|
||||
} else {
|
||||
app.setAsDefaultProtocolClient('responsively');
|
||||
app.setAsDefaultProtocolClient(protocol);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -99,16 +103,20 @@ app.on('open-url', async (event, url) => {
|
|||
openUrl(url);
|
||||
} else {
|
||||
urlToOpen = url;
|
||||
if (!hasActiveWindow) {
|
||||
createWindow();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (false && process.env.NODE_ENV === 'development') {
|
||||
['win32', 'darwin'].includes(process.platform) &&
|
||||
app.removeAsDefaultProtocolClient('responsively');
|
||||
app.removeAsDefaultProtocolClient(protocol);
|
||||
}
|
||||
// Respect the OSX convention of having the application in memory even
|
||||
// after all windows have been closed
|
||||
hasActiveWindow = false;
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
|
@ -136,6 +144,7 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
|
|||
});
|
||||
|
||||
const createWindow = async () => {
|
||||
hasActiveWindow = true;
|
||||
if (
|
||||
process.env.NODE_ENV === 'development' ||
|
||||
process.env.DEBUG_PROD === 'true'
|
||||
|
|
Loading…
Reference in a new issue