/
QuickMeet
/
Chat.Desktop
Обзор
Документация
Войти
/
QuickMeet
/
Chat.Desktop
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/app/main/app.ts
169 строк
5 KB
Jean Brito
feat: New UI using Fuselage (#2927)
13 сен 2024, 23:05
Не верифицирован
13 сен 2024, 23:05
2f60cb9
Код
Авторство
О чём код?
import { app, session } from 'electron'; import { rimraf } from 'rimraf'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore:next-line // eslint-disable-next-line import/order, @typescript-eslint/no-unused-vars import electronBuilderJson from '../../../electron-builder.json'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore:next-line // eslint-disable-next-line import/order, @typescript-eslint/no-unused-vars import packageJson from '../../../package.json'; import { JITSI_SERVER_CAPTURE_SCREEN_PERMISSIONS_CLEARED } from '../../jitsi/actions'; import { dispatch, listen } from '../../store'; import { readSetting } from '../../store/readSetting'; import { SETTINGS_CLEAR_PERMITTED_SCREEN_CAPTURE_PERMISSIONS, SETTINGS_NTLM_CREDENTIALS_CHANGED, SETTINGS_SET_HARDWARE_ACCELERATION_OPT_IN_CHANGED, } from '../../ui/actions'; import { askForClearScreenCapturePermission } from '../../ui/main/dialogs'; import { getRootWindow } from '../../ui/main/rootWindow'; import { APP_ALLOWED_NTLM_CREDENTIALS_DOMAINS_SET, APP_MAIN_WINDOW_TITLE_SET, APP_PATH_SET, APP_VERSION_SET, } from '../actions'; export const packageJsonInformation = { productName: packageJson.productName, goUrlShortener: packageJson.goUrlShortener, }; export const electronBuilderJsonInformation = { appId: electronBuilderJson.appId, protocol: electronBuilderJson.protocols.schemes[0], }; export const getPlatformName = (): string => { switch (process.platform) { case 'win32': return 'Windows'; case 'linux': return 'Linux'; case 'darwin': return 'macOS'; default: return 'Unknown'; } }; export const relaunchApp = (...args: string[]): void => { const command = process.argv.slice(1, app.isPackaged ? 1 : 2); app.relaunch({ args: [...command, ...args] }); app.exit(); }; export const performElectronStartup = (): void => { app.setAsDefaultProtocolClient(electronBuilderJsonInformation.protocol); app.setAppUserModelId(electronBuilderJsonInformation.appId); app.commandLine.appendSwitch('--autoplay-policy', 'no-user-gesture-required'); app.commandLine.appendSwitch( 'disable-features', 'HardwareMediaKeyHandling,MediaSessionService' ); const args = process.argv.slice(app.isPackaged ? 1 : 2); if (args.includes('--reset-app-data')) { rimraf.sync(app.getPath('userData')); relaunchApp(); return; } const canStart = process.mas || app.requestSingleInstanceLock(); if (!canStart) { app.exit(); return; } const isHardwareAccelerationEnabled = readSetting( 'isHardwareAccelerationEnabled' ); if ( args.includes('--disable-gpu') || isHardwareAccelerationEnabled === false ) { console.log('Disabling Hardware acceleration'); app.disableHardwareAcceleration(); app.commandLine.appendSwitch('--disable-2d-canvas-image-chromium'); app.commandLine.appendSwitch('--disable-accelerated-2d-canvas'); app.commandLine.appendSwitch('--disable-gpu'); } }; export const setupApp = (): void => { app.addListener('activate', async () => { const browserWindow = await getRootWindow(); if (!browserWindow.isVisible()) { browserWindow.showInactive(); } browserWindow.focus(); }); app.addListener('window-all-closed', () => { app.quit(); }); listen(SETTINGS_SET_HARDWARE_ACCELERATION_OPT_IN_CHANGED, (_action) => { relaunchApp(); }); listen(APP_ALLOWED_NTLM_CREDENTIALS_DOMAINS_SET, (action) => { if (action.payload.length > 0) { session.defaultSession.allowNTLMCredentialsForDomains(action.payload); } }); listen(SETTINGS_NTLM_CREDENTIALS_CHANGED, (action) => { if (action.payload === true) { const allowedNTLMCredentialsDomains = readSetting( 'allowedNTLMCredentialsDomains' ); if (allowedNTLMCredentialsDomains) { console.log('Setting NTLM credentials', allowedNTLMCredentialsDomains); session.defaultSession.allowNTLMCredentialsForDomains( allowedNTLMCredentialsDomains ); } } else { console.log('Clearing NTLM credentials'); session.defaultSession.allowNTLMCredentialsForDomains(''); } }); listen( SETTINGS_CLEAR_PERMITTED_SCREEN_CAPTURE_PERMISSIONS, async (_action) => { const permitted = await askForClearScreenCapturePermission(); if (permitted) { dispatch({ type: JITSI_SERVER_CAPTURE_SCREEN_PERMISSIONS_CLEARED, payload: {}, }); } } ); const allowedNTLMCredentialsDomains = readSetting( 'allowedNTLMCredentialsDomains' ); const isNTLMCredentialsEnabled = readSetting('isNTLMCredentialsEnabled'); if (isNTLMCredentialsEnabled && allowedNTLMCredentialsDomains.length > 0) { console.log('Setting NTLM credentials', allowedNTLMCredentialsDomains); session.defaultSession.allowNTLMCredentialsForDomains( allowedNTLMCredentialsDomains ); } dispatch({ type: APP_PATH_SET, payload: app.getAppPath() }); dispatch({ type: APP_VERSION_SET, payload: app.getVersion() }); dispatch({ type: APP_MAIN_WINDOW_TITLE_SET, payload: 'Rocket.Chat' }); };