-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(media): add custom menu, refactor events into separate module
- Loading branch information
1 parent
f69428d
commit 4f73527
Showing
3 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { app } from 'electron' | ||
|
||
import { refocusWindows } from './window' | ||
|
||
export function initEvents (): void { | ||
app.on('activate', async () => { | ||
await refocusWindows() | ||
}) | ||
|
||
app.on('second-instance', async () => { | ||
await refocusWindows() | ||
}) | ||
|
||
app.on('window-all-closed', () => { | ||
app.quit() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
import { app } from 'electron' | ||
import { createDir } from '@library-api/core' | ||
|
||
import { initEvents } from './events' | ||
import { initIPC } from './ipc' | ||
import { createWindows, refocusWindows } from './window' | ||
import { initMenu } from './menu' | ||
import { createWindows } from './window' | ||
import { DOWNLOAD_DIR, VIDEO_DIR } from './constants' | ||
|
||
if (!app.requestSingleInstanceLock()) { | ||
app.quit() | ||
} | ||
|
||
app.on('activate', async () => { | ||
await refocusWindows() | ||
}) | ||
(async () => { | ||
// configure app | ||
initMenu() | ||
initEvents() | ||
|
||
app.on('second-instance', async () => { | ||
await refocusWindows() | ||
}) | ||
|
||
app.on('window-all-closed', () => { | ||
app.quit() | ||
}) | ||
|
||
;(async () => { | ||
// setup system files | ||
await createDir(DOWNLOAD_DIR) | ||
await createDir(VIDEO_DIR) | ||
|
||
// setup everything else | ||
await app.whenReady() | ||
initIPC() | ||
|
||
// start app | ||
await createWindows() | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Menu } from 'electron' | ||
import { MenuItemConstructorOptions } from 'electron/main' | ||
|
||
const appName = 'Library Media' | ||
const template: MenuItemConstructorOptions[] = [ | ||
{ | ||
label: appName, | ||
submenu: [ | ||
{ role: 'quit', label: `Quit ${appName}` } | ||
] | ||
} | ||
] | ||
|
||
export function initMenu (): void { | ||
const menu = Menu.buildFromTemplate(template) | ||
Menu.setApplicationMenu(menu) | ||
} |