mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
Added a recording popup UI for the audio recording feature in the desktop app, improving the user experience when capturing audio from applications. ### What changed? - Created a new popup window system for displaying recording controls - Added a dedicated recording UI with start/stop controls and status indicators - Moved audio encoding logic from the main app to a dedicated module - Implemented smooth animations for popup appearance/disappearance - Updated the recording workflow to show visual feedback during recording process - Added internationalization support for recording-related text - Modified the recording status flow to include new states: new, recording, stopped, ready fix AF-2340
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import { BrowserWindow, WebContentsView } from 'electron';
|
|
|
|
import { AFFINE_EVENT_CHANNEL_NAME } from '../shared/type';
|
|
import { applicationMenuEvents } from './application-menu';
|
|
import { beforeAppQuit } from './cleanup';
|
|
import { logger } from './logger';
|
|
import { recordingEvents } from './recording';
|
|
import { sharedStorageEvents } from './shared-storage';
|
|
import { uiEvents } from './ui/events';
|
|
import { updaterEvents } from './updater/event';
|
|
import { popupEvents } from './windows-manager/popup';
|
|
|
|
export const allEvents = {
|
|
applicationMenu: applicationMenuEvents,
|
|
updater: updaterEvents,
|
|
ui: uiEvents,
|
|
sharedStorage: sharedStorageEvents,
|
|
recording: recordingEvents,
|
|
popup: popupEvents,
|
|
};
|
|
|
|
function getActiveWindows() {
|
|
return BrowserWindow.getAllWindows().filter(win => !win.isDestroyed());
|
|
}
|
|
|
|
export function registerEvents() {
|
|
const unsubs: (() => void)[] = [];
|
|
// register events
|
|
for (const [namespace, namespaceEvents] of Object.entries(allEvents)) {
|
|
for (const [key, eventRegister] of Object.entries(namespaceEvents)) {
|
|
const unsubscribe = eventRegister((...args: any[]) => {
|
|
const chan = `${namespace}:${key}`;
|
|
logger.debug(
|
|
'[ipc-event]',
|
|
chan,
|
|
args.filter(
|
|
a =>
|
|
a !== undefined &&
|
|
typeof a !== 'function' &&
|
|
typeof a !== 'object'
|
|
)
|
|
);
|
|
// is this efficient?
|
|
getActiveWindows().forEach(win => {
|
|
if (win.isDestroyed()) {
|
|
return;
|
|
}
|
|
// .webContents could be undefined if the window is destroyed
|
|
win.webContents?.send(AFFINE_EVENT_CHANNEL_NAME, chan, ...args);
|
|
win.contentView.children.forEach(child => {
|
|
if (
|
|
child instanceof WebContentsView &&
|
|
child.webContents &&
|
|
!child.webContents.isDestroyed()
|
|
) {
|
|
child.webContents?.send(AFFINE_EVENT_CHANNEL_NAME, chan, ...args);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
unsubs.push(unsubscribe);
|
|
}
|
|
}
|
|
|
|
unsubs.forEach(unsub => {
|
|
beforeAppQuit(() => {
|
|
unsub();
|
|
});
|
|
});
|
|
}
|