mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 18:16:15 +08:00
21 lines
432 B
TypeScript
21 lines
432 B
TypeScript
import { app } from 'electron';
|
|
|
|
import { logger } from './logger';
|
|
|
|
const cleanupRegistry: (() => void)[] = [];
|
|
|
|
export function beforeAppQuit(fn: () => void) {
|
|
cleanupRegistry.push(fn);
|
|
}
|
|
|
|
app.on('before-quit', () => {
|
|
cleanupRegistry.forEach(fn => {
|
|
// some cleanup functions might throw on quit and crash the app
|
|
try {
|
|
fn();
|
|
} catch (err) {
|
|
logger.warn('cleanup error on quit', err);
|
|
}
|
|
});
|
|
});
|