feat: reopen closed
This commit is contained in:
parent
de75b48519
commit
11c61b3d72
|
@ -15,9 +15,7 @@ const {
|
||||||
let win;
|
let win;
|
||||||
|
|
||||||
async function createWindow(flecks) {
|
async function createWindow(flecks) {
|
||||||
const {
|
const {browserWindowOptions} = flecks.get('@flecks/electron/server');
|
||||||
browserWindowOptions,
|
|
||||||
} = flecks.get('@flecks/electron/server');
|
|
||||||
win = new BrowserWindow(browserWindowOptions);
|
win = new BrowserWindow(browserWindowOptions);
|
||||||
await flecks.invokeSequentialAsync('@flecks/electron/server.window', win);
|
await flecks.invokeSequentialAsync('@flecks/electron/server.window', win);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +29,10 @@ export default {
|
||||||
* See: https://www.electronjs.org/docs/latest/api/browser-window
|
* See: https://www.electronjs.org/docs/latest/api/browser-window
|
||||||
*/
|
*/
|
||||||
browserWindowOptions: {},
|
browserWindowOptions: {},
|
||||||
|
/**
|
||||||
|
* Quit the app when all windows are closed.
|
||||||
|
*/
|
||||||
|
quitOnClosed: true,
|
||||||
/**
|
/**
|
||||||
* The URL to load in electron by default.
|
* The URL to load in electron by default.
|
||||||
*
|
*
|
||||||
|
@ -65,11 +67,16 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'@flecks/electron/server.initialize': async (app, flecks) => {
|
'@flecks/electron/server.initialize': async (app, flecks) => {
|
||||||
// Apple has to be *special*.
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
if (process.platform !== 'darwin') {
|
const {quitOnClosed} = flecks.get('@flecks/electron/server');
|
||||||
app.quit();
|
if (!quitOnClosed) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// Apple has to be *special*.
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app.quit();
|
||||||
});
|
});
|
||||||
app.on('activate', async () => {
|
app.on('activate', async () => {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) {
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
|
@ -84,6 +91,11 @@ export default {
|
||||||
const {url = `http://${$$public}`} = flecks.get('@flecks/electron/server');
|
const {url = `http://${$$public}`} = flecks.get('@flecks/electron/server');
|
||||||
await win.loadURL(url);
|
await win.loadURL(url);
|
||||||
},
|
},
|
||||||
|
'@flecks/repl.context': (flecks) => ({
|
||||||
|
electron: {
|
||||||
|
createWindow: () => createWindow(flecks),
|
||||||
|
},
|
||||||
|
}),
|
||||||
'@flecks/server.up': async (flecks) => {
|
'@flecks/server.up': async (flecks) => {
|
||||||
// `app` will be undefined if we aren't running in an electron environment. Just bail.
|
// `app` will be undefined if we aren't running in an electron environment. Just bail.
|
||||||
if (!app) {
|
if (!app) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user