system tray and package config
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.5 KiB |
BIN
electron-ui/src/assets/tray_icon.png
Normal file
BIN
electron-ui/src/assets/tray_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 780 B |
@ -10,7 +10,7 @@
|
||||
*/
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { app, BrowserWindow, shell, ipcMain } from 'electron';
|
||||
import { app, BrowserWindow, shell, ipcMain, Tray, Menu } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
import log from 'electron-log';
|
||||
import MenuBuilder from './menu';
|
||||
@ -28,7 +28,8 @@ class AppUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
let mainWindow: BrowserWindow;
|
||||
let tray: Tray | null = null;
|
||||
|
||||
ipcMain.on('ipc-example', async (event, arg) => {
|
||||
const msgTemplate = (pingPong: string) => `IPC test: ${pingPong}`;
|
||||
@ -78,7 +79,7 @@ const createWindow = async () => {
|
||||
show: false,
|
||||
width: 1024,
|
||||
height: 728,
|
||||
icon: getAssetPath('icon.png'),
|
||||
icon: getAssetPath('icon.png'), // Set app icon
|
||||
webPreferences: {
|
||||
preload: app.isPackaged
|
||||
? path.join(__dirname, 'preload.js')
|
||||
@ -99,12 +100,15 @@ const createWindow = async () => {
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null;
|
||||
mainWindow.on('close', (event) => {
|
||||
console.log('close event triggered');
|
||||
event.preventDefault();
|
||||
mainWindow.hide();
|
||||
});
|
||||
|
||||
const menuBuilder = new MenuBuilder(mainWindow);
|
||||
menuBuilder.buildMenu();
|
||||
registerFileIpcHandlers();
|
||||
|
||||
// Open urls in the user's browser
|
||||
mainWindow.webContents.setWindowOpenHandler((edata) => {
|
||||
@ -112,11 +116,31 @@ const createWindow = async () => {
|
||||
return { action: 'deny' };
|
||||
});
|
||||
|
||||
registerFileIpcHandlers();
|
||||
|
||||
// Remove this if your app does not use auto updates
|
||||
// eslint-disable-next-line
|
||||
new AppUpdater();
|
||||
console.log('asset path: ', getAssetPath('tray_icon.png'));
|
||||
tray = new Tray(getAssetPath('tray_icon.png'));
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Show',
|
||||
click: () => {
|
||||
mainWindow?.show();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Quit',
|
||||
click: () => {
|
||||
pythonManager.stop();
|
||||
app.quit();
|
||||
},
|
||||
},
|
||||
]);
|
||||
tray.setToolTip('ClipTrim');
|
||||
tray.setContextMenu(contextMenu);
|
||||
tray.on('double-click', () => {
|
||||
mainWindow?.show();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@ -126,16 +150,17 @@ const createWindow = async () => {
|
||||
app.on('window-all-closed', () => {
|
||||
// Respect the OSX convention of having the application in memory even
|
||||
// after all windows have been closed
|
||||
pythonManager.stop();
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
// pythonManager.stop();
|
||||
// Do not quit app, keep tray active
|
||||
// if (process.platform !== 'darwin') {
|
||||
// app.quit();
|
||||
// }
|
||||
});
|
||||
|
||||
app
|
||||
.whenReady()
|
||||
.then(() => {
|
||||
// pythonManager.start();
|
||||
pythonManager.start();
|
||||
createWindow();
|
||||
app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
/* @import 'tailwindcss/base';
|
||||
@import 'tailwindcss/components';
|
||||
@import 'tailwindcss/utilities'; */
|
||||
/*
|
||||
* @NOTE: Prepend a `~` to css file paths that are in your node_modules
|
||||
* See https://github.com/webpack-contrib/sass-loader#imports
|
||||
|
||||
@ -215,6 +215,7 @@ export default function AudioTrimmer({
|
||||
{ threshold: 0.1 },
|
||||
);
|
||||
observer.observe(node);
|
||||
// eslint-disable-next-line consistent-return
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
};
|
||||
@ -234,6 +235,7 @@ export default function AudioTrimmer({
|
||||
}
|
||||
}
|
||||
fetchAudio();
|
||||
// eslint-disable-next-line consistent-return
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="script-src 'self' 'unsafe-inline'"
|
||||
/>
|
||||
<title>Hello Electron React!</title>
|
||||
<title>ClipTrim</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
Reference in New Issue
Block a user